-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·144 lines (114 loc) · 4.05 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
cmake_minimum_required(VERSION 3.11)
include(cmake/ccache_support.cmake)
project(GlobalNuAnalysis2 LANGUAGES C CXX VERSION 0.1.1)
set(LIBNAME GlobalNuAnalysis2)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(compiler_selection)
include(cuda_support)
configure_file(core/config_vars.h.in ${CMAKE_BINARY_DIR}/generated/config_vars.h)
set(BUILD_SHARED_LIBS ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
include(add_fmt)
add_subdirectory(core)
add_subdirectory(transformations)
add_subdirectory(extra)
add_subdirectory(examples)
add_subdirectory(unittest)
set(SOURCES
${CORE_SOURCES}
${TRANSFORMATION_SOURCES}
${EXTRA_SOURCES}
${EXAMPLES_SOURCES}
${UNITTEST_SOURCES}
)
set(HEADERS
${CUHEADERS}
${CORE_HEADERS}
${TRANSFORMATION_HEADERS}
${EXTRA_HEADERS}
${EXAMPLES_HEADERS}
${UNITTEST_HEADERS}
config_vars.h
)
include_directories(
${CMAKE_BINARY_DIR}/generated/
core/parameters/
core/parametrized/
core/transformation/
core/
transformations/trial/
transformations/backgrounds/
transformations/base/
transformations/sum/
transformations/array1d/
transformations/ratio/
transformations/calculus/
transformations/detector/
transformations/functions/
transformations/hist/
transformations/integrator/
transformations/interpolation/
transformations/linalg/
transformations/neutrino/
transformations/stats/
transformations/var/
transformations/debug/
transformations/legacy/
extra/
examples/
unittest/
)
message(STATUS "Setting ${CMAKE_BUILD_TYPE} build")
add_custom_target(cleanpyc ALL
COMMAND find . -name '*.pyc' -delete
COMMENT "Cleaning temporary python files"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
option(GENERATE_PROFILE OFF)
option(USE_PROFILE OFF)
option(UB_SANITIZE OFF)
option(LTO OFF)
#Check if LTO is possible
if(LTO)
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
endif()
message(STATUS "Compiling in C++${CMAKE_CXX_STANDARD} mode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Werror -Wall -pedantic -pipe")
include(compilation_opts)
include(debug_opts)
find_package(Eigen3 REQUIRED NO_MODULE)
find_package(Boost 1.40.0 REQUIRED)
if(Boost_FOUND)
message(STATUS "found Boost version ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} in ${Boost_INCLUDE_DIRS}")
else(Boost_FOUND)
message(FATAL_ERROR "Boost >= 1.40.0 not found")
endif(Boost_FOUND)
find_package(GSL REQUIRED)
find_package(ROOT CONFIG REQUIRED)
include(${ROOT_USE_FILE})
add_library(${LIBNAME} SHARED ${SOURCES} ${CONTRIB_SRC})
ROOT_GENERATE_DICTIONARY(Dict "${HEADERS}" MODULE ${LIBNAME} OPTIONS -interpreteronly)
if(result)
set_property(TARGET ${LIBNAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
target_include_directories(${LIBNAME} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(${LIBNAME} PRIVATE ROOT::Core ROOT::MathCore ${CUDA_ADD_LIBS})
target_link_libraries(${LIBNAME} PRIVATE GSL::gsl GSL::gslcblas)
target_link_libraries(${LIBNAME} PRIVATE Eigen3::Eigen)
target_link_libraries(${LIBNAME} PRIVATE fmt)
if(GENERATE_PROFILE)
target_link_libraries(${LIBNAME} PRIVATE "-fprofile-generate=${CMAKE_BINARY_DIR}/profile-data")
endif()
if(UB_SANITIZE)
target_link_libraries(${LIBNAME} PRIVATE "-fsanitize=undefined")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)