-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
151 lines (122 loc) · 4.66 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
# Minimum 3.5 version is determined by cmake -E copy_if_different command
# that was used to copy headers to the build directory:
# multiple files are supported since cmake 3.5
cmake_minimum_required(VERSION 3.5)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include( MunkeiVersionFromGit )
version_from_git(
LOG ON
TIMESTAMP "%Y%m%d%H%M%S"
)
project(AnalysisTree
VERSION ${VERSION}
LANGUAGES CXX)
# by default build optimized code
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
# in DEBUG mode make verbose Makefile
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif ()
if(CMAKE_CXX_STANDARD LESS 17)
find_package(Boost REQUIRED)
endif()
if(Boost_FOUND)
message(STATUS "Boost version ${Boost_VERSION_STRING} is found!")
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIRS}")
endif()
# CMake options
set(AnalysisTree_BUILD_TESTS OFF CACHE BOOL "Build tests for the AnalysisTree")
set(AnalysisTree_BUILD_EXAMPLES OFF CACHE BOOL "Build examples for the AnalysisTree")
set(AnalysisTree_BUILD_EXPERIMENTAL OFF CACHE BOOL "Build experimental features for the AnalysisTree")
set(AnalysisTree_BUILD_INFRA_1 OFF CACHE BOOL "Build AnalysisTree infra-1.0")
# Tests
include(TestsSetup)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb -g -DDEBUG -D__DEBUG -Wall -Wextra")
#set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb -g -DDEBUG -D__DEBUG -Wall -Wextra --coverage")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ftree-vectorize -ffast-math -DNODEBUG")
message(STATUS "Using CXX flags for ${CMAKE_BUILD_TYPE}: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
message(STATUS "Using CXX standard " ${CMAKE_CXX_STANDARD})
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
list(APPEND CMAKE_PREFIX_PATH ${ROOTSYS})
find_package(ROOT REQUIRED)
message(STATUS "Using ROOT: ${ROOT_VERSION} <${ROOT_CONFIG}>")
include_directories(${ROOT_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} core)
include(${ROOT_USE_FILE})
# libraries
add_subdirectory(core)
add_subdirectory(infra)
if(AnalysisTree_BUILD_INFRA_1)
add_subdirectory(infra-1.0)
endif()
if(AnalysisTree_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# header with version
configure_file(cmake/AnalysisTreeVersion.hpp.in ${CMAKE_BINARY_DIR}/include/AnalysisTree/AnalysisTreeVersion.hpp)
configure_file(cmake/AnalysisTreeConfig.sh.in ${CMAKE_BINARY_DIR}/AnalysisTreeConfig.sh)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${PROJECT_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake")
message(STATUS "${PROJECT_NAME}Targets: ${${PROJECT_NAME}Targets}")
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
set(${PROJECT_NAME}_INCLUDE_DIR "include")
set(${PROJECT_NAME}_LIBRARY_DIR "lib")
set(${PROJECT_NAME}_BINARY_DIR "bin")
set(${AnalysisTree_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}")
configure_package_config_file(
cmake/${PROJECT_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
PATH_VARS ${PROJECT_NAME}_INCLUDE_DIR ${PROJECT_NAME}_LIBRARY_DIR ${PROJECT_NAME}_BINARY_DIR
)
add_custom_target(HashWriteTarget ALL) # Silent call of target. I don't know how to avoid it, sorry :)
add_custom_command(TARGET HashWriteTarget
POST_BUILD
COMMAND /bin/sh ${CMAKE_CURRENT_SOURCE_DIR}/cmake/AnalysisTreeHashWriter.sh ${CMAKE_CURRENT_SOURCE_DIR}
)
install(EXPORT ${PROJECT_NAME}Targets
FILE
${PROJECT_NAME}Targets.cmake
DESTINATION
${ConfigPackageLocation}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
install(FILES
${CMAKE_BINARY_DIR}/include/AnalysisTree/AnalysisTreeVersion.hpp
DESTINATION
include/AnalysisTree
COMPONENT
Devel
)
install(FILES
${CMAKE_BINARY_DIR}/AnalysisTreeConfig.sh
${CMAKE_CURRENT_BINARY_DIR}/AnalysisTreeHash.sh
DESTINATION
bin
COMPONENT
Devel
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/AnalysisTreeDiff.patch
DESTINATION
bin
COMPONENT
Devel
OPTIONAL
)