forked from mosra/corrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
193 lines (170 loc) · 7.05 KB
/
CMakeLists.txt
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#
# This file is part of Corrade.
#
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
# Vladimír Vondruš <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
cmake_minimum_required(VERSION 2.8.12)
project(Corrade)
# CMake policies: enable MACOSX_RPATH by default
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
# Don't treat imported targets with :: as files
if(POLICY CMP0028)
cmake_policy(SET CMP0028 NEW)
endif()
include(CMakeDependentOption)
option(GCC47_COMPATIBILITY "Enable compatibility mode for GCC 4.7 (might disable some features)" OFF)
option(MSVC2015_COMPATIBILITY "Enable compatibility mode for MSVC 2015 (might disable some features)" OFF)
option(WITH_INTERCONNECT "Build Interconnect library" ON)
option(WITH_PLUGINMANAGER "Build PluginManager library" ON)
option(WITH_TESTSUITE "Build TestSuite library" ON)
cmake_dependent_option(WITH_UTILITY "Build Utility library" ON "NOT WITH_INTERCONNECT;NOT WITH_PLUGINMANAGER;NOT WITH_TESTSUITE" ON)
option(BUILD_DEPRECATED "Include deprecated API in the build" ON)
if(BUILD_DEPRECATED)
set(CORRADE_BUILD_DEPRECATED 1)
endif()
option(BUILD_STATIC "Build static libraries (default are shared)" OFF)
cmake_dependent_option(BUILD_STATIC_PIC "Build static libraries with position-independent code" ON "BUILD_STATIC" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
if(BUILD_TESTS)
if(CORRADE_TARGET_IOS)
set(CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX "cz.mosra.corrade")
endif()
enable_testing()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL NaCl)
set(CORRADE_TARGET_NACL 1)
# Newlib toolchain supports only static linking
if(NACL_TOOLCHAIN STREQUAL newlib)
set(CORRADE_TARGET_NACL_NEWLIB 1)
set(BUILD_STATIC ON)
else()
set(CORRADE_TARGET_NACL_GLIBC 1)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(CORRADE_TARGET_EMSCRIPTEN 1)
# It's meaningless to use dynamic libraries with Emscripten
set(BUILD_STATIC ON)
elseif(UNIX)
# Both APPLE and UNIX are defined on OSX
if(APPLE)
set(CORRADE_TARGET_APPLE 1)
if(CMAKE_OSX_SYSROOT MATCHES "/(iPhoneOS|iPhoneSimulator)[0-9.]*\\.sdk")
set(CORRADE_TARGET_IOS 1)
endif()
endif()
# UNIX is also defined on Android
if(CMAKE_SYSTEM_NAME STREQUAL Android)
set(CORRADE_TARGET_ANDROID 1)
# It's too inconvenient to manually load all shared libs using JNI
set(BUILD_STATIC ON)
endif()
# NaCl and Emscripten are Unix too, this selects only the other ones
set(CORRADE_TARGET_UNIX 1)
elseif(WIN32)
set(CORRADE_TARGET_WINDOWS 1)
if(WINDOWS_PHONE OR WINDOWS_STORE)
set(CORRADE_TARGET_WINDOWS_RT 1)
endif()
endif()
# Platform-specific options
if(CORRADE_TARGET_WINDOWS)
if(CORRADE_TARGET_WINDOWS_RT)
set(UTILITY_USE_ANSI_COLORS 1)
else()
option(UTILITY_USE_ANSI_COLORS "Use ANSI escape sequences for colored Debug output on Windows" OFF)
endif()
if(UTILITY_USE_ANSI_COLORS)
set(CORRADE_UTILITY_USE_ANSI_COLORS 1)
endif()
endif()
if(CORRADE_TARGET_APPLE)
option(TESTSUITE_TARGET_XCTEST "Build TestSuite tests compatible with Xcode XCTest" OFF)
if(TESTSUITE_TARGET_XCTEST)
set(CORRADE_TESTSUITE_TARGET_XCTEST 1)
endif()
endif()
if(BUILD_STATIC)
set(CORRADE_BUILD_STATIC 1)
endif()
# Initialize macros etc.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})
if(CMAKE_CROSSCOMPILING)
find_program(CORRADE_RC_EXECUTABLE corrade-rc)
if(NOT CORRADE_RC_EXECUTABLE)
message(FATAL_ERROR "Native `corrade-rc` executable, which is needed when crosscompiling, was not found")
endif()
add_executable(Corrade::rc IMPORTED)
set_property(TARGET Corrade::rc PROPERTY IMPORTED_LOCATION ${CORRADE_RC_EXECUTABLE})
endif()
if(CORRADE_TESTSUITE_TARGET_XCTEST)
set(CORRADE_TESTSUITE_XCTEST_RUNNER ${PROJECT_SOURCE_DIR}/src/Corrade/TestSuite/XCTestRunner.mm.in)
endif()
if(CORRADE_TARGET_ANDROID)
set(CORRADE_TESTSUITE_ADB_RUNNER ${PROJECT_SOURCE_DIR}/src/Corrade/TestSuite/AdbRunner.sh)
endif()
# Detect and auto-enable compiler compatibility
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7.0")
message(FATAL_ERROR "Compatibility branch of Corrade is needed for use with GCC < 4.7. See the documentation for more information.")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1")
if(NOT GCC47_COMPATIBILITY)
set(GCC47_COMPATIBILITY ON)
message(WARNING "GCC < 4.8.1 detected, automatically enabling GCC47_COMPATIBILITY. Note that some features may not be available with this compiler.")
endif()
endif()
elseif(MSVC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0")
message(FATAL_ERROR "Compatibility branch of Corrade is needed for use with MSVC < 2015. See the documentation for more information.")
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "20.0")
if(NOT MSVC2015_COMPATIBILITY)
set(MSVC2015_COMPATIBILITY ON)
message(WARNING "MSVC 2015 detected, automatically enabling MSVC2015_COMPATIBILITY. Note that some features may not be available with this compiler.")
endif()
endif()
endif()
if(GCC47_COMPATIBILITY)
set(CORRADE_GCC47_COMPATIBILITY 1)
endif()
if(MSVC2015_COMPATIBILITY)
set(CORRADE_MSVC2015_COMPATIBILITY 1)
endif()
if(TESTSUITE_TARGET_XCTEST)
set(CORRADE_TESTSUITE_TARGET_XCTEST 1)
endif()
include(UseCorrade)
if(CORRADE_TARGET_EMSCRIPTEN)
include(UseEmscripten)
endif()
# Installation paths
include(CorradeLibSuffix)
set(CORRADE_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(CORRADE_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(CORRADE_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/corrade)
set(CORRADE_CMAKE_MODULE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/cmake/Corrade)
set(CORRADE_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Corrade)
# Library version
set(CORRADE_LIBRARY_VERSION 0.2)
set(CORRADE_LIBRARY_SOVERSION 0)
add_subdirectory(modules)
add_subdirectory(src)