forked from SeisComP3/seiscomp3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (136 loc) · 5.04 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
PROJECT(SeisComP3)
# Global options (see below):
# - SC_GLOBAL_PYTHON_WRAPPER
# - SC_GLOBAL_PYTHON_WRAPPER_NUMPY
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0005 NEW)
#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}/Modules)
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_PYTHON_WRAPPER "Create Python wrappers" ON)
OPTION(SC_GLOBAL_PYTHON_WRAPPER_NUMPY "Add Numpy support for Python wrapper" OFF)
FIND_PACKAGE(PythonInterp)
EXEC_PROGRAM(
${PYTHON_EXECUTABLE}
ARGS "-c \"from __future__ import print_function;import sys;print(sys.version[:3])\""
OUTPUT_VARIABLE PYTHON_VERSION
)
IF (SC_GLOBAL_PYTHON_WRAPPER)
IF (APPLE)
FIND_PACKAGE(PythonLibsApple REQUIRED)
ELSE (APPLE)
FIND_PACKAGE(PythonLibs REQUIRED)
ENDIF (APPLE)
FIND_PACKAGE(PythonInterp REQUIRED)
ENDIF (SC_GLOBAL_PYTHON_WRAPPER)
SET(PYTHON_LIBRARY_SUFFIX /python)
SET(PYTHON_LIBRARY_PATH lib${PYTHON_LIBRARY_SUFFIX})
IF(SC_GLOBAL_PYTHON_WRAPPER_NUMPY)
FIND_PACKAGE(Numpy)
ENDIF()
OPTION(SC_GLOBAL_GUI "Build graphical user interfaces (requires Qt4 or Qt5)" ON)
OPTION(SC_GLOBAL_GUI_QT5 "Build graphical user interfaces for Qt5" ON)
IF(SC_GLOBAL_GUI)
FIND_PACKAGE(Qt5 QUIET COMPONENTS Core Widgets)
IF(NOT Qt5_FOUND)
SET(SC_GLOBAL_GUI_QT5 OFF)
ENDIF()
IF(NOT SC_GLOBAL_GUI_QT5)
FIND_PACKAGE(Qt4 QUIET)
ENDIF()
ENDIF()
INCLUDE(AddFileDependencies)
INCLUDE(CreateLibrary)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
SET(CPACK_PACKAGE_VENDOR "[email protected]")
SET(CPACK_PACKAGE_VERSION_NAME "Potsdam")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "2")
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 "seiscomp3-${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)
# SET(PROJECT_TEST_DATA_DIR ${CMAKE_SOURCE_DIR}/src/core/test/data)
# 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}")
# gcc 6 defaults to C++14 which might break compilation
IF(GCC_VERSION_MAJOR GREATER 5)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wno-deprecated-declarations")
ENDIF(GCC_VERSION_MAJOR GREATER 5)
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)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-D_REENTRANT)
# Enable ctest
ENABLE_TESTING()
SUBDIRS(src doc)