forked from eic/EICrecon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
146 lines (118 loc) · 5.96 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
# Variables to control this CMake build:
# ===================================================================================
# CMake flag | environment variable | Description
# ===================================================================================
# -DEIC_DD4HEP_HOME | EIC_DD4HEP_HOME | DD4Hep Detector geometry install
# -DIP6_DD4HEP_HOME | IP6_DD4HEP_HOME | DD4Hep IP6 geometry install dir
# -- (under review) | EDM4HEP_ROOT | Edm4Hep installation directory
#------------------------------------------------------------------------------------
# -DCMAKE_CXX_STANDARD | 17 - standard for C++ compilation
# ===================================================================================
#
#
# ==============================================================
# DEPENDENCIES (used by find_package)
# ==============================================================
# Name | Description
# ==============================================================
# JANA | Jana2 framework
# EDM4HEP | Event data model based on podio
# podio | IO library
# DD4hep | Geometry framework
# ROOT | CERN ROOT
# spdlog | Formatting library
# IRT | Indirect Ray Tracing library
# ==============================================================
cmake_minimum_required(VERSION 3.16)
project(EICRecon VERSION 0.3.6)
# Make C++17 a default
if(NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17)
endif()
# Export compile commands as json for run-clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# This PROJECT_SOURCE_DIR at this point corresponds to repository root.
# Saving it as EICRECON_SOURCE_DIR so can be used for jana_plugin.cmake
# to correctly set plugin includes (and in other places as needed)
set(EICRECON_SOURCE_DIR ${PROJECT_SOURCE_DIR})
# Also use clang-tidy integration in CMake
option(ENABLE_CLANG_TIDY "Enable clang-tidy integration in cmake" OFF)
if(ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if (CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" CACHE STRING "" FORCE)
else()
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
endif()
endif()
# Enable -fPIC for all targets
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Install to the top directory by default
if( ${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT} )
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} CACHE PATH "Install in top directory by default" FORCE)
endif()
# Default plugins installation directory is 'plugins'
if(NOT DEFINED PLUGIN_OUTPUT_DIRECTORY)
set(PLUGIN_OUTPUT_DIRECTORY "lib/EICrecon/plugins")
message(STATUS "${CMAKE_PROJECT_NAME}: Set default PLUGIN_OUTPUT_DIRECTORY")
endif()
message(STATUS "${CMAKE_PROJECT_NAME}: PLUGIN_OUTPUT_DIRECTORY: ${PLUGIN_OUTPUT_DIRECTORY}")
# Default plugins static libraries installation directory is 'lib'
if(NOT DEFINED PLUGIN_LIBRARY_OUTPUT_DIRECTORY)
set(PLUGIN_LIBRARY_OUTPUT_DIRECTORY "lib")
message(STATUS "${CMAKE_PROJECT_NAME}: Set default PLUGIN_OUTPUT_DIRECTORY")
endif()
message(STATUS "${CMAKE_PROJECT_NAME}: PLUGIN_LIBRARY_OUTPUT_DIRECTORY: ${PLUGIN_LIBRARY_OUTPUT_DIRECTORY}")
# Check and print what JANA2 is used
find_package(JANA REQUIRED)
message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 CMake : ${JANA_DIR}")
message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 includes: ${JANA_INCLUDE_DIR}")
message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 library : ${JANA_LIBRARY}")
# PODIO, EDM4HEP, EDM4EIC event models
find_package(podio REQUIRED)
find_package(EDM4HEP REQUIRED)
find_package(EDM4EIC REQUIRED)
set(EDM4EIC_INCLUDE_DIR ${EDM4EIC_DIR}/../../include)
# DD4Hep is required for the most of the part
find_package(DD4hep REQUIRED)
# ACTS
find_package(Acts REQUIRED COMPONENTS Core PluginIdentification PluginTGeo PluginDD4hep)
set(Acts_VERSION_MIN "19.0.0")
set(Acts_VERSION "${Acts_VERSION_MAJOR}.${Acts_VERSION_MINOR}.${Acts_VERSION_PATCH}")
if(${Acts_VERSION} VERSION_LESS ${Acts_VERSION_MIN}
AND NOT "${Acts_VERSION}" STREQUAL "9.9.9")
message(FATAL_ERROR "Acts version ${Acts_VERSION_MIN} or higher required, but ${Acts_VERSION} found")
endif()
set(Acts_INCLUDE_DIRS ${Acts_DIR}/../../../include ${ActsDD4hep_DIR}/../../../include )
# CERN ROOT
find_package(ROOT REQUIRED)
# Set it ON for additional CMake printout
set(EICRECON_VERBOSE_CMAKE OFF)
# Add CMake additional functionality:
include(cmake/print_functions.cmake) # Helpers to print fancy headers, file names, etc
include(cmake/print_subdirectory_tree.cmake) # Prints processed subdirectories
include(cmake/jana_plugin.cmake) # Add common settings for plugins
list (APPEND CMAKE_MODULE_PATH ${EICRECON_SOURCE_DIR}/cmake) # Find Find<Modules>.cmake
# ------------------------------------------------------------------
print_grand_header(" B U I L D E I C R E C O N P A R T S ")
# ------------------------------------------------------------------
add_subdirectory( src/services )
add_subdirectory( src/algorithms )
add_subdirectory( src/benchmarks )
add_subdirectory( src/detectors )
add_subdirectory( src/examples )
add_subdirectory( src/global )
add_subdirectory( src/scripts )
add_subdirectory( src/tests )
add_subdirectory( src/utilities )
# Print what we had built
print_header("CMake processed subdirectories:")
print_subdirectory_tree()
message(STATUS "\n-------------------------------")
# Install all cmake helpers
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/EICreconConfig.cmake.in cmake/EICreconConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/EICrecon)
install(FILES ${CMAKE_BINARY_DIR}/cmake/EICreconConfig.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/EICrecon) # why is this needed?
file(GLOB EICRECON_CMAKE_FILES cmake/*.cmake)
install(FILES ${EICRECON_CMAKE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/EICrecon)