cmake_modules/compilerchecks.cmake
changeset 9221 c4289023ddae
parent 9220 5e7db24f3489
child 9222 a19fa86509c2
equal deleted inserted replaced
9220:5e7db24f3489 9221:c4289023ddae
    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 check_c_compiler_flag("-fstack-protector-all -fstack-protector" HAVE_STACKPROTECTOR)
    15 if(NOT WIN32)
    16 if(HAVE_STACKPROTECTOR AND (NOT WIN32))
    16     check_c_compiler_flag("-fstack-protector-all -fstack-protector" HAVE_STACKPROTECTOR)
       
    17 endif()
       
    18 if(HAVE_STACKPROTECTOR)
    17     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector")
    19     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector")
    18     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    20     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    19     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector")
    21     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector")
    20     set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
    22     set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
    21     set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    23     set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fstack-protector-all -fstack-protector")
    22 endif()
    24 endif()
    23 
    25 
    24 #symbol visibility, not supported on Windows (so we error out to avoid spam)
    26 #symbol visibility, not supported on Windows
    25 check_c_compiler_flag("-fvisibility=hidden -Werror" HAVE_VISIBILITY)
    27 if(NOT WIN32)
       
    28     check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
       
    29 endif()
    26 if(HAVE_VISIBILITY)
    30 if(HAVE_VISIBILITY)
    27     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
    31     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
    28     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
    32     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
    29 endif()
    33 endif()
    30 
    34