forked from apt-sim/AdePT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (98 loc) · 4.65 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
# SPDX-FileCopyrightText: 2020 CERN
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.18)
# Record the command line invoking the cmake command. Replay with recmake_initial.sh.
include(cmake/RecordCmdLine.cmake)
project(Adept
VERSION 0.1.0
DESCRIPTION "Accelerated demonstrator of electromagnetic Particle Transport"
LANGUAGES C CXX CUDA)
# - Include needed custom/core modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
include(CMakeSettings)
include(CTest)
# - Core/C++/CUDA build and dependency settings
# For single-mode generators, default to Optimized with Debug if nothing is specified
if(NOT CMAKE_CONFIGURATION_TYPES)
set(__DEFAULT_CMAKE_BUILD_TYPE RelWithDebInfo)
if(CMAKE_BUILD_TYPE)
set(__DEFAULT_CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
endif()
set(CMAKE_BUILD_TYPE "${__DEFAULT_CMAKE_BUILD_TYPE}"
CACHE STRING "Choose the type of build, options are: None Release MinSizeRel Debug RelWithDebInfo MinSizeRel."
FORCE)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD})
set(CMAKE_CUDA_STANDARD_REQUIRED ${CMAKE_CXX_STANDARD_REQUIRED})
set(CMAKE_CUDA_EXTENSIONS OFF)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# (for now internal) CopCore dependency
add_subdirectory(base/inc/CopCore)
# With CUDA language enabled above, this should find the toolkit alongside the compiler
find_package(CUDAToolkit REQUIRED)
#Find VecCore with correct backend
set(VecCore_VERSION 0.5.2)
set(VecCore_BACKEND CUDA)
find_package(VecCore ${VecCore_VERSION} REQUIRED COMPONENTS ${VecCore_BACKEND})
message(STATUS "Using VecCore version ${VecCore_VERSION}")
# Find VecGeom geometry headers library
set(VecGeom_VERSION 1.1.17)
find_package(VecGeom ${VecGeom_VERSION} REQUIRED)
message(STATUS "Using VecGeom version ${VecGeom_VERSION}")
# make sure we import VecGeom architecture flags - is this needed?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VECGEOM_CXX_FLAGS}")
# Make sure VecGeom::vgdml is enabled
if(NOT TARGET VecGeom::vgdml)
message(FATAL_ERROR "AdePT requires VecGeom compiled with GDML support")
endif()
# Find Geant4, optional for now
find_package(Geant4 QUIET)
if(Geant4_FOUND)
message(STATUS "Using Geant4 version ${Geant4_VERSION} from ${Geant4_INCLUDE_DIRS}")
else()
message(STATUS "Did not find Geant4")
endif()
# Set up debugging levels for CUDA:
# - For RelWithDebInfo (the default), generate line info to enable profiling.
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:RelWithDebInfo>>:--generate-line-info>")
# - For Debug, generate full debug information - this completely disables optimizations!
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:Debug>>:--device-debug>")
# - For both, interleave the source in PTX to enhance the debugging experience.
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<OR:$<CONFIG:RelWithDebInfo>,$<CONFIG:Debug>>>:--source-in-ptx>")
# Disable warnings from the CUDA frontend about unknown GCC pragmas - let the compiler decide what it likes.
add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe;--diag_suppress=unrecognized_gcc_pragma>")
# Add external dependencies before our own code to allow checking for the
# targets and depend on them.
add_subdirectory(external)
if(BUILD_TESTING)
set(TESTING_GDML "${PROJECT_BINARY_DIR}/trackML.gdml")
set(CMS2018_GDML "${PROJECT_BINARY_DIR}/cms2018.gdml")
file(DOWNLOAD https://gitlab.cern.ch/VecGeom/VecGeom/raw/master/persistency/gdml/gdmls/trackML.gdml "${TESTING_GDML}")
file(DOWNLOAD https://gitlab.cern.ch/VecGeom/VecGeom/raw/master/persistency/gdml/gdmls/cms2018.gdml "${CMS2018_GDML}")
endif()
# Builds...
# Target for use of AdePT
# NB: NOT complete yet due to dependence of AdePT/LoopNavigator.h on VecGeom
# This would be another INTERFACE link library, but needs care because it
# involves VecGeom+CUDA, so usage requirements need some care and thought
add_library(AdePT INTERFACE)
target_include_directories(AdePT
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/base/inc>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/magneticfield/inc>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/tracking/inc>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(AdePT INTERFACE CopCore::CopCore)
# Optional library to activate NVTX annotations for profiling:
set(NVTX OFF CACHE BOOL "Add NVTX instrumentation for profiling (only for annotated examples)")
add_library(NVTX INTERFACE)
if(NVTX)
target_link_libraries(NVTX INTERFACE nvToolsExt)
target_compile_definitions(NVTX INTERFACE -DUSE_NVTX)
endif()
add_subdirectory(tracking)
add_subdirectory(test)
add_subdirectory(examples)