forked from SeisComP/seiscomp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
195 lines (163 loc) · 6.36 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0 FATAL_ERROR)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0005 NEW)
PROJECT(SeisComP)
# Global options (see below):
# - SC_GLOBAL_PYTHON_WRAPPER
# - SC_GLOBAL_PYTHON_WRAPPER_NUMPY
#SET(CMAKE_DEBUG_POSTFIX _d)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
SET(CMAKEDEFINE "#cmakedefine")
#OPTION(SHARED_LIBRARIES "Build shared libraries" ON)
SET(SHARED_LIBRARIES 1)
ADD_DEFINITIONS(-DSC_ALL_SHARED)
IF (WIN32)
ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
ADD_DEFINITIONS(-DNOMINMAX)
ENDIF (WIN32)
# Find needed packages
FIND_PACKAGE(LibXml2 REQUIRED)
OPTION(SC_GLOBAL_UNITTESTS "Enable unit tests" ON)
OPTION(SC_GLOBAL_PYTHON_WRAPPER "Create Python 3 wrapper" ON)
OPTION(SC_GLOBAL_PYTHON_WRAPPER_NUMPY "Add Numpy support for Python 3 wrapper" ON)
OPTION(SC_ENABLE_CONTRIB "Enables descending into the contrib directory" ON)
# Modern GCC (>= 5.1) on old systems with libraries compiled with ABI version 0.
# see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
OPTION(FORCE_CXX11_ABI_0 "Option description" OFF)
SET(PythonInterp_FIND_VERSION 3)
SET(PythonInterp_FIND_VERSION_MAJOR 3)
SET(PythonInterp_FIND_VERSION_EXACT 0)
FIND_PACKAGE(PythonInterp)
EXEC_PROGRAM(
${PYTHON_EXECUTABLE}
ARGS "-c \"import sys;print(sys.version[:3])\""
OUTPUT_VARIABLE PYTHON_VERSION
)
IF(SC_GLOBAL_PYTHON_WRAPPER_NUMPY)
FIND_PACKAGE(Numpy)
ENDIF()
IF (APPLE)
FIND_PACKAGE(PythonLibsApple REQUIRED)
ELSE (APPLE)
FIND_PACKAGE(PythonLibs REQUIRED)
ENDIF (APPLE)
FIND_PACKAGE(PythonInterp REQUIRED)
SET(PYTHON_LIBRARY_SUFFIX /python)
SET(PYTHON_LIBRARY_PATH lib${PYTHON_LIBRARY_SUFFIX})
OPTION(SC_GLOBAL_GUI "Build graphical user interfaces (requires Qt5)" ON)
OPTION(SC_GLOBAL_GUI_QT5 "Build graphical user interfaces with Qt5" ON)
OPTION(SC_GLOBAL_GUI_QT6 "Build graphical user interfaces with Qt6" OFF)
IF(SC_GLOBAL_GUI)
IF((NOT SC_GLOBAL_GUI_QT5) AND (NOT SC_GLOBAL_GUI_QT6))
MESSAGE(FATAL_ERROR "Either Qt5 or Qt6 must be enabled, other versions are not supported")
ENDIF()
IF((SC_GLOBAL_GUI_QT5) AND (SC_GLOBAL_GUI_QT6))
MESSAGE(FATAL_ERROR "Qt5 and Qt6 are enabled, please decide for one of them")
ENDIF()
IF(SC_GLOBAL_GUI_QT5)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Widgets)
MESSAGE(STATUS "Use Qt5")
ENDIF()
IF(SC_GLOBAL_GUI_QT6)
FIND_PACKAGE(Qt6 REQUIRED COMPONENTS Core Widgets)
MESSAGE(STATUS "Use Qt6")
ENDIF()
ENDIF()
INCLUDE(AddFileDependencies)
INCLUDE(SeisComP)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
SET(CPACK_PACKAGE_VENDOR "seiscomp-devel@gfz-potsdam.de")
SET(CPACK_PACKAGE_VERSION_NAME "Potsdam")
SET(CPACK_PACKAGE_VERSION_MAJOR "4")
SET(CPACK_PACKAGE_VERSION_MINOR "0")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
#SET(CPACK_STRIP_FILES "bin/*")
SET(CPACK_SOURCE_STRIP_FILES "")
#SET(CPACK_PACKAGE_EXECUTABLES "bin/*")
SET(CPACK_PACKAGE_FILE_NAME "seiscomp-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
INCLUDE(CPack)
SET(PROJECT_CONFIG_DIR etc)
SET(PROJECT_SHARE_DIR share)
SET(PROJECT_API_H api.h)
SET(SC3_PACKAGE_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Default directories that can be overridden in the
# subprojects
SET(SC3_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(SC3_PACKAGE_BIN_DIR bin)
SET(SC3_PACKAGE_LIB_DIR lib)
SET(SC3_PACKAGE_INCLUDE_DIR include)
SET(SC3_PACKAGE_SHARE_DIR share)
SET(SC3_PACKAGE_CONFIG_DIR etc)
SET(SC3_PACKAGE_TEMPLATES_DIR templates)
# Platform check
#
IF (APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET (MACOSX 1)
MESSAGE(STATUS "MACOSX detected")
ELSEIF (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET (LINUX 1)
ENDIF (APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# If gcc is installed add -wall and -pedantic to the commandline
#
IF (CMAKE_COMPILER_IS_GNUCC)
IF ( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
ADD_DEFINITIONS(-Wall -pedantic -Wno-long-long -Wno-variadic-macros)
#ADD_DEFINITIONS(-Wall -Wno-long-long -Wno-variadic-macros)
ELSE ( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
ADD_DEFINITIONS(-Wall)
ENDIF ( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
# Query gcc version. We can't use CMAKE_CXX_COMPILER_VERSION which is
# only supported in cmake >= 2.8.10. SLES 11 still comes with cmake 2.6.
EXECUTE_PROCESS(
COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION
)
STRING(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
LIST(LENGTH GCC_VERSION_COMPONENTS GCC_VERSION_COMPONENTS_SIZE)
LIST(GET GCC_VERSION_COMPONENTS 0 GCC_VERSION_MAJOR)
# E.g. Fedora 26 does by default report only the major version number (7)
# The new option "-dumpfullversion" is not available on older compilers
IF(GCC_VERSION_COMPONENTS_SIZE GREATER 1)
LIST(GET GCC_VERSION_COMPONENTS 1 GCC_VERSION_MINOR)
ELSE(GCC_VERSION_COMPONENTS_SIZE GREATER 1)
SET(GCC_VERSION_MINOR 0)
ENDIF(GCC_VERSION_COMPONENTS_SIZE GREATER 1)
MESSAGE(STATUS "Found GCC version ${GCC_VERSION_MAJOR}.${GCC_VERSION_MINOR}")
# Enable C++17 features
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
# Modern GCC (>= 5.1) on old systems with libraries compiled with ABI version 0.
# see https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
IF ( FORCE_CXX11_ABI_0 )
ADD_COMPILE_DEFINITIONS(_GLIBCXX_USE_CXX11_ABI=0)
ENDIF ()
ENDIF (CMAKE_COMPILER_IS_GNUCC)
# Set the platform specific suffix for dynamic libraries
ADD_DEFINITIONS(
-DSHARED_LIBRARY_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"
-DSHARED_MODULE_SUFFIX="${CMAKE_SHARED_MODULE_SUFFIX}"
)
# Helper for Eclipse CDT
#
IF (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF (CMAKE_COMPILER_IS_GNUCXX)
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0.0")
MESSAGE(FATAL_ERROR "Insufficient GCC version. At least version \
7.0.0 is required for C++17 language features.")
ENDIF ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-D_REENTRANT)
IF(SC_GLOBAL_UNITTESTS)
MESSAGE(STATUS "Enable unit tests")
FIND_PACKAGE(Boost REQUIRED COMPONENTS unit_test_framework)
ENABLE_TESTING()
ELSE(SC_GLOBAL_UNITTESTS)
MESSAGE(STATUS "Disable unit tests")
ENDIF(SC_GLOBAL_UNITTESTS)
INSTALL(FILES doc/base/license.rst RENAME LICENSE DESTINATION ${SC3_PACKAGE_SHARE_DIR}/doc/seiscomp)
INSTALL(FILES LICENSE.html DESTINATION ${SC3_PACKAGE_SHARE_DIR}/doc/seiscomp)
SUBDIRS(src doc)