dotfiles/dev/templateC/cmake/functions.cmake

13 lines
409 B
CMake
Raw Normal View History

2019-07-21 01:27:31 +00:00
INCLUDE(CheckCCompilerFlag)
function(enable_c_compiler_flag_if_supported flag)
string(FIND "${CMAKE_C_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
check_c_compiler_flag("${flag}" flag_supported)
if(flag_supported)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
endif()
unset(flag_supported CACHE)
endif()
endfunction()