26 lines
896 B
CMake
26 lines
896 B
CMake
macro(check_link_flag variable flag)
|
|
message (STATUS "checking linker flag ${flag}")
|
|
|
|
set (__check_linker_flag_old "${CMAKE_EXE_LINKER_FLAGS}" INTERNAL)
|
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
|
|
|
|
try_compile (test_check_linker_flag
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp"
|
|
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_link_flag.cpp")
|
|
if (test_check_linker_flag)
|
|
message (STATUS "checking linker flag ${flag} - found")
|
|
set (${variable} 1)
|
|
else(test_check_linker_flag)
|
|
message (STATUS "checking linker flag ${flag} - not found")
|
|
set (${variable} 0)
|
|
endif(test_check_linker_flag)
|
|
endmacro()
|
|
|
|
|
|
macro(append_link_flag flag)
|
|
check_link_flag (__test_link_flag_${flag} ${flag})
|
|
if (__test_link_flag_${flag})
|
|
set (CMAKE_EXE_LINKER_FLAGS "${__append_link_flag_old}")
|
|
endif()
|
|
endmacro()
|