cmake_modules/compilerchecks.cmake
changeset 9222 a19fa86509c2
parent 9221 c4289023ddae
child 9223 71fc5893071c
equal deleted inserted replaced
9221:c4289023ddae 9222:a19fa86509c2
    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, when found it needs to go in the linker flags too
    12 #stack protection, when found it needs to go in the linker flags too
    13 #it is disabled on win32 because it adds a dll and messes with linker
    13 #it is disabled on win32 because it adds a dll and messes with linker
    14 #(see 822312 654424 on bugzilla.redhat.com)
    14 #(see 822312 654424 on bugzilla.redhat.com)
    15 if(NOT WIN32)
    15 check_c_compiler_flag("-fstack-protector-all -fstack-protector" HAVE_STACKPROTECTOR)
    16     check_c_compiler_flag("-fstack-protector-all -fstack-protector" HAVE_STACKPROTECTOR)
    16 if(HAVE_STACKPROTECTOR AND (NOT WIN32))
    17 endif()
       
    18 if(HAVE_STACKPROTECTOR)
       
    19     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector")
    17     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector")
    20     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    18     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    21     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector")
    19     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector")
    22     set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
    20     set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
    23     set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    21     set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    24 endif()
    22 endif()
    25 
    23 
    26 #symbol visibility, not supported on Windows
    24 #symbol visibility, not supported on Windows (so we error out to avoid spam)
    27 if(NOT WIN32)
    25 check_c_compiler_flag("-fvisibility=hidden -Werror" HAVE_VISIBILITY)
    28     check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
       
    29 endif()
       
    30 if(HAVE_VISIBILITY)
    26 if(HAVE_VISIBILITY)
    31     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
    27     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
    32     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
    28     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
    33 endif()
    29 endif()
    34 
    30