File: ucommon.cmake

package info (click to toggle)
ucommon 5.2.2-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,156 kB
  • sloc: cpp: 41,584; sh: 11,440; ansic: 511; makefile: 210
file content (76 lines) | stat: -rw-r--r-- 2,798 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright (C) 2009 David Sugar, Tycho Softworks
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

if (NOT UCOMMON_LIBS AND NOT UCOMMON_FLAGS)
    include(CheckCCompilerFlag)

    if(CMAKE_COMPILER_IS_GNUCXX)
        set(UCOMMON_VISIBILITY_FLAG "-fvisibility=hidden")
        if(MINGW OR MSYS)
            set(CHECK_FLAGS -Wno-long-long -mthreads -fvisibility-inlines-hidden)
        else()
            if(CMAKE_SYSTEM MATCHES "SunOS.*")
                set(CHECK_FLAGS -Wno-long-long -mt -fvisibility-inlines-hidden)
            else()
                set(CHECK_FLAGS -Wno-long-long -pthread -mt -fvisibility-inlines-hidden)
            endif()
        endif()
    endif()

    if(BUILD_RUNTIME AND WIN32)
        set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_RUNTIME)
    else()
        if(BUILD_STATIC)
            set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_STATIC)
        endif()
    endif()

    # see if we are building with or without std c++ libraries...
    if (BUILD_STDLIB)
        # for now we assume only newer libstdc++ library
        set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DNEW_STDCPP)
        MESSAGE( STATUS "Configuring full ANSI C++ runtime")
    elseif (BUILD_OLDLIB)
        # for really old libstdc++ libraries...
        set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DOLD_STDCPP)
        MESSAGE( STATUS "Configuring compatible C++ runtime")
    else()
        MESSAGE( STATUS "Configuring minimal C++ runtime")
        if(CMAKE_COMPILER_IS_GNUCXX)
            set(CHECK_FLAGS ${CHECK_FLAGS} -fno-exceptions -fno-rtti -fno-enforce-eh-specs)
            if(MINGW OR MSYS)
                set(UCOMMON_LINKING -nodefaultlibs -nostdinc++)
            else()
                set(UCOMMON_LINKING -nodefaultlibs -nostdinc++)
            endif()
        endif()
    endif()

    # check final for compiler flags
    foreach(flag ${CHECK_FLAGS})
        check_c_compiler_flag(${flag} CHECK_${flag})
        if(CHECK_${flag})
            set(UCOMMON_FLAGS ${UCOMMON_FLAGS} ${flag})
        endif()
    endforeach()

    # visibility support for linking reduction (gcc >4.1 only so far...)

    if(UCOMMON_VISIBILITY_FLAG)
        check_c_compiler_flag(${UCOMMON_VISIBILITY_FLAG} CHECK_VISIBILITY)
    endif()

    if(CHECK_VISIBILITY)
        set(UCOMMON_FLAGS ${UCOMMON_FLAGS} ${UCOMMON_VISIBILITY_FLAG} -DUCOMMON_VISIBILITY=1)
    else()
        set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_VISIBILITY=0)
    endif()

endif()