-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCMakeLists.txt
164 lines (134 loc) · 5.38 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
# Copyright 2016-2021 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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.
#
# NUISANCE 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 NUISANCE. If not, see <http://www.gnu.org/licenses/>.
################################################################################
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
#Use the compilers found in the path
find_program(CMAKE_C_COMPILER NAMES $ENV{CC} gcc PATHS ENV PATH NO_DEFAULT_PATH)
find_program(CMAKE_CXX_COMPILER NAMES $ENV{CXX} g++ PATHS ENV PATH NO_DEFAULT_PATH)
set (NUISANCE_VERSION 2.9.9)
project(NUISANCE VERSION ${NUISANCE_VERSION} LANGUAGES CXX Fortran)
#Changes default install path to be a subdirectory of the build dir.
#Can set build dir at configure time with -DCMAKE_INSTALL_PREFIX=/install/path
if(CMAKE_INSTALL_PREFIX STREQUAL "" OR CMAKE_INSTALL_PREFIX STREQUAL
"/usr/local")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}")
elseif(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
elseif(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
endif()
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
include(CPM)
if(DEFINED ENV{NuHepMCModules_ROOT})
include($ENV{NuHepMCModules_ROOT}/NuHepMCModules.cmake)
else()
CPMFindPackage(
NAME CMakeModules
GIT_TAG stable
GITHUB_REPOSITORY NuHepMC/CMakeModules
DOWNLOAD_ONLY
)
include(${CMakeModules_SOURCE_DIR}/NuHepMCModules.cmake)
endif()
################################################################################
# Check Dependencies
################################################################################
#Set this to TRUE to enable build debugging messages
set(BUILD_DEBUG_MSGS TRUE)
include(CMessage)
include(NuHepMCUtils)
include(NUISANCEDependencies)
add_subdirectory(src)
add_subdirectory(app)
SET(CONFIG_COMPILE_DEFINTIONS)
foreach(FEATURE
T2KReWeight
NIWGLegacy
NOvARwgt
nusystematics
Prob3plusplus
GiBUU)
if(${FEATURE}_ENABLED)
LIST(APPEND CONFIG_COMPILE_DEFINTIONS -D${FEATURE}_ENABLED)
endif()
endforeach()
if(GENIE_ENABLED)
LIST(APPEND CONFIG_COMPILE_DEFINTIONS -DGENIE_ENABLED)
LIST(APPEND CONFIG_INCLUDE_DIRECTORIES -I${GENIE_INC_DIR})
if(GENIE3_FOUND)
LIST(APPEND CONFIG_COMPILE_DEFINTIONS -DGENIE3_API_ENABLED)
endif()
endif()
if(NEUT_ENABLED)
LIST(APPEND CONFIG_COMPILE_DEFINTIONS -DNEUT_ENABLED)
LIST(APPEND CONFIG_INCLUDE_DIRECTORIES -I${NEUT_INCLUDE_DIR})
endif()
if(NuWro)
LIST(APPEND CONFIG_COMPILE_DEFINTIONS -DNuWro_ENABLED)
LIST(APPEND CONFIG_INCLUDE_DIRECTORIES -I${NuWro_INC_DIR})
endif()
STRING(REPLACE ";" " " CONFIG_COMPILE_DEFINTIONS "${CONFIG_COMPILE_DEFINTIONS}")
STRING(REPLACE ";" " " CONFIG_INCLUDE_DIRECTORIES "${CONFIG_INCLUDE_DIRECTORIES}")
configure_file(cmake/Templates/setup.sh.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY)
configure_file(cmake/Templates/BuildDynamicSample.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSample" @ONLY)
configure_file(cmake/Templates/BuildDynamicSmearcepter.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSmearcepter" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh"
DESTINATION
${CMAKE_INSTALL_PREFIX})
install(PROGRAMS
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSample"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSmearcepter"
DESTINATION
${CMAKE_INSTALL_PREFIX}/bin)
install(PROGRAMS
"${PROJECT_SOURCE_DIR}/scripts/nuissamples" DESTINATION
bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION
${CMAKE_INSTALL_PREFIX})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/parameters DESTINATION
${CMAKE_INSTALL_PREFIX})
add_subdirectory(CLI)
add_subdirectory(validation)
install(EXPORT nuisance-targets
FILE NUISANCETargets.cmake
NAMESPACE NUIS::
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/NUISANCE
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/NUISANCEConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NUISANCEConfig.cmake
INSTALL_DESTINATION
/this/is/ignored/for/some/reason/thanks/kitware
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/NUISANCEConfigVersion.cmake
VERSION ${NUISANCE_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/NUISANCEConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/NUISANCEConfigVersion.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/FindNOvARwgt.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/NUISANCE)