PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/strigi-0.7.7/libstreams/cmake/MacroCheckGccVisibility.cmake

#
CMake | 47 lines | 30 code | 8 blank | 9 comment | 7 complexity | d486c0942a3feb5077f2460ddb59d2e8 MD5 | raw file
Possible License(s): LGPL-2.0
  1. #
  2. # Copyright (c) 2006, Alexander Neundorf <neundorf@kde.org>
  3. # Copyright (c) 2006, Laurent Montel, <montel@kde.org>
  4. #
  5. # Redistribution and use is allowed according to the terms of the BSD license.
  6. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  7. macro(MACRO_CHECK_GCC_VISIBILITY GccVisibility)
  8. if (CMAKE_COMPILER_IS_GNUCXX)
  9. include(CheckCXXCompilerFlag)
  10. include(MacroEnsureVersion)
  11. # visibility support
  12. check_cxx_compiler_flag(-fvisibility=hidden ${GccVisibility})
  13. # get the gcc version
  14. exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} --version OUTPUT_VARIABLE _gcc_version_info)
  15. string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
  16. # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the patch level, handle this here:
  17. if (NOT _gcc_version)
  18. string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}")
  19. endif (NOT _gcc_version)
  20. macro_ensure_version("4.1.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_1)
  21. macro_ensure_version("4.2.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_2)
  22. set(_GCC_COMPILED_WITH_BAD_ALLOCATOR FALSE)
  23. if (GCC_IS_NEWER_THAN_4_1)
  24. exec_program(${CMAKE_C_COMPILER} ARGS -v OUTPUT_VARIABLE _gcc_alloc_info)
  25. string(REGEX MATCH "(--enable-libstdcxx-allocator=mt)" _GCC_COMPILED_WITH_BAD_ALLOCATOR "${_gcc_alloc_info}")
  26. endif (GCC_IS_NEWER_THAN_4_1)
  27. if (${GccVisibility} AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
  28. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
  29. set (KDE4_C_FLAGS "${KDE4_C_FLAGS}" "-fvisibility=hidden")
  30. if (GCC_IS_NEWER_THAN_4_2)
  31. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
  32. endif (GCC_IS_NEWER_THAN_4_2)
  33. else (${GccVisibility} AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
  34. set (${GccVisibility} 0)
  35. endif (${GccVisibility} AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
  36. else (CMAKE_COMPILER_IS_GNUCXX)
  37. set(${GccVisibility} FALSE)
  38. endif (CMAKE_COMPILER_IS_GNUCXX)
  39. endmacro(MACRO_CHECK_GCC_VISIBILITY)