forked from llr-cta/calin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (130 loc) · 5.3 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
# calin/CMakeLists.txt -- Stephen Fegan
#
# Copyright 2015, Stephen Fegan <[email protected]>
# Laboratoire Leprince-Ringuet, CNRS/IN2P3, Ecole Polytechnique, Institut Polytechnique de Paris
#
# This file is part of "calin"
#
# "calin" is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 or later, as published by
# the Free Software Foundation.
#
# "calin" 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.
cmake_minimum_required(VERSION 3.15)
project(calin)
enable_testing()
# ============================================================= #
# Find the various libraries and packages that calin depends on #
# ============================================================= #
## Use CMake policy to specify complete library path
cmake_policy(SET CMP0060 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/CMakeModules/")
include_directories(include ${CMAKE_BINARY_DIR}/include)
if(NOT CALIN_BUILD_ARCH)
set(CALIN_BUILD_ARCH "native")
endif()
message(STATUS "Tuning build for architecture: " ${CALIN_BUILD_ARCH})
if(${CALIN_BUILD_ARCH} STREQUAL "generic")
set(CALIN_BUILD_ARCH_OPT "-mtune=${CALIN_BUILD_ARCH}")
else()
set(CALIN_BUILD_ARCH_OPT "-march=${CALIN_BUILD_ARCH}")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CALIN_BUILD_ARCH_OPT} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CALIN_BUILD_ARCH_OPT} -std=c++17 -Wall")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3")
if(NOT CALIN_PYTHON_SUB_DIR)
set(CALIN_PYTHON_SUB_DIR "python")
endif()
if(NOT CALIN_SHARE_SUB_DIR)
set(CALIN_SHARE_SUB_DIR "share")
endif()
if(NOT CALIN_INCLUDE_SUB_DIR)
set(CALIN_INCLUDE_SUB_DIR "include")
endif()
if(NOT CALIN_LIB_SUB_DIR)
set(CALIN_LIB_SUB_DIR "lib")
endif()
if(NOT CALIN_BIN_SUB_DIR)
set(CALIN_BIN_SUB_DIR "bin")
endif()
set(CALIN_PROTO_INSTALL_DIR ${CALIN_SHARE_SUB_DIR}/calin/proto)
set(CALIN_PROTO_HEADER_INSTALL_DIR ${CALIN_INCLUDE_SUB_DIR}/calin/proto)
set(CALIN_DATA_INSTALL_DIR ${CALIN_SHARE_SUB_DIR}/calin/data)
set(CALIN_EXAMPLES_INSTALL_DIR ${CALIN_SHARE_SUB_DIR}/calin/examples)
set(CALIN_LIB_INSTALL_DIR ${CALIN_LIB_SUB_DIR})
set(CALIN_BIN_INSTALL_DIR ${CALIN_BIN_SUB_DIR})
set(CALIN_HEADER_INSTALL_DIR ${CALIN_INCLUDE_SUB_DIR}/calin)
set(CALIN_PYTHON_INSTALL_DIR ${CALIN_PYTHON_SUB_DIR}/calin)
set(CALIN_UNIT_TEST_INSTALL_DIR ${CALIN_SHARE_SUB_DIR}/calin/unit_tests)
## Find Protobuf libraries and set protobuf base path
set(PROTOBUF_IMPORT_DIRS ${PROJECT_SOURCE_DIR}/proto)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/proto)
set(EXTRA_LIBS ${EXTRA_LIBS} ${PROTOBUF_LIBRARY})
## Find FFTW libraries
find_package(FFTW REQUIRED)
include_directories(${FFTW_INCLUDE_DIRS})
set(EXTRA_LIBS ${EXTRA_LIBS} ${FFTW_LIBRARIES} )
## Find GSL libraries
find_package(GSL REQUIRED)
include_directories(${GSL_INCLUDE_DIRS})
set(EXTRA_LIBS ${EXTRA_LIBS} ${GSL_LIBRARIES} )
## Find Sqlite3 libraries
find_package(SQLite3 REQUIRED)
include_directories(${SQLITE3_INCLUDE_DIR})
set(EXTRA_LIBS ${EXTRA_LIBS} ${SQLITE3_LIBRARY} )
## Find Python interpreter and libraries
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
include_directories(${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
message(STATUS "Python3_LIBRARIES:" ${Python3_LIBRARIES})
## Find SWIG and set SWIG include paths to "swig", "include" and "proto"
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_FLAGS -I${CMAKE_SOURCE_DIR}/swig -I${CMAKE_BINARY_DIR}/swig -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_BINARY_DIR}/include -I${CMAKE_BINARY_DIR}/proto)
## Find ZeroMQ
find_package(ZMQ REQUIRED)
include_directories(${ZMQ_INCLUDE_DIRS})
## Find Xerces-C
find_package(XercesC)
set(CALIN_HAVE_XERCESC FALSE)
if(XercesC_FOUND)
include_directories(${XercesC_INCLUDE_DIRS})
set(EXTRA_LIBS ${EXTRA_LIBS} ${XercesC_LIBRARIES} )
set(CALIN_HAVE_XERCESC TRUE)
endif()
## Find the CTA ADH_APIS package
find_package(CTA_ADH_APIS)
## Find Geant4 if requested
SET(CALIN_HAVE_GEANT4 FALSE)
if(NO_GEANT4)
message(STATUS "Skipping GEANT4 as requested")
set(GEANT4_FOUND FALSE)
else()
find_package(Geant4)
if(GEANT4_FOUND)
message(STATUS "GEANT4_INCLUDE_DIR: " ${GEANT4_INCLUDE_DIR})
message(STATUS "GEANT4_LIBRARY_DIR: " ${GEANT4_LIBRARY_DIR})
include_directories(${GEANT4_INCLUDE_DIR})
link_directories(${GEANT4_LIBRARY_DIR})
set(CALIN_HAVE_GEANT4 TRUE)
endif()
endif()
# ========================================== #
# Add the subdirectories to the build system #
# ========================================== #
add_subdirectory(include)
add_subdirectory(scripts)
add_subdirectory(tools)
add_subdirectory(proto)
add_subdirectory(src)
add_subdirectory(swig)
add_subdirectory(unit_tests)
install(DIRECTORY include/ DESTINATION ${CALIN_HEADER_INSTALL_DIR})
install(DIRECTORY data/ DESTINATION ${CALIN_DATA_INSTALL_DIR})
install(DIRECTORY examples/ DESTINATION ${CALIN_EXAMPLES_INSTALL_DIR})
install(DIRECTORY python/ DESTINATION ${CALIN_PYTHON_INSTALL_DIR})