forked from metashell/metashell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
261 lines (221 loc) · 7.82 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# Metashell - Interactive C++ template metaprogramming shell
# Copyright (C) 2013, Abel Sinkovics ([email protected])
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.6)
project(metashell)
set(CMAKE_PROJECT_NAME metashell)
set(MAJOR_VERSION 3)
set(MINOR_VERSION 0)
set(PATCH_VERSION 0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Version macros
add_definitions(-DMETASHELL_MAJOR=${MAJOR_VERSION})
add_definitions(-DMETASHELL_MINOR=${MINOR_VERSION})
add_definitions(-DMETASHELL_PATCH=${PATCH_VERSION})
include(Platform)
# Windows workaround
if (WIN32)
add_definitions( -DNOMINMAX )
endif()
# Warnings, C++11, etc
include(Compiler)
# Workaround on some systems (OSX + clang + Boost 1.55)
add_definitions(-DBOOST_ATOMIC_FORCE_FALLBACK=1)
# Sanitizers
if (ENABLE_SANITIZERS)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "Enabling GCC's address sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Enabling Clang's address sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
endif()
# Code coverage
if (ENABLE_CODE_COVERAGE)
include(CodeCoverage)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} --coverage")
endif()
endif()
# Profiling
if (ENABLE_PROFILING)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
endif()
endif()
# The "internal" Templight build
set(TEMPLIGHT_BUILD "${CMAKE_SOURCE_DIR}/3rd/templight/build")
set(
TEMPLIGHT_INCLUDEDIR
"${TEMPLIGHT_INCLUDEDIR};${CMAKE_SOURCE_DIR}/3rd/templight/llvm/tools/clang/include"
)
set(
TEMPLIGHT_BINARYDIR
"${TEMPLIGHT_BINARYDIR};${TEMPLIGHT_BUILD}/Release+Asserts/bin"
)
set(
TEMPLIGHT_BINARYDIR
"${TEMPLIGHT_BINARYDIR};${TEMPLIGHT_BUILD}/Release/bin"
)
set(
TEMPLIGHT_BINARYDIR
"${TEMPLIGHT_BINARYDIR};${TEMPLIGHT_BUILD}/bin"
)
# Templight
find_package(Templight)
if (NOT DEFINED TEMPLIGHT_HEADER_INSTALL_PATH)
set(TEMPLIGHT_HEADER_INSTALL_PATH "include/metashell/templight")
endif ()
if (NOT DEFINED LIBCXX_HEADER_INSTALL_PATH)
set(LIBCXX_HEADER_INSTALL_PATH "include/metashell/libcxx")
endif ()
# Boost
if (WIN32)
add_definitions(-DBOOST_ALL_NO_LIB=1)
else ()
set(BOOST_ATOMIC_LIB boost_atomic)
if (OPEN_BSD)
add_definitions(-DBOOST_HAS_STDINT_H)
elseif(NOT APPLE)
find_package(Rt)
endif()
endif ()
# Pthreads
if (NOT WIN32)
find_package(Threads)
endif()
# Readline
if (NOT WIN32)
if (USE_EDITLINE)
find_package(Editline)
else()
find_package(Readline)
endif()
endif()
include_directories("include")
include_directories(SYSTEM "3rd/boost/include")
include_directories(SYSTEM "3rd/rapidjson/include")
include_directories(SYSTEM "3rd/protobuf/include")
include_directories(SYSTEM "3rd/termcap/include")
# Unit testing
enable_testing()
# Recursing
subdirs(lib app test 3rd)
# Debian package
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (APPLE)
# This argument is needed, so the generated archive will not have
# /usr/local prefix for all files
set(CMAKE_INSTALL_PREFIX ".")
else()
set(CMAKE_INSTALL_PREFIX "/usr")
endif()
endif()
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
include(InstallRequiredSystemLibraries)
if(WIN32)
set(
CPACK_NSIS_MENU_LINKS
"bin/metashell.exe" "Metashell"
"http://metashell.org" "Metashell website"
"http://metashell.org/about/demo" "Metashell online demo"
)
endif()
if (DEFINED PLATFORM_CPACK_GENERATOR)
set(CPACK_GENERATOR "${PLATFORM_CPACK_GENERATOR}")
endif ()
if (PLATFORM_NAME AND NOT WIN32)
set(METASHELL_PACKAGE_PLATFORM "_${PLATFORM_NAME}${PLATFORM_VERSION}")
else()
set(METASHELL_PACKAGE_PLATFORM "")
endif()
set(CPACK_PACKAGE_DESCRIPTION "Metashell")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "It is an interactive C++ template metaprogramming shell")
set(CPACK_PACKAGE_VENDOR "Abel Sinkovics")
set(CPACK_PACKAGE_CONTACT "Abel Sinkovics <[email protected]>")
set(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}${METASHELL_PACKAGE_PLATFORM}_${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}")
seT(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
if (SUSE_LINUX)
set(CPACK_RPM_PACKAGE_REQUIRES "libstdc++-devel, glibc-devel")
elseif (FEDORA_LINUX)
set(
CPACK_RPM_PACKAGE_REQUIRES
"libstdc++-devel, glibc-headers, glibc-devel"
)
elseif (UBUNTU_LINUX)
if ("${PLATFORM_VERSION}" STREQUAL "14.04")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++-4.8-dev")
elseif (
("${PLATFORM_VERSION}" STREQUAL "14.10")
OR ("${PLATFORM_VERSION}" STREQUAL "15.04")
)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++-4.9-dev")
elseif ("${PLATFORM_VERSION}" STREQUAL "16.04")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++-5-dev")
else()
message(
WARNING
"Unsupported Ubuntu version. Package dependencies will be invalid."
)
endif()
set(CPACK_SET_DESTDIR "on")
set(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
elseif (DEBIAN_LINUX)
if (
("${PLATFORM_VERSION}" STREQUAL "7.6")
OR ("${PLATFORM_VERSION}" STREQUAL "7.7")
)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6-4.7-dev")
elseif (
("${PLATFORM_VERSION}" STREQUAL "8.1")
OR ("${PLATFORM_VERSION}" STREQUAL "8.5")
)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++-4.9-dev")
else()
message(
WARNING
"Unsupported Debian version. Package dependencies will be invalid."
)
endif()
set(CPACK_SET_DESTDIR "on")
set(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
endif ()
set(CPACK_COMPONENTS_ALL metashell windows_headers templight)
set(CPACK_ALL_INSTALL_TYPES full notemplight minimal)
set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Full")
set(CPACK_INSTALL_TYPE_NOTEMPLIGHT_DISPLAY_NAME "Without Templight")
set(CPACK_INSTALL_TYPE_MINIMAL_DISPLAY_NAME "Minimal")
set(CPACK_COMPONENT_METASHELL_DISPLAY_NAME "Metashell")
set(CPACK_COMPONENT_METASHELL_DESCRIPTION "The Metashell binary")
set(CPACK_COMPONENT_METASHELL_INSTALL_TYPES full notemplight minimal)
set(CPACK_COMPONENT_WINDOWS_HEADERS_DISPLAY_NAME "C++ headers")
set(CPACK_COMPONENT_WINDOWS_HEADERS_DESCRIPTION "The MinGW standard headers")
set(CPACK_COMPONENT_WINDOWS_HEADERS_INSTALL_TYPES full notemplight)
set(CPACK_COMPONENT_TEMPLIGHT_DISPLAY_NAME "Templight")
set(CPACK_COMPONENT_TEMPLIGHT_DESCRIPTION "Templight")
set(CPACK_COMPONENT_TEMPLIGHT_INSTALL_TYPES full)
include(CPack)
endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")