-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
53 lines (42 loc) · 1.54 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
# SETUP
# -----------------------------------------------------------------------
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 20)
project(Rivelatore)
# compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# delete root files
set(results_path ${PROJECT_SOURCE_DIR}/results/)
file(GLOB results "${results_path}/*.root")
if(NOT results)
message("ROOT directory is empty")
else()
file(REMOVE_RECURSE ${results})
message("ROOT files deleted")
endif()
# look for GEANT4
find_package(Geant4 REQUIRED ui_all vis_all)
# include necessary files and directories
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/include/utils)
# compile every source and header file in project directory
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB utils_cpp ${PROJECT_SOURCE_DIR}/src/utils/*.cpp)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
file(GLOB utils_hh ${PROJECT_SOURCE_DIR}/include/utils/*.hh)
# copy macro files to build directory
set(SCRIPTS vis.mac run.mac compile.sh)
foreach(_script ${SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
# create executable and link it to Geant4 libraries
add_executable(rivelatore main.cpp ${sources} ${headers} ${utils_cpp} ${utils_hh})
target_link_libraries(rivelatore ${Geant4_LIBRARIES})
# install executable
install(TARGETS rivelatore DESTINATION bin)
# -----------------------------------------------------------------------