cmake_modules/compilerchecks.cmake
changeset 9165 7b0d5388abc4
parent 9159 3e9d4bbc4053
child 9167 ecf19179b37e
equal deleted inserted replaced
9163:67334acaaac7 9165:7b0d5388abc4
     3 include(CheckCCompilerFlag)
     3 include(CheckCCompilerFlag)
     4 #when you need to check for a linker flag, just leave the argument of "check_c_compiler_flag" empty
     4 #when you need to check for a linker flag, just leave the argument of "check_c_compiler_flag" empty
     5 
     5 
     6 # CMAKE_C{XX}_FLAGS is for compiler flags (c and c++)
     6 # CMAKE_C{XX}_FLAGS is for compiler flags (c and c++)
     7 # CMAKE_EXE_LINKER_FLAGS is for linker flags (also add them to pascal_flags and haskell_flags)
     7 # CMAKE_EXE_LINKER_FLAGS is for linker flags (also add them to pascal_flags and haskell_flags)
     8 
     8 # CMAKE_SHARED_LIBRARY_<lang>_FLAGS same but for shared libraries
     9 
     9 
    10 #TODO: should there be two different checks for C and CXX?
    10 #TODO: should there be two different checks for C and CXX?
    11 
    11 
    12 #stack protection
    12 #stack protection, when found it needs to go in the linker flags too (-lssp is added)
    13 check_c_compiler_flag("-fstack-protector" HAVE_STACKPROTECTOR)
    13 check_c_compiler_flag("-fstack-protector" HAVE_STACKPROTECTOR)
    14 if(HAVE_STACKPROTECTOR)
    14 if(HAVE_STACKPROTECTOR)
    15     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
    15     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
    16     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
    16     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
       
    17     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector")
       
    18     set(CMAKE_SHARED_LIBRARY_C_FLAGS  "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector")
       
    19     set(CMAKE_SHARED_LIBRARY_CXX_FLAGS  "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector")
    17 endif()
    20 endif()
    18 
    21 
    19 #symbol visibility
    22 #symbol visibility
    20 check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITYH)
    23 check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITYH)
    21 if(HAVE_VISIBILITYH)
    24 if(HAVE_VISIBILITYH)