-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
160 lines (128 loc) · 6.41 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
# CMakeLists.txt for the "SandReco" package. It creates a library with a dictionary and a main program.
# If ROOT is not installed in a default system location you need to tell CMake where to find it.
# Sourcing `thisroot.sh` already sets the required environment variables.
# Otherwise, you'll have to tell the build system where to look for ROOT,
# e.g. by passing `-DROOT_DIR="/path/to/root/installation` at cmake configuration time.
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(SandReco LANGUAGES CXX VERSION 01.00.00)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_PLATFORM_INDEPENDENT_CODE ON)
# Locate the ROOT package and define a number of useful targets and variables.
find_package(ROOT REQUIRED)
# Locate EDep-sim
find_package(EDepSim REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# set output directory
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
# Creates a libStruct shared library with a generated dictionary.
add_library(Struct SHARED include/struct.h)
target_include_directories(Struct PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(Struct PUBLIC)
ROOT_GENERATE_DICTIONARY(StructDict struct.h MODULE Struct LINKDEF include/StructLinkDef.h)
# Create SANDGeoManager lib
add_library(SANDGeoManager SHARED src/SANDGeoManager.cpp src/SANDSTTTubeInfo.cpp src/SANDECALCellInfo.cpp)
target_link_libraries(SANDGeoManager PUBLIC EDepSim::edepsim_io)
ROOT_GENERATE_DICTIONARY(SANDGeoManagerDict SANDGeoManager.h SANDSTTTubeInfo.h SANDECALCellInfo.h MODULE SANDGeoManager LINKDEF include/SANDGeoManagerLinkDef.h)
# Creates a libUtils shared library
add_library(Utils SHARED src/utils.cpp src/transf.cpp)
target_include_directories(Utils PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(Utils PUBLIC SANDGeoManager EDepSim::edepsim_io)
# Create libClustering shared library
add_library(SANDClustering SHARED src/SANDClustering.cpp)
target_link_libraries(SANDClustering PUBLIC Utils)
ROOT_GENERATE_DICTIONARY(SANDClusteringDict SANDClustering.h MODULE SANDClustering LINKDEF include/SANDClusteringLinkDef.h)
# Creates Digitize executable.
add_executable(Digitize src/digitization.cpp src/SANDDigitization.cpp src/SANDDigitizationEDEPSIM.cpp src/SANDDigitizationFLUKA.cpp)
target_link_libraries(Digitize Struct SANDGeoManager Utils)
# Creates Reconstruct executable.
add_executable(Reconstruct src/reconstruction.cpp)
target_link_libraries(Reconstruct Struct Utils SANDGeoManager SANDClustering)
# Creates Analyze executable.
#add_executable(Analyze src/analysis.cpp)
#target_link_libraries(Analyze Struct Utils ROOT::EG)
# Creates Display executable.
add_executable(Display src/display.cpp)
target_link_libraries(Display Struct Utils)
# Creates FastCheck executable.
add_executable(FastCheck src/fastcheck.cpp)
target_link_libraries(FastCheck Struct Utils)
# Creates a libSANDEventDisplay shared library
add_library(SANDEventDisplay SHARED src/SANDEventDisplay.cpp src/SANDDisplayUtils.cpp SANDEventDisplayDict.cxx)
target_include_directories(SANDEventDisplay PUBLIC ${EDepSim_INCLUDE_DIR}
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(SANDEventDisplay PUBLIC Utils EDepSim::edepsim_io)
ROOT_GENERATE_DICTIONARY(SANDEventDisplayDict SANDEventDisplay.h LINKDEF include/SANDEventDisplayLinkDef.h)
# Creates eventDisplay executable.
add_executable(eventDisplay src/eventDisplay.cpp)
target_link_libraries(eventDisplay PUBLIC Utils SANDEventDisplay "-lEG -lGui")
# Creates SANDECALClustering executable.
add_executable(SANDECALClustering src/SANDECALClustering.cpp)
target_link_libraries(SANDECALClustering PUBLIC Utils SANDClustering)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "default install path" FORCE )
endif()
# Copy setup.sh configuration file
configure_file(setup.sh "${CMAKE_INSTALL_PREFIX}/setup.sh" COPYONLY)
#install(TARGETS Utils Struct SANDEventDisplay SANDClustering SANDECALClustering SANDGeoManager Digitize Reconstruct Analyze Display FastCheck eventDisplay
install(TARGETS Utils Struct SANDEventDisplay SANDClustering SANDECALClustering SANDGeoManager Reconstruct Digitize Display FastCheck eventDisplay
EXPORT SandRecoTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
install(
DIRECTORY "${CMAKE_BINARY_DIR}/."
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
FILES_MATCHING
PATTERN "*.pcm"
PATTERN "*.rootmap"
PATTERN "lib" EXCLUDE
PATTERN "bin" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION "${CMAKE_INSTALL_PREFIX}"
PATTERN "Linkdef.h" EXCLUDE
PATTERN "SANDEventDisplayLinkDef.h" EXCLUDE)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons
DESTINATION "${CMAKE_INSTALL_PREFIX}")
# ############################################################
#
# Prepare the package so that it can be used with the find_package interface.
#
# ############################################################
# Include module with function 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Build the targets description so that the package can be configured
# using find_package.
install(EXPORT SandRecoTargets
NAMESPACE SandReco::
DESTINATION lib/cmake/SandReco)
# Write the 'SandRecoConfigVersion.cmake' file which can be used to
# check if a version meets the requested properties.
write_basic_package_version_file(
SandRecoConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
# Write the 'SandRecoConfig.cmake' file so that a user package can
# access this with find_package.
configure_package_config_file(
PackageConfig.cmake.in
SandRecoConfig.cmake
PATH_VARS CMAKE_INSTALL_PREFIX
INSTALL_DESTINATION lib/cmake/SandReco)
# Install the config files.
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/SandRecoConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SandRecoConfigVersion.cmake
DESTINATION lib/cmake/SandReco)