forked from JeffersonLab/hps-mc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
158 lines (131 loc) · 4.69 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
cmake_minimum_required(VERSION 3.22)
project(hps-mc VERSION 2.0.0)
# cmake macros
include(ExternalProject)
include(FindPackageHandleStandardArgs)
# languages
enable_language(Fortran)
enable_language(C)
# enable in source build since default is not writable from a non-root account
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "..." FORCE)
endif()
# cmake macros for this project
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# Find Python 3
find_package(Python3 COMPONENTS Interpreter REQUIRED)
message(STATUS "Python3 executable found at: ${Python3_EXECUTABLE}")
set(PYTHON ${Python3_EXECUTABLE})
# Find Python 2
#find_package(Python2 COMPONENTS Interpreter REQUIRED)
#message(STATUS "Python2 executable found at: ${Python2_EXECUTABLE}")
# Check for Fortran compiler
find_program(GFORTRAN gfortran REQUIRED)
# Check for Java
find_package(Java COMPONENTS Runtime REQUIRED)
message(STATUS "java was found at: ${Java_JAVA_EXECUTABLE}")
message(STATUS "java version: ${Java_VERSION}")
# Check for Maven
find_program(MAVEN mvn REQUIRED)
set(MAVEN_BUILD_COMMAND ${MAVEN} clean install -DskipTests -T 4 -q)
# Check for GSL
find_package(GSL REQUIRED)
message(STATUS "GSL found with version: ${GSL_VERSION}")
# Build and install stdhep tools
option(HPSMC_ENABLE_STDHEP "Install StdHep tools" OFF)
if (HPSMC_ENABLE_STDHEP)
add_subdirectory(tools/stdhep-lib)
add_subdirectory(tools/stdhep-tools)
else()
message(STATUS "StdHep tools are disabled")
endif()
# Build and install EGS5
option(HPSMC_ENABLE_EGS5 "Install EGS5" OFF)
if (HPSMC_ENABLE_EGS5)
if (NOT HPSMC_ENABLE_STDHEP)
message(FATAL_ERROR "StdHep must be enabled to use EGS5")
endif()
add_subdirectory(generators/egs5)
install(DIRECTORY generators/egs5 DESTINATION share/generators USE_SOURCE_PERMISSIONS)
else()
message(STATUS "EGS5 is disabled")
endif()
# Build and install Madgraph
option(HPSMC_ENABLE_MADGRAPH "Install Madgraph" OFF)
if (HPSMC_ENABLE_MADGRAPH)
add_subdirectory(generators/madgraph4)
add_subdirectory(generators/madgraph5)
install(DIRECTORY generators/madgraph4 DESTINATION share/generators USE_SOURCE_PERMISSIONS)
install(DIRECTORY generators/madgraph5 DESTINATION share/generators USE_SOURCE_PERMISSIONS)
else()
message(STATUS "Madgraph is disabled")
endif()
option(HPSMC_ENABLE_ROOT "Enable ROOT setup" OFF)
if (HPSMC_ENABLE_ROOT)
if(DEFINED ENV{ROOTSYS})
set(ROOTSYS $ENV{ROOTSYS})
message(STATUS "ROOTSYS set to: ${ROOTSYS}")
else()
message(FATAL_ERROR "ROOT was enabled but ROOTSYS is not set in the environment")
endif()
else()
message(STATUS "ROOT is disabled")
endif()
# External projects will be added to this target
add_custom_target(external)
# Install magnetic field maps
option(HPSMC_ENABLE_FIELDMAPS "Install fieldmaps" OFF)
if(HPSMC_ENABLE_FIELDMAPS)
include(InstallFieldmaps)
else()
message(STATUS "Fieldmaps are disabled")
endif()
# Install LCIO
option(HPSMC_ENABLE_LCIO "Install LCIO" OFF)
if(HPSMC_ENABLE_LCIO)
include(InstallLCIO)
else()
message(STATUS "LCIO is disabled")
endif()
# Install HPS Java
option(HPSMC_ENABLE_HPSJAVA "Install HPS Java" OFF)
if(HPSMC_ENABLE_HPSJAVA)
include(InstallHpsJava)
else()
message(STATUS "HpsJava is disabled")
endif()
# Install Pede
option(HPSMC_ENABLE_PEDE "Enable (and install if necessary) pede" OFF)
if (HPSMC_ENABLE_PEDE)
find_program(pede_FOUND "pede")
if(pede_FOUND)
message(STATUS "Found pede at ${pede_FOUND}")
else()
include(InstallPede)
endif()
else()
message(STATUS "pede is disabled")
endif()
# Install local conditions database
option(HPSMC_ENABLE_CONDITIONS "Install local conditions database" OFF)
if(HPSMC_ENABLE_CONDITIONS)
include(InstallConditions)
else()
message(STATUS "Local conditions db is disabled")
endif()
# Install python scripts
install(DIRECTORY python DESTINATION lib)
# Custom target to only install the python scripts (must be executed manually)
add_custom_target(InstallPythonScripts
COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/lib && cp -R ${PROJECT_SOURCE_DIR}/python ${CMAKE_INSTALL_PREFIX}/lib)
# Install configured scripts
file(GLOB SCRIPTS_IN scripts/*.in)
foreach(SCRIPT_IN ${SCRIPTS_IN})
get_filename_component(SCRIPT_IN_FILE ${SCRIPT_IN} NAME)
string(REPLACE ".in" "" SCRIPT_OUT ${SCRIPT_IN_FILE})
configure_file(${SCRIPT_IN} ${CMAKE_BINARY_DIR}/${SCRIPT_OUT} @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/${SCRIPT_OUT} DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endforeach()
# Print install dir
message(STATUS "HPSMC will be installed at: ${CMAKE_INSTALL_PREFIX}")