-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
95 lines (80 loc) · 3.03 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
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
project(grasshopper)
# Allow User Build Options Here...
option(WITH_GEANT4_UIVIS "Build with Geant4 UI and Vis drivers" ON) # Can switch to OFF if not building with vis drivers --> NOT recommended
option(WITH_ROOT "Build with ROOT" OFF) # Can switch off if ROOT Output not desired
# Add various compile definitions
if(WITH_ROOT)
add_compile_definitions(G4ANALYSIS_USE_ROOT)
message(STATUS "G4ANALYSIS_USE_ROOT Added to compile Definitions.")
endif()
#Suppress Warnings
if(${SHOW_WARNINGS})
message(STATUS "Running make with warning full verbosity")
else()
message(STATUS "Subduing some warnings")
add_compile_options(-Wno-unused-variable -Wno-shadow -Wno-unused-parameter)
endif()
#Find Geant4 Package
# Here you require a Geant4 minimum version... example set to 10.5
if(WITH_GEANT4_UIVIS)
find_package(Geant4 10.5 REQUIRED ui_all vis_all)
message(STATUS "Built Geant4 with UI and Vis Drivers")
else()
find_package(Geant4 10.5 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
#
include(${Geant4_USE_FILE})
# Find ROOT (required package)
if(WITH_ROOT)
find_package(ROOT CONFIG REQUIRED)
if(ROOT_FOUND)
message(STATUS "ROOT Found.")
else()
message(STATUS "ROOT NOT Found. --> MAKE WILL FAIL!")
endif()
include("${ROOT_USE_FILE}")
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR}
${ROOT_INCLUDE_DIR}
)
else()
include_directories(${PROJECT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR}
)
endif()
# Locate Sources and Headers
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 and ROOT libraries
#
add_executable(grasshopper grasshopper.cc ${sources} ${headers})
if(WITH_ROOT)
target_link_libraries(grasshopper ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
else()
target_link_libraries(grasshopper ${Geant4_LIBRARIES})
endif()
#----------------------------------------------------------------------------
# Copy relavant scripts to the build directory, i.e. the directory in which we
# build grasshopper. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(VIS_SCRIPTS
# vis.mac
)
foreach(_script ${VIS_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS grasshopper DESTINATION bin)