This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
135 lines (109 loc) · 4.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
# Set the minimum version of CMake that's required
cmake_minimum_required(VERSION 3.12)
# Set the project name
project(
Framework
VERSION 1.3.6
DESCRIPTION "Framework used to define processing pipelines and modules."
LANGUAGES CXX)
setup_library(module Framework name Exception)
setup_library(module Framework name Performance dependencies ROOT::Core Framework::Exception)
root_generate_dictionary(PerfDict
Framework/Performance/Timer.h
LINKDEF ${PROJECT_SOURCE_DIR}/include/Framework/Performance/LinkDef.h
MODULE Framework_Performance)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Framework_Performance_rdict.pcm DESTINATION lib)
setup_library(module Framework name Configure interface)
# Search for the Python3 library
find_package(Python3 COMPONENTS Interpreter Development)
# Search for Boost
find_package(
Boost REQUIRED
COMPONENTS system
log
filesystem
thread
chrono
atomic
regex)
# Search and configure ROOT
find_package(ROOT 6.16 CONFIG REQUIRED)
# Generate the ROOT dictionary. The following allows the use of the macro used
# to generate the dictionary.
include("${ROOT_DIR}/RootMacros.cmake")
# Execute the command to extract the SHA1 hash of the current git tag. The
# variable GIT_SHA1 will be set to contain the hash.
execute_process(COMMAND git rev-parse HEAD OUTPUT_VARIABLE GIT_SHA1)
# Remove the newline character
string(REGEX REPLACE "\n$" "" GIT_SHA1 "${GIT_SHA1}")
# Copies the file 'Version.h.in', substitutes the value of GIT_SHA1 and writes
# it out to Version.h.
configure_file(${PROJECT_SOURCE_DIR}/include/Framework/Version.h.in
${PROJECT_BINARY_DIR}/include/Framework/Version.h)
install(FILES ${PROJECT_BINARY_DIR}/include/Framework/Version.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Framework/)
# Register both the event and run headers with the event bus and ROOT dictionary
register_event_object(module_path "Framework" namespace "ldmx"
class "EventHeader")
register_event_object(module_path "Framework" namespace "ldmx"
class "RunHeader")
# Setup the library
setup_library(module Framework
dependencies Python3::Python
ROOT::Core
ROOT::Hist
ROOT::TreePlayer
Boost::log
Boost::atomic
Boost::regex
Framework::Exception
Framework::Configure
Framework::Performance
"${registered_targets}")
# Compiling the Framework library requires features introduced by the cpp 17
# standard.
set_target_properties(
Framework
PROPERTIES CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
# the following writes the LinkDef file using the CMake global variables
# namespaces and dict that are lists appended to by the register_event_object function
message(STATUS "Building ROOT dictionary LinkDef")
set(linkdef_filepath ${PROJECT_BINARY_DIR}/include/Framework/EventDictLinkDef.h)
file(WRITE ${linkdef_filepath} "
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;
")
list(REMOVE_DUPLICATES namespaces)
foreach(namespace ${namespaces})
file(APPEND ${linkdef_filepath} "#pragma link C++ namespace ${namespace};\n")
endforeach()
foreach(entry ${dict})
file(APPEND ${linkdef_filepath} "#pragma link C++ class ${entry}+;\n")
endforeach()
file(APPEND ${linkdef_filepath} "\n#endif\n")
# need to update include directories so the dictionary generation knows
# to use different paths at install time
target_include_directories(Framework PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
${include_paths}
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
# attach a ROOT dictionary to the Framework module with all the registered
# headers in the event_headers list
root_generate_dictionary(EventDict
${event_headers}
LINKDEF ${linkdef_filepath}
MODULE Framework)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libFramework_rdict.pcm DESTINATION lib)
# Add the fire executable
add_executable(fire ${PROJECT_SOURCE_DIR}/app/fire.cxx)
target_link_libraries(fire PRIVATE Framework::Framework)
install(TARGETS fire DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# Setup the test
setup_test(dependencies Framework::Framework)
setup_python(package_name ${PYTHON_PACKAGE_NAME}/Framework)