PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 8ms 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
 8macro(MACRO_CHECK_GCC_VISIBILITY GccVisibility)
 9  if (CMAKE_COMPILER_IS_GNUCXX)
10   include(CheckCXXCompilerFlag)
11   include(MacroEnsureVersion)
12   # visibility support
13   check_cxx_compiler_flag(-fvisibility=hidden ${GccVisibility})
14
15   # get the gcc version
16   exec_program(${CMAKE_C_COMPILER} ARGS ${CMAKE_C_COMPILER_ARG1} --version OUTPUT_VARIABLE _gcc_version_info)
17
18   string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
19   # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the patch level, handle this here:
20   if (NOT _gcc_version)
21      string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}")
22   endif (NOT _gcc_version)
23
24   macro_ensure_version("4.1.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_1)
25   macro_ensure_version("4.2.0" "${_gcc_version}" GCC_IS_NEWER_THAN_4_2)
26
27   set(_GCC_COMPILED_WITH_BAD_ALLOCATOR FALSE)
28   if (GCC_IS_NEWER_THAN_4_1)
29      exec_program(${CMAKE_C_COMPILER} ARGS -v OUTPUT_VARIABLE _gcc_alloc_info)
30      string(REGEX MATCH "(--enable-libstdcxx-allocator=mt)" _GCC_COMPILED_WITH_BAD_ALLOCATOR "${_gcc_alloc_info}")
31   endif (GCC_IS_NEWER_THAN_4_1)
32
33   if (${GccVisibility} AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
34      set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
35      set (KDE4_C_FLAGS "${KDE4_C_FLAGS}" "-fvisibility=hidden")
36
37      if (GCC_IS_NEWER_THAN_4_2)
38          set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
39      endif (GCC_IS_NEWER_THAN_4_2)
40   else (${GccVisibility} AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
41      set (${GccVisibility} 0)
42   endif (${GccVisibility} AND GCC_IS_NEWER_THAN_4_1 AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR AND NOT WIN32)
43
44  else (CMAKE_COMPILER_IS_GNUCXX)
45    set(${GccVisibility} FALSE)
46  endif (CMAKE_COMPILER_IS_GNUCXX)
47endmacro(MACRO_CHECK_GCC_VISIBILITY)