-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
170 lines (149 loc) · 4.4 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
# Fermitools CMAKE build system
# Author: Alexander Reustle (2022)
cmake_minimum_required(VERSION 3.18)
project(
fermitools
VERSION 2.1.0
LANGUAGES CXX C
DESCRIPTION "Fermi Sciencetools"
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found ccache in ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
## Options. Activate at configure time with `-D<OPTION>=ON`
option(FERMI_BUILD_ROOT "Build the CERN ROOT components. Requires ROOT!" OFF)
option(CMAKE_CXX_COMPILER "Specify Compiler" clang)
## CMake tool support packages. These provide additional funcitons to our Cmake files.
include(CMakeDependentOption)
include(CheckCXXCompilerFlag)
include(GNUInstallDirs)
include(CTest)
## The local cmake modules path.
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
## Externals: The dependent packages on which the Sciencetools relies. ##
find_package(cfitsio 4.0.0 REQUIRED)
find_package(CLHEP REQUIRED)
find_package(CppUnit REQUIRED)
find_package(f2c REQUIRED)
find_package(FFTW REQUIRED)
find_package(GSL REQUIRED)
find_package(healpix_cxx REQUIRED)
find_package(OpenMP REQUIRED COMPONENTS CXX)
find_package(SWIG 3.0.1 REQUIRED COMPONENTS python)
set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
# Python3 External development headers and numpy headers.
set(Python3_FIND_VIRTUALENV FIRST)
find_package(Python3 3.7 REQUIRED COMPONENTS NumPy Development Interpreter)
find_package(WCSlib REQUIRED)
find_package(XercesC REQUIRED)
## Make the targets visible in other CMake files.
set_target_properties(
cfitsio::cfitsio
CLHEP::CLHEP
CppUnit::CppUnit
f2c::f2c
FFTW::fftw3
GSL::gsl
healpix_cxx::healpix_cxx
Python3::Python
Python3::NumPy
WCSlib::WCSlib
XercesC::XercesC
PROPERTIES IMPORTED_GLOBAL TRUE
)
## Handle root.
if(FERMI_BUILD_ROOT)
find_package(ROOT REQUIRED)
set_target_properties(
ROOT::Core
PROPERTIES IMPORTED_GLOBAL TRUE
)
endif()
if(NOT APPLE)
add_compile_definitions(TRAP_FPE)
endif()
###############################################################################
# Specify Installation destinations
###############################################################################
include(GNUInstallDirs)
set(CONFIG_INSTALLDIR lib/cmake/${PROJECT_NAME})
set(
PYTHON_SITE_PKGDIR
lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages
)
set(FERMI_INSTALL_PYTHON ${PYTHON_SITE_PKGDIR}/${PROJECT_NAME})
set(FERMI_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
set(FERMI_INSTALL_DATADIR share/${PROJECT_NAME}/data)
set(FERMI_INSTALL_REFDATADIR share/${PROJECT_NAME}/refdata/fermi)
set(FERMI_INSTALL_HELPDIR share/${PROJECT_NAME}/help)
set(FERMI_INSTALL_PFILESDIR share/${PROJECT_NAME}/syspfiles)
set(FERMI_INSTALL_XMLDIR share/${PROJECT_NAME}/xml/fermi)
##################################################
## Targets
## The full colleciton of Sciencetools packages.
list(
APPEND FERMI_COMPONENTS
ape
astro
BayesianBlocks
burstFit
catalogAccess
celestialSources
dataSubselector
embed_python
evtbin
facilities
fermitools-fhelp
fitsGen
flux
healpix
hoops
irfs
Likelihood
map_tools
Minuit2
modelEditor
observationSim
optimizers
orbitSim
pulsarDb
pulsePhase
pyBurstAnalysisGUI
pyExposure
pyLikelihood
rspgen
sane
skymaps
sourceIdentify
SolarSystemTools
st_facilities
st_stream
st_graph
st_app
tip
timeSystem
xmlBase
)
list(JOIN FERMI_COMPONENTS " " FERMI_COMPONENTS_SPACES)
#### Configuration ####
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in config.h)
include_directories(${CMAKE_BINARY_PATH})
#######################
foreach(pkg ${FERMI_COMPONENTS})
add_subdirectory(src/${pkg} ${CMAKE_BINARY_DIR}/${pkg})
endforeach()
####### Install #######
# Add the init.py file to the installed target python site-packages dir.
install(CODE "file(TOUCH ${CMAKE_BINARY_DIR}/__init__.py)")
install(FILES "${CMAKE_BINARY_DIR}/__init__.py" DESTINATION ${FERMI_INSTALL_PYTHON})
# Add the fermitools.pth file to lib
install(CODE "file(WRITE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pth ${PROJECT_NAME}\\n)")
install(CODE "file(APPEND ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pth ../../../lib/\\n)")
install(CODE "file(APPEND ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pth ../../../lib/${PROJECT_NAME}\\n)")
install(
FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pth"
DESTINATION ${PYTHON_SITE_PKGDIR}
)