If you need to test linker flags, try out this code snippet, and make sure to unset the variable or subsequent tests will fail!
include(CheckCCompilerFlag)
set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack")
check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag
if(HAVE_NOEXECSTACK)
list(APPEND pascal_flags "-k-z" "-knoexecstack")
if(NOT ${MINIMAL_FLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
endif()
unset(CMAKE_REQUIRED_FLAGS)
No comments:
Post a Comment