Superbuild: install step creates build/run_pbwo4 symlink pointing at the executable in build/minicalosim-build/. Regular build: CMAKE_RUNTIME_OUTPUT_DIRECTORY ensures the executable lands in build/ regardless of generator. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
1.8 KiB
CMake
51 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(minicalosim-superbuild NONE)
|
|
|
|
include(ExternalProject)
|
|
include(ProcessorCount)
|
|
|
|
ProcessorCount(NPROC)
|
|
if(NOT NPROC OR NPROC EQUAL 0)
|
|
set(NPROC 4)
|
|
endif()
|
|
# Cap at 16 to avoid memory exhaustion on large machines (mirrors Dockerfile)
|
|
if(NPROC GREATER 16)
|
|
set(NPROC 16)
|
|
endif()
|
|
|
|
set(G4_INSTALL ${CMAKE_BINARY_DIR}/geant4-install)
|
|
set(G4_SRC ${CMAKE_SOURCE_DIR}/../lib/geant4)
|
|
set(MINI_SRC ${CMAKE_SOURCE_DIR}/..)
|
|
|
|
option(GEANT4_INSTALL_DATA "Download Geant4 physics data files (~2 GB)" ON)
|
|
|
|
# ── Geant4 ────────────────────────────────────────────────────────────────────
|
|
ExternalProject_Add(geant4
|
|
SOURCE_DIR ${G4_SRC}
|
|
BINARY_DIR ${CMAKE_BINARY_DIR}/geant4-build
|
|
INSTALL_DIR ${G4_INSTALL}
|
|
CMAKE_ARGS
|
|
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
-DGEANT4_INSTALL_DATA=${GEANT4_INSTALL_DATA}
|
|
-DGEANT4_USE_GDML=ON
|
|
-DGEANT4_BUILD_MULTITHREADED=OFF
|
|
-DGEANT4_BUILD_TLS_MODEL=global-dynamic
|
|
BUILD_COMMAND cmake --build <BINARY_DIR> --parallel ${NPROC}
|
|
INSTALL_COMMAND cmake --install <BINARY_DIR>
|
|
)
|
|
|
|
# ── minicalosim (run_pbwo4) ───────────────────────────────────────────────────
|
|
ExternalProject_Add(run_pbwo4
|
|
SOURCE_DIR ${MINI_SRC}
|
|
BINARY_DIR ${CMAKE_BINARY_DIR}/minicalosim-build
|
|
CMAKE_ARGS
|
|
-DCMAKE_PREFIX_PATH=${G4_INSTALL}
|
|
-DWITH_GEANT4_UIVIS=OFF
|
|
BUILD_COMMAND cmake --build <BINARY_DIR> --target run_pbwo4 --parallel ${NPROC}
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
${CMAKE_BINARY_DIR}/minicalosim-build/run_pbwo4
|
|
${CMAKE_BINARY_DIR}/run_pbwo4
|
|
DEPENDS geant4
|
|
)
|