2017-01-25 18:43:46 +11:00
|
|
|
###############################################################################
|
2017-01-18 21:43:30 +11:00
|
|
|
macro(check_link_flag _variable _flag)
|
|
|
|
string (MAKE_C_IDENTIFIER ${_flag} _name)
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-01-18 21:43:30 +11:00
|
|
|
if (NOT DEFINED __check_link_flag_${_name})
|
|
|
|
message (STATUS "checking linker flag ${_flag}")
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-01-23 16:47:03 +11:00
|
|
|
set (__check_linker_flag_old "${CMAKE_EXE_LINKER_FLAGS}")
|
2017-01-18 21:43:30 +11:00
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}")
|
|
|
|
|
|
|
|
try_compile (
|
|
|
|
__check_link_flag_${_name}
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp"
|
|
|
|
SOURCES
|
2019-06-18 11:28:17 +10:00
|
|
|
"${NC_CMAKE_BASE}/test_link_flag.cpp")
|
2017-01-18 21:43:30 +11:00
|
|
|
|
|
|
|
if (__check_link_flag_${_name})
|
|
|
|
message (STATUS "checking linker flag ${_flag} - found")
|
|
|
|
else()
|
|
|
|
message (STATUS "checking linker flag ${_flag} - not found")
|
|
|
|
endif()
|
2017-01-23 16:47:03 +11:00
|
|
|
|
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "${__check_linker_flag_old}")
|
2017-01-18 21:43:30 +11:00
|
|
|
endif ()
|
|
|
|
|
2017-01-25 18:43:46 +11:00
|
|
|
set (${_variable} ${__check_link_flag_${_name}})
|
2017-01-17 19:20:12 +11:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
2017-01-25 18:43:46 +11:00
|
|
|
##-----------------------------------------------------------------------------
|
2017-01-23 16:48:36 +11:00
|
|
|
macro(append_link_flag _flag)
|
|
|
|
check_link_flag (__test_link_flag_${_flag} ${_flag})
|
2017-01-18 21:43:30 +11:00
|
|
|
if (__test_link_flag_${_flag})
|
|
|
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}")
|
2017-01-17 19:20:12 +11:00
|
|
|
endif()
|
|
|
|
endmacro()
|