Alexandre Lision | ddd731e | 2014-01-31 11:50:08 -0500 | [diff] [blame] | 1 | # Copyright (C) 2009 David Sugar, Tycho Softworks |
| 2 | # |
| 3 | # This file is free software; as a special exception the author gives |
| 4 | # unlimited permission to copy and/or distribute it, with or without |
| 5 | # modifications, as long as this notice is preserved. |
| 6 | # |
| 7 | # This program is distributed in the hope that it will be useful, but |
| 8 | # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the |
| 9 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 | |
| 11 | if (NOT UCOMMON_LIBS AND NOT UCOMMON_FLAGS) |
| 12 | include(CheckCCompilerFlag) |
| 13 | |
| 14 | if(CMAKE_COMPILER_IS_GNUCXX) |
| 15 | set(UCOMMON_VISIBILITY_FLAG "-fvisibility=hidden") |
| 16 | if(MINGW OR MSYS OR CMAKE_SYSTEM MATCHES "Windows") |
| 17 | set(CHECK_FLAGS -Wno-long-long -mthreads -fvisibility-inlines-hidden) |
| 18 | else() |
| 19 | if(CMAKE_SYSTEM MATCHES "SunOS.*") |
| 20 | set(CHECK_FLAGS -Wno-long-long -mt -fvisibility-inlines-hidden) |
| 21 | else() |
| 22 | set(CHECK_FLAGS -Wno-long-long -pthread -mt -fvisibility-inlines-hidden) |
| 23 | endif() |
| 24 | endif() |
| 25 | endif() |
| 26 | |
| 27 | if(BUILD_RUNTIME AND WIN32) |
| 28 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_RUNTIME) |
| 29 | else() |
| 30 | if(BUILD_STATIC) |
| 31 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_STATIC) |
| 32 | endif() |
| 33 | endif() |
| 34 | |
| 35 | # see if we are building with or without std c++ libraries... |
| 36 | if (BUILD_STDLIB) |
| 37 | # for now we assume only newer libstdc++ library |
| 38 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DNEW_STDCPP) |
| 39 | MESSAGE( STATUS "Configuring full ANSI C++ runtime") |
| 40 | elseif (BUILD_OLDLIB) |
| 41 | # for really old libstdc++ libraries... |
| 42 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DOLD_STDCPP) |
| 43 | MESSAGE( STATUS "Configuring compatible C++ runtime") |
| 44 | else() |
| 45 | MESSAGE( STATUS "Configuring minimal C++ runtime") |
| 46 | if(CMAKE_COMPILER_IS_GNUCXX) |
| 47 | set(CHECK_FLAGS ${CHECK_FLAGS} -fno-exceptions -fno-rtti -fno-enforce-eh-specs) |
| 48 | if(MINGW OR MSYS OR CMAKE_SYSTEM MATCHES "Windows") |
| 49 | set(UCOMMON_LINKING -nodefaultlibs -nostdinc++) |
| 50 | else() |
| 51 | set(UCOMMON_LINKING -nodefaultlibs -nostdinc++) |
| 52 | endif() |
| 53 | endif() |
| 54 | endif() |
| 55 | |
| 56 | # check final for compiler flags |
| 57 | foreach(flag ${CHECK_FLAGS}) |
| 58 | check_c_compiler_flag(${flag} CHECK_${flag}) |
| 59 | if(CHECK_${flag}) |
| 60 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} ${flag}) |
| 61 | endif() |
| 62 | endforeach() |
| 63 | |
| 64 | # visibility support for linking reduction (gcc >4.1 only so far...) |
| 65 | |
| 66 | if(UCOMMON_VISIBILITY_FLAG) |
| 67 | check_c_compiler_flag(${UCOMMON_VISIBILITY_FLAG} CHECK_VISIBILITY) |
| 68 | endif() |
| 69 | |
| 70 | if(CHECK_VISIBILITY) |
| 71 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} ${UCOMMON_VISIBILITY_FLAG} -DUCOMMON_VISIBILITY=1) |
| 72 | else() |
| 73 | set(UCOMMON_FLAGS ${UCOMMON_FLAGS} -DUCOMMON_VISIBILITY=0) |
| 74 | endif() |
| 75 | |
| 76 | endif() |