forked from SuperNEMO-DBD/Falaise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
190 lines (164 loc) · 6.28 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# - Top level CMake script for Falaise
#-----------------------------------------------------------------------
# Copyright 2012,2013 Ben Morgan <[email protected]>
# Copyright 2012,2013 University of Warwick
#
# This file is part of Falaise.
#
# Falaise is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Falaise is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Falaise. If not, see <http://www.gnu.org/licenses/>.
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# Enforce an out-of-source build.
#
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "Falaise requires an out-of-source build.")
message(STATUS "Please remove these files from ${CMAKE_BINARY_DIR} first:")
message(STATUS " CMakeCache.txt")
message(STATUS " CMakeFiles")
message(STATUS "Once these files are removed, create a separate directory")
message(STATUS "and run CMake from there, pointing it to:")
message(STATUS " ${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "in-source build detected")
endif()
#-----------------------------------------------------------------------
# CMake/project requirements and configuration
#
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(Falaise VERSION "4.0.3")
# - Load custom modules
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
#-----------------------------------------------------------------------
# Needed Modules
#
#- Common LPC utilities
include(LPCCMakeSettings)
# - Clang Format/Tidy
include(ClangTools)
# - Add Git info to versioning
# 1. Add "-g<HEADHASH:0-8>" when in Git working copy
# 2. If there are uncommitted local changes, add "-dirty"
include(GetGitRevisionDescription)
get_git_head_revision(Falaise_GIT_REFSPEC Falaise_GIT_HASH)
git_local_changes(Falaise_GIT_STATE)
if(Falaise_GIT_HASH)
string(SUBSTRING "${Falaise_GIT_HASH}" 0 8 Falaise_GIT_HASH_SHORT)
set(Falaise_VERSION "${Falaise_VERSION}-g${Falaise_GIT_HASH_SHORT}")
if(Falaise_GIT_STATE STREQUAL "DIRTY")
set(Falaise_VERSION "${Falaise_VERSION}-dirty")
set(FALAISE_VERSION_IS_DIRTY YES)
endif()
endif()
#-----------------------------------------------------------------------
# Configure testing if required
#
option(FALAISE_ENABLE_TESTING "Build unit testing system for Falaise" OFF)
# Common testing environment
set(_falaise_TEST_ENVIRONMENT
"FALAISE_RESOURCE_DIR=${PROJECT_SOURCE_DIR}/resources"
"PATH=${PROJECT_BUILD_BINDIR}:$ENV{PATH}"
)
macro(set_falaise_test_environment _tname)
set_property(TEST ${_tname}
APPEND PROPERTY ENVIRONMENT ${_falaise_TEST_ENVIRONMENT}
)
endmacro()
if(FALAISE_ENABLE_TESTING)
enable_testing()
endif()
#-----------------------------------------------------------------------
# Optional build of documentation
#
option(FALAISE_WITH_DOCS "Build documentation for Falaise" ON)
#-----------------------------------------------------------------------
# Bayeux is the main external dependency, and we know it will additionally
# search for and provide compatible versions of:
#
# - Boost
# - GSL
# - ROOT
# - Geant4
set(FALAISE_BAYEUX_MIN_VERSION 3.4.1)
find_package(Bayeux ${FALAISE_BAYEUX_MIN_VERSION} REQUIRED geant4)
#-----------------------------------------------------------------------
# Build the subdirectories as required
#
add_subdirectory(utilities)
add_subdirectory(source)
if(FALAISE_WITH_DOCS)
add_subdirectory(documentation)
endif()
#-----------------------------------------------------------------------
# Install resources
#
# Build tree
# This allows the programs to be run directly without requiring FALAISE_RESOURCE_DIR
# to be set.
add_custom_command(OUTPUT ${PROJECT_BUILD_DATAROOTDIR}/${PROJECT_RESOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_LIST_DIR}/resources ${PROJECT_BUILD_DATAROOTDIR}/${PROJECT_RESOURCE_DIR}
COMMENT "Symlinking Falaise resources into build directory"
)
add_custom_target(PublishResources ALL DEPENDS ${PROJECT_BUILD_DATAROOTDIR}/${PROJECT_RESOURCE_DIR})
# Install tree
install(DIRECTORY resources/
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_RESOURCE_DIR}"
)
install(DIRECTORY ${PROJECT_BUILD_DATAROOTDIR}/
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}
# Exclude resources symlink
PATTERN "${PROJECT_RESOURCE_DIR}" EXCLUDE
)
#-----------------------------------------------------------------------
# - CMake Support files
include(CMakePackageConfigHelpers)
# - Versioning file is the same for the build and install trees
write_basic_package_version_file(
${FALAISE_BUILD_CMAKEDIR}/${FALAISE_TAG}/FalaiseConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
# - Config file is also the same in build/install trees as we use same layout
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/FalaiseConfig.cmake.in
${FALAISE_BUILD_CMAKEDIR}/${FALAISE_TAG}/FalaiseConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_TAG}
PATH_VARS
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_DATAROOTDIR
)
# - Targets (build tree)
export(EXPORT FalaiseTargets
NAMESPACE Falaise::
FILE ${FALAISE_BUILD_CMAKEDIR}/${FALAISE_TAG}/FalaiseTargets.cmake
)
# - Targets (install tree)
install(EXPORT FalaiseTargets
NAMESPACE Falaise::
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${FALAISE_TAG}
)
# - Installation of, well, install tree files
install(
FILES
${PROJECT_BUILD_CMAKEDIR}/${FALAISE_TAG}/FalaiseConfigVersion.cmake
${PROJECT_BUILD_CMAKEDIR}/${FALAISE_TAG}/FalaiseConfig.cmake
DESTINATION
${CMAKE_INSTALL_CMAKEDIR}/${FALAISE_TAG}
)
#-----------------------------------------------------------------------
# - Plugins/modules installation - Must come last because they must find
# Falaise, so require the config/targets file to have been generated
# Also programs whilst migrating FLVisualize
add_subdirectory(programs)
add_subdirectory(modules)
# - end