-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
678 lines (590 loc) · 23 KB
/
CMakeLists.txt
File metadata and controls
678 lines (590 loc) · 23 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
# SPDX-FileCopyrightText: 2020 CERN
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.25.2)
# 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
)
#----------------------------------------------------------------------------#
# CMake and Build Settings
#----------------------------------------------------------------------------#
# - Include needed custom/core modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
include(CMakeSettings)
include(CTest)
include(CheckCXXSourceCompiles)
# - 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."
FORCE
)
endif()
set(CMAKE_CXX_STANDARD 20)
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)
#----------------------------------------------------------------------------#
# User options
#----------------------------------------------------------------------------#
# Options
option(ADEPT_USE_SURF "Enable surface model navigation on GPU" OFF)
option(ADEPT_MIXED_PRECISION "Use B-field integration and surface model in mixed precision" OFF)
option(ADEPT_USE_SPLIT_KERNELS "Run split version of the transport kernels" OFF)
option(ADEPT_USE_EXT_BFIELD "Use external B field from file via the covfie library" OFF)
option(ADEPT_DEBUG_SINGLE_THREAD "Run transport kernels in single thread mode" OFF)
set(ADEPT_DEBUG_TRACK 0 CACHE STRING "Debug tracking level (0=off, >0=on with levels)")
option(ADEPT_ENFORCE_STRICT_FLAGS "Enforce strict compiler flags, as also used in CMSSW" OFF)
option(ADEPT_ENABLE_POWER_METER "Compile the code for consumption measurement" OFF)
option(ADEPT_BUILD_TESTING "Build unit and regression tests" OFF)
option(ADEPT_BUILD_EXAMPLES "Build examples" OFF)
# Backend options
# Available backend options
set(_backend_opts CUDA HIP)
set(_backend_default CUDA)
# Set backend option default value and store in CMake cache
set(ADEPT_COMPUTE_BACKEND CUDA CACHE STRING "Backend to compile for")
# Store the possible options in the cache
set_property(CACHE ADEPT_COMPUTE_BACKEND PROPERTY STRINGS ${_backend_opts})
# Check that the selected option is correct
list(FIND _backend_opts "${ADEPT_COMPUTE_BACKEND}" idx)
if(idx EQUAL -1)
message(FATAL_ERROR
"Invalid ADEPT_COMPUTE_BACKEND='${ADEPT_COMPUTE_BACKEND}'. Available options: ${_backend_opts}"
)
endif()
if(ADEPT_COMPUTE_BACKEND STREQUAL CUDA)
set(ADEPT_USE_CUDA TRUE)
elseif(ADEPT_COMPUTE_BACKEND STREQUAL HIP)
set(ADEPT_USE_HIP TRUE)
endif()
if(ADEPT_USE_CUDA)
enable_language(CUDA)
elseif(ADEPT_USE_HIP)
enable_language(HIP)
endif()
message(STATUS "${Green}${ADEPT_COMPUTE_BACKEND} backend enabled${ColorReset}")
# Ensure that ctest is enabled when ADEPT_BUILD_TESTING is ON
if(ADEPT_BUILD_TESTING)
set(BUILD_TESTING ON)
endif()
# Compile flag for AdePT SteppingActions on the GPU
set(ADEPT_STEPPINGACTION "NONE" CACHE STRING "SteppingAction: NONE|CMS|LHCb|ATLAS")
set_property(CACHE ADEPT_STEPPINGACTION PROPERTY STRINGS NONE CMS LHCb ATLAS)
if(ADEPT_STEPPINGACTION STREQUAL "CMS")
set(_ADEPT_STEPACTION_TYPE 1)
elseif(ADEPT_STEPPINGACTION STREQUAL "LHCb")
set(_ADEPT_STEPACTION_TYPE 2)
elseif(ADEPT_STEPPINGACTION STREQUAL "ATLAS")
set(_ADEPT_STEPACTION_TYPE 3)
else()
set(_ADEPT_STEPACTION_TYPE 0)
endif()
message(STATUS "AdePT SteppingAction: ${Green}${ADEPT_STEPPINGACTION} ${ColorReset}")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(_warn_flags
-Wall
-Wextra
-Wpedantic
-Wno-non-template-friend
-Wno-long-long
-Wreturn-type
-Wpessimizing-move
-Wclass-memaccess
-Wno-cast-function-type
-Wno-unused-but-set-parameter
-Wno-ignored-qualifiers
-Wno-unused-parameter
-Wunused
-Wparentheses
-Wnon-virtual-dtor
-Wno-unused-local-typedefs
-Wno-attributes
-Wno-psabi
)
set(_error_flags
-Werror=main
-Werror=switch
-Werror=pointer-arith
-Werror=overlength-strings
-Werror=overflow
-Werror=array-bounds
-Werror=format-contains-nul
-Werror=type-limits
-Werror=return-type
-Werror=missing-braces
-Werror=unused-value
-Werror=unused-label
-Werror=address
-Werror=format
-Werror=sign-compare
-Werror=write-strings
-Werror=delete-non-virtual-dtor
-Werror=strict-aliasing
-Werror=narrowing
-Werror=unused-but-set-variable
-Werror=reorder
-Werror=unused-variable
-Werror=conversion-null
-Werror=return-local-addr
)
# In soft mode, convert all -Werror=foo to just -Wfoo
if(NOT ADEPT_ENFORCE_STRICT_FLAGS)
set(_converted_errors "")
foreach(f IN LISTS _error_flags)
string(REPLACE "-Werror=" "-W" _wflag "${f}")
list(APPEND _converted_errors "${_wflag}")
endforeach()
set(_final_flags ${_warn_flags} ${_converted_errors})
else()
message(STATUS "Enabling strict compiler flags")
set(_final_flags ${_warn_flags} ${_error_flags})
endif()
string(JOIN " " _final_flags_str ${_final_flags})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_final_flags_str}")
endif()
#----------------------------------------------------------------------------#
# Dependencies
#----------------------------------------------------------------------------#
if(ADEPT_USE_CUDA)
# With CUDA language enabled above, this should find the toolkit alongside the compiler
find_package(CUDAToolkit REQUIRED)
endif()
#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 ${Cyan}${VecCore_VERSION}${ColorReset}")
# Before looking for other packages, try to find XercesC explicitly to avoid
# problems with G4HepEm not finding Geant4 11.1 even though we find it here.
find_package(XercesC REQUIRED)
# Find VecGeom geometry headers library
find_package(VecGeom REQUIRED)
if(ADEPT_USE_CUDA AND NOT VecGeom_CUDA_FOUND)
message(FATAL_ERROR
"AdePT requires a VecGeom build with CUDA support when "
"ADEPT_COMPUTE_BACKEND=CUDA. Rebuild/reinstall VecGeom with CUDA enabled "
"and point CMake to that installation."
)
endif()
### VecGeom Version check
# Use VecGeom_VERSION_STRING if defined, otherwise fall back to VecGeom_VERSION
if(NOT VecGeom_VERSION_STRING)
set(VecGeom_VERSION_STRING ${VecGeom_VERSION})
endif()
# VecGeom might append build metadata (e.g. '+master.abc123') to the version string.
# Strip everything after the '+' to focus on the version core.
string(REGEX REPLACE "\\+.*$" "" CLEANED_VERSION "${VecGeom_VERSION_STRING}")
# Try to match the core version suffix to extract either:
# - an RC version like "rc3", "rc4"
# - a dev version like "dev.3", "dev.4"
# This works even if the full suffix is like "rc3.213" or "dev.4.99"
string(REGEX MATCH "2\\.0\\.0-(rc[0-9]+|dev\\.[0-9]+)" _match "${CLEANED_VERSION}")
set(MATCHED_SUFFIX "${CMAKE_MATCH_1}")
set(_vecgeom_dev_version 5)
set(_vecgeom_version_ok FALSE)
# Handle dev versions
if(MATCHED_SUFFIX MATCHES "dev\\.([0-9]+)")
set(devver "${CMAKE_MATCH_1}")
if(devver GREATER_EQUAL _vecgeom_dev_version)
set(_vecgeom_version_ok TRUE)
endif()
endif()
# Handle rc versions
if(MATCHED_SUFFIX MATCHES "rc\\.([0-9]+)")
set(rcver "${CMAKE_MATCH_1}")
if(rcver GREATER_EQUAL _vecgeom_dev_version)
set(_vecgeom_version_ok TRUE)
endif()
endif()
# Handle stable releases >= 2.0.0
if(CLEANED_VERSION VERSION_GREATER_EQUAL "2.0.0" AND NOT MATCHED_SUFFIX)
set(_vecgeom_version_ok TRUE)
endif()
if(NOT _vecgeom_version_ok)
message(FATAL_ERROR "AdePT requires VecGeom >= 2.0.0-dev.${_vecgeom_dev_version} or >= 2.0.0-rc.${_vecgeom_dev_version}, but found '${VecGeom_VERSION_STRING}'")
else()
message(STATUS "Using VecGeom version ${Cyan}${VecGeom_VERSION_STRING}${ColorReset}")
endif()
### end version check for VecGeom
# Check whether VecGeom::vgdml is enabled
if(TARGET VecGeom::vgdml)
set(VECGEOM_GDML_SUPPORT TRUE)
add_compile_definitions(VECGEOM_GDML_SUPPORT)
else()
set(VECGEOM_GDML_SUPPORT FALSE)
message(STATUS "VecGeom was compiled without GDML support, only in-memory geometry conversion via g4vg will be available")
endif()
# Run split kernels
if (ADEPT_USE_SPLIT_KERNELS)
add_compile_definitions(ADEPT_USE_SPLIT_KERNELS)
message(STATUS "${Green}AdePT will run with split kernels${ColorReset}")
endif()
# Debugging in single-thread mode
if (ADEPT_DEBUG_SINGLE_THREAD)
add_compile_definitions("$<$<CONFIG:Debug>:ADEPT_DEBUG_SINGLE_THREAD>")
message(STATUS "${Magenta}Transport is running in single-thread mode${ColorReset}")
endif()
# Check for RK integration precision
if (ADEPT_MIXED_PRECISION)
message(STATUS "${Green}Using single precision in RK integration${ColorReset}")
add_compile_definitions(ADEPT_MIXED_PRECISION)
else()
message(STATUS "${Green}Using double precision in RK integration${ColorReset}")
endif()
# Check for surface model support in VecGeom
if(ADEPT_USE_SURF)
if(VecGeom_SURF_FOUND)
if (ADEPT_MIXED_PRECISION)
message(STATUS "${Green}Using the surface model in VecGeom in mixed precision${ColorReset}")
else()
message(STATUS "${Green}Using the surface model in VecGeom in double precision${ColorReset}")
endif()
add_compile_definitions(ADEPT_USE_SURF)
else()
message(STATUS "${Magenta}No VecGeom surface support. Forcing ADEPT_USE_SURF to OFF${ColorReset}")
set(ADEPT_USE_SURF OFF CACHE BOOL "Disable using the surface model" FORCE)
endif()
else()
message(STATUS "${Green}Using the solid model in VecGeom${ColorReset}")
endif()
# Find Geant4, optional for now
find_package(Geant4 REQUIRED)
message(STATUS "Using Geant4 version ${Cyan}${Geant4_VERSION}${ColorReset} from ${Geant4_INCLUDE_DIRS}")
# Build AdePT with the same library type as Geant4:
# prefer static libraries when they are available, otherwise use shared.
if(Geant4_static_FOUND)
set(_adept_library_type STATIC)
if(Geant4_shared_FOUND)
message(STATUS "Both static and shared Geant4 libraries are available; AdePT will use static libraries.")
endif()
elseif(Geant4_shared_FOUND)
set(_adept_library_type SHARED)
else()
message(FATAL_ERROR
"Could not determine the Geant4 library type: neither "
"Geant4_static_FOUND nor Geant4_shared_FOUND is set."
)
endif()
message(STATUS "AdePT library type: ${Green}${_adept_library_type}${ColorReset} (taken from Geant4)")
# If both Geant4 STATIC and SHARED are installed, plain Geant4_LIBRARIES still refers to
# the default imported SHARED targets. Remap those targets to their -static siblings
# when AdePT itself is built as a static library.
set(_adept_geant4_libraries)
foreach(_g4lib IN LISTS Geant4_LIBRARIES)
set(_adept_g4lib ${_g4lib})
if(_adept_library_type STREQUAL "STATIC" AND _g4lib MATCHES "^Geant4::" AND TARGET "${_g4lib}-static")
set(_adept_g4lib "${_g4lib}-static")
endif()
list(APPEND _adept_geant4_libraries "${_adept_g4lib}")
endforeach()
block()
set(CMAKE_REQUIRED_INCLUDES ${Geant4_INCLUDE_DIRS})
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# Check if Geant4 is supports G4VTrackingManager
# Always available from v11.0, but experiments may backport it to earlier versions
# so we do a compile check.
check_cxx_source_compiles([[
#include "G4VTrackingManager.hh"
#include "G4Track.hh"
struct testtm_ : G4VTrackingManager {
void HandOverOneTrack(G4Track*) override {}
};
int main() {
testtm_ t;
return 0;
}
]] AdePT_HAS_G4VTRACKINGMANAGER)
endblock()
# Find HepMC3, used by integration examples to load realistic events
find_package(HepMC3 QUIET)
if(HepMC3_FOUND)
message(STATUS "HepMC3 found ${HEPMC3_INCLUDE_DIR}")
add_compile_definitions(HEPMC3_FOUND)
endif()
# Find G4VG
# Default to use FetchContent'd G4VG for current ease of use and until CI
# includes an install. Also allows easy testing of upstream patches until
# fully stable across projects.
# NB: Though the option can be switched in a given build directory after the initial
# build, if you have an install of G4VG that could/would be picked up, you may get
# CMake-generate time warnings about safe runtime paths. Generally, you should
# pick one way to pickup G4VG and stick with that throughout the lifetime of
# the build directory.
# The eventual fix for this will be to move to require an external G4VG only
option(ADEPT_USE_BUILTIN_G4VG "Fetch and build G4VG as part of AdePT" ON)
if(ADEPT_USE_BUILTIN_G4VG)
# Fetch it locally
include(FetchContent)
FetchContent_Declare(
g4vg
GIT_REPOSITORY https://github.com/celeritas-project/g4vg
GIT_TAG f4308d392a502b7bd7468938f8d9a63198d3d866 # v1.0.3
)
# Keep the fetched G4VG library type aligned with AdePT.
if(_adept_library_type STREQUAL "SHARED")
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()
FetchContent_MakeAvailable(g4vg)
message(STATUS "Using FetchContent to build G4VG as part of AdePT")
else()
find_package(G4VG 1.0.3 REQUIRED)
message(STATUS "Found G4VG: ${G4VG_DIR}")
endif()
# Find covfie to load external fields from file.
if(ADEPT_USE_EXT_BFIELD)
# An 3D magnetic field map requires the covfie library.
# The default is to use an installed covfie version. If no covfie installation is provided,
# it is fetched from source and made available via FetchContent
message(STATUS "Compiling with external magnetic field support via covfie")
add_compile_definitions(ADEPT_USE_EXT_BFIELD)
find_package(covfie QUIET)
if (covfie_FOUND)
get_target_property(COVFIE_INCLUDE_DIR covfie::core INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "covfie found at: ${COVFIE_INCLUDE_DIR}")
else()
set(ADEPT_COVFIE_REPO "https://github.com/acts-project/covfie.git")
set(ADEPT_COVFIE_BRANCH "v0.15.3") # latest version number at 06.08.2025
message(STATUS "No covfie provided, fetching from: ${ADEPT_COVFIE_REPO} (branch: ${ADEPT_COVFIE_BRANCH})")
include(FetchContent)
FetchContent_Declare(
covfie
GIT_REPOSITORY ${ADEPT_COVFIE_REPO}
GIT_TAG ${ADEPT_COVFIE_BRANCH}
)
set(COVFIE_PLATFORM_CUDA ON CACHE BOOL "Enable CUDA support in covfie" FORCE)
FetchContent_MakeAvailable(covfie)
FetchContent_GetProperties(covfie)
if(NOT covfie_POPULATED)
message(FATAL_ERROR "Fetching covfie failed!")
endif()
endif()
endif()
if(ADEPT_ENABLE_POWER_METER)
find_package(Power_meter QUIET)
if(Power_meter_FOUND)
message(STATUS "Power_meter found ${Power_meter_INCLUDE_DIR}")
add_compile_definitions(ENABLE_POWER_METER)
else()
# Fetch it locally
include(FetchContent)
FetchContent_Declare(
power_meter
GIT_REPOSITORY https://github.com/apt-sim/power_meter
GIT_TAG 458fa2f4f72287d7128de25ed570d2803f0fbe89
)
FetchContent_MakeAvailable(power_meter)
message(STATUS "Using FetchContent to build Power_meter")
FetchContent_GetProperties(power_meter)
if(NOT power_meter_POPULATED)
message(FATAL_ERROR "Fetching Power_meter failed!")
endif()
add_compile_definitions(ENABLE_POWER_METER)
endif()
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 track debug as compile definition for CUDA if debugging requested
if(ADEPT_DEBUG_TRACK GREATER 0)
add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:-DADEPT_DEBUG_TRACK=${ADEPT_DEBUG_TRACK}>")
endif()
if(ADEPT_USE_HIP)
add_compile_options("$<$<COMPILE_LANGUAGE:HIP>:-Xcudafe;--diag_suppress=unrecognized_gcc_pragma;-rdc=true>")
endif()
find_package(G4HepEm CONFIG REQUIRED)
if(G4HepEm_FOUND)
message(STATUS "G4HepEm found ${G4HepEm_INCLUDE_DIR}")
endif()
#----------------------------------------------------------------------------#
# Build Targets
#----------------------------------------------------------------------------#
set(ADEPT_CORE_SRCS
src/AdePTG4HepEmState.cpp
src/AsyncAdePTTransport.cc
src/AsyncAdePTTransport.cu
src/HostCircularBuffer.cpp
)
set(ADEPT_G4_INTEGRATION_SRCS
src/AdePTConfiguration.cc
src/AdePTGeometryBridge.cpp
src/G4HepEmTrackingManagerSpecialized.cc
src/AdePTTrackingManager.cc
src/G4EmStandardPhysics_AdePT.cc
src/G4EmStandardPhysics_HepEm.cc
src/AdePTGeant4Integration.cpp
src/AdePTConfigurationMessenger.cc
src/G4IntegrationRdcFacade.cu
)
add_library(Core INTERFACE)
target_include_directories(Core
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/AdePT/copcore/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>
)
add_library(AdePT::Core ALIAS Core)
cuda_rdc_add_library(Transport ${_adept_library_type}
${ADEPT_CORE_SRCS}
)
if(ADEPT_USE_HIP)
set_source_files_properties(src/AsyncAdePTTransport.cu PROPERTIES LANGUAGE HIP)
set_source_files_properties(src/G4IntegrationRdcFacade.cu PROPERTIES LANGUAGE HIP)
endif()
cuda_rdc_target_include_directories(Transport
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>
)
cuda_rdc_target_link_libraries(Transport
PUBLIC
Core
VecGeom::vecgeom
G4HepEm::g4HepEm
G4HepEm::g4HepEmData
G4HepEm::g4HepEmInit
G4HepEm::g4HepEmRun
CUDA::cudart
)
if(ADEPT_USE_EXT_BFIELD)
# link covfie if external magnetic field usage is enabled
cuda_rdc_target_link_libraries(Transport
PUBLIC
covfie::core
covfie::cuda
)
endif()
# must be defined when compiling the core sources.
target_compile_definitions(Transport
PRIVATE ADEPT_STEPACTION_TYPE=${_ADEPT_STEPACTION_TYPE}
)
if(TARGET Transport_objects)
target_compile_definitions(Transport_objects
PRIVATE ADEPT_STEPACTION_TYPE=${_ADEPT_STEPACTION_TYPE}
)
endif()
# Export config macros to consumers (Athena, etc.)
set(ADEPT_PUBLIC_CONFIG_DEFINITIONS
ADEPT_STEPACTION_TYPE=${_ADEPT_STEPACTION_TYPE}
$<$<BOOL:${ADEPT_USE_SURF}>:ADEPT_USE_SURF>
$<$<BOOL:${ADEPT_MIXED_PRECISION}>:ADEPT_MIXED_PRECISION>
$<$<BOOL:${ADEPT_USE_SPLIT_KERNELS}>:ADEPT_USE_SPLIT_KERNELS>
$<$<AND:$<BOOL:${ADEPT_DEBUG_SINGLE_THREAD}>,$<CONFIG:Debug>>:ADEPT_DEBUG_SINGLE_THREAD>
$<$<BOOL:${ADEPT_USE_EXT_BFIELD}>:ADEPT_USE_EXT_BFIELD>
$<$<BOOL:${ADEPT_ENABLE_POWER_METER}>:ADEPT_ENABLE_POWER_METER>
$<$<BOOL:${ADEPT_DEBUG_TRACK}>:ADEPT_DEBUG_TRACK=${ADEPT_DEBUG_TRACK}>
)
target_compile_definitions(Transport
PUBLIC
${ADEPT_PUBLIC_CONFIG_DEFINITIONS}
)
# Use descriptive install names while keeping short CMake target names.
set_target_properties(Transport PROPERTIES OUTPUT_NAME adept_transport)
if(TARGET Transport_static)
set_target_properties(Transport_static PROPERTIES OUTPUT_NAME adept_transport_static)
endif()
if(TARGET Transport_final)
set_target_properties(Transport_final PROPERTIES OUTPUT_NAME adept_transport_final)
endif()
# This needs to be after the cuda_rdc_target_include_directories when
# using v10 of CudaRdcUtils.cmake
cuda_rdc_add_library(AdePT::Transport ALIAS Transport)
# Keep the experiment-facing library as a true RDC target so exported consumers
# can propagate the middle/final transport mapping across their own device-link.
cuda_rdc_add_library(G4Integration ${_adept_library_type}
${ADEPT_G4_INTEGRATION_SRCS}
)
cuda_rdc_target_include_directories(G4Integration
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/>
)
cuda_rdc_add_library(AdePT::G4Integration ALIAS G4Integration)
cuda_rdc_target_link_libraries(G4Integration
PUBLIC
Transport
Core
VecGeom::vecgeom
$<$<BOOL:${VECGEOM_GDML_SUPPORT}>:VecGeom::vgdml>
${_adept_geant4_libraries}
G4VG::g4vg
$<$<BOOL:${ADEPT_ENABLE_POWER_METER}>:Power_meter::Power_meter>
)
set_target_properties(G4Integration PROPERTIES OUTPUT_NAME adept_g4integration)
if(TARGET G4Integration_static)
set_target_properties(G4Integration_static PROPERTIES OUTPUT_NAME adept_g4integration_static)
endif()
if(TARGET G4Integration_final)
set_target_properties(G4Integration_final PROPERTIES OUTPUT_NAME adept_g4integration_final)
endif()
if(ADEPT_BUILD_TESTING)
add_subdirectory(test)
endif()
if(ADEPT_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
####################################################################################################
include(CMakePackageConfigHelpers)
#Generate the configuration file from the template and save it to the build directory
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
# Install RDC targets one by one. With the current CudaRdcUtils helper,
# batching multiple targets in a single cuda_rdc_install(...) call can drop
# sibling *_static/*_final exports from the generated package config.
cuda_rdc_install(TARGETS Core
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
cuda_rdc_install(TARGETS Transport
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
cuda_rdc_install(TARGETS G4Integration
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
#Install the headers
install(DIRECTORY include/AdePT
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
#Install the configuration file
install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AdePTConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
# Export the targets file
export(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
FILE "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Targets.cmake"
)
#Install the targets file
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)