-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
230 lines (175 loc) · 7 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
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(lumilar)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/system)
find_package(Geant4 REQUIRED)
find_package(ROOT REQUIRED COMPONENTS RIO Core)
find_package(CLHEP REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
include(${Geant4_USE_FILE})
include(${ROOT_USE_FILE})
#include(${CLHEP_USE_FILE})
message(STATUS "Geant4 GDML SUPPORT: ${Geant4_gdml_FOUND}")
#----------------------------------------------------------------------------
# Setup Projects PATHS
set(MAIN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
set(MAIN_SOURCE_DIR "${PROJECT_SOURCE_DIR}/source")
set(MAIN_BUILD_DIR "${PROJECT_SOURCE_DIR}/build")
if (NOT MAIN_EXTERNAL_DIR)
set(MAIN_EXTERNAL_DIR "${PROJECT_SOURCE_DIR}/extern" )
endif()
#----------------------------------------------------------------------------
# Check if BxDecay0 is already installed
set(BXDECAY0_DIR "${MAIN_EXTERNAL_DIR}/bxdecay0")
set(BXDECAY0_INSTALLED FALSE)
file(GLOB BXDECAY0_FILES "${BXDECAY0_DIR}/*")
if (BXDECAY0_FILES)
message(STATUS "BxDecay0 is already installed at ${BXDECAY0_DIR}")
set(BXDECAY0_INSTALLED TRUE)
endif()
#----------------------------------------------------------------------------
# Clone and build BxDecay0 if not already installed
if (NOT BXDECAY0_INSTALLED)
message(STATUS "Cloning and building BxDecay0...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E env git clone https://github.com/BxCppDev/bxdecay0.git ${BXDECAY0_DIR}
WORKING_DIRECTORY ${MAIN_EXTERNAL_DIR}
)
execute_process(
COMMAND ./tools/build.sh --without-dbd-gA-data --with-geant4-extension --geant4-prefix "${Geant4_DIR}"
WORKING_DIRECTORY ${BXDECAY0_DIR}
)
endif()
if(NOT BXDECAY0_DIR)
set(BXDECAY0_DIR "${MAIN_EXTERNAL_DIR}/bxdecay0")
endif()
find_package(BxDecay0 REQUIRED COMPONENTS Geant4 CONFIG PATHS "${BXDECAY0_DIR}/_build.d" NO_DEFAULT_PATH)
include_directories(${BXDECAY0_DIR}/_install.d/include)
#----------------------------------------------------------------------------
# Check if Marley is already installed
set(MARLEY_DIR "${MAIN_EXTERNAL_DIR}/marley")
set(MARLEY_INSTALLED FALSE)
file(GLOB MARLEY_FILES "${MARLEY_DIR}/*")
if (MARLEY_FILES)
message(STATUS "Marley is already installed at ${MARLEY_DIR}")
set(MARLEY_INSTALLED TRUE)
endif()
#----------------------------------------------------------------------------
# Clone and build Marley if not already installed
if (NOT MARLEY_INSTALLED)
message(STATUS "Cloning and building Marley...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E env git clone https://github.com/njlane314/marley.git ${MARLEY_DIR}
WORKING_DIRECTORY ${MAIN_EXTERNAL_DIR}
)
execute_process(
COMMAND make
WORKING_DIRECTORY ${MAIN_EXTERNAL_DIR}/marley/build
)
endif()
#----------------------------------------------------------------------------
# Check if Eigen is already installed
set(EIGEN_DIR "${MAIN_EXTERNAL_DIR}/eigen/Eigen/")
set(EIGEN_INSTALLED FALSE)
file(GLOB EIGEN_FILES "${EIGEN_DIR}/*")
if (EIGEN_FILES)
message(STATUS "Eigen is already installed at ${EIGEN_DIR}")
set(EIGEN_INSTALLED TRUE)
endif()
#----------------------------------------------------------------------------
# Clone and build Eigen if not already installed
if (NOT EIGEN_INSTALLED)
message(STATUS "Cloning and building Eigen...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E env git clone https://github.com/libigl/eigen.git ${EIGEN_DIR}
WORKING_DIRECTORY ${MAIN_EXTERNAL_DIR}
)
endif()
include_directories(${EIGEN_DIR})
#----------------------------------------------------------------------------
# check if LArNEST is already installed
set(LArNEST_DIR "${MAIN_EXTERNAL_DIR}/larnest")
set(LArNEST_BUILD_DIR "${LArNEST_DIR}/build")
set(LArNEST_INSTALLED FALSE)
Set(LArNEST_INCLUDE_DIR ${LArNEST_DIR}/include)
set(LArNEST_LIBRARIES ${LArNEST_BUILD_DIR}/libLArNESTCore.a)
include_directories(${LArNEST_INCLUDE_DIR})
file(GLOB LArNEST_FILES "${LArNEST_DIR}/src/*")
if (LArNEST_FILES)
message(STATUS "LArNEST is already installed at ${LArNEST_DIR}")
set(LArNEST_INSTALLED TRUE)
endif()
#----------------------------------------------------------------------------
# Clone and build LArNEST if not already installed
if (NOT LArNEST_INSTALLED)
message(STATUS "Cloning and building LArNEST...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E env git clone https://github.com/NESTCollaboration/larnest ${LArNEST_DIR}
WORKING_DIRECTORY ${MAIN_EXTERNAL_DIR}
)
execute_process(
COMMAND mkdir build
WORKING_DIRECTORY ${LArNEST_DIR}
)
execute_process(
COMMAND cmake -S . -B build
WORKING_DIRECTORY ${LArNEST_DIR}
)
execute_process(
COMMAND cmake --build build
WORKING_DIRECTORY ${LArNEST_DIR}
)
endif()
include_directories(${LArNEST_INCLUDE_DIR})
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Find libraries and include directories
find_library(MARLEY
NAMES MARLEY
PATHS "${MARLEY_DIR}/build"
REQUIRED
NO_DEFAULT_PATH
)
find_library(MARLEY_ROOT
NAMES MARLEY_ROOT
PATHS "${MARLEY_DIR}/build"
REQUIRED
NO_DEFAULT_PATH
)
file(GLOB SOURCES ${MAIN_SOURCE_DIR}/*.cc
${MAIN_SOURCE_DIR}/physics/*.cc
${MAIN_SOURCE_DIR}/analysis/*.cc
${MAIN_SOURCE_DIR}/generators/*.cc
${MAIN_SOURCE_DIR}/geometry/*.cc
)
file(GLOB HEADERS ${MAIN_INCLUDE_DIR}/*.hh
${MAIN_INCLUDE_DIR}/physics/*.hh
${MAIN_INCLUDE_DIR}/analysis/*.hh
${MAIN_INCLUDE_DIR}/generators/*.hh
${MAIN_INCLUDE_DIR}/geometry/*.hh
${MAIN_INCLUDE_DIR}/utilities/*.hh
)
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PRIVATE
${MAIN_INCLUDE_DIR}
${MARLEY_DIR}/include
${MAIN_INCLUDE_DIR}/physics
${MAIN_INCLUDE_DIR}/analysis
${MAIN_INCLUDE_DIR}/generators
${MAIN_INCLUDE_DIR}/geometry
${MAIN_INCLUDE_DIR}/utilities
${BXDECAY0_DIR}/_install.d/include
)
target_link_libraries(${PROJECT_NAME} ${Geant4_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${ROOT_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${CLHEP_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${MARLEY} ${MARLEY_ROOT})
target_link_libraries(${PROJECT_NAME} BxDecay0::BxDecay0 BxDecay0::BxDecay0_Geant4)
target_link_libraries(${PROJECT_NAME} ${LArNEST_LIBRARIES})