From 724fab0949cfa908dcc223b40611d61122045872 Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Tue, 1 Aug 2023 08:52:48 -0400 Subject: [PATCH 1/3] Export Celeritas_VERSION_STRING --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6374ee903c..c518658e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -424,10 +424,14 @@ install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/backport" # Export all cache variables that start with CELERITAS_ set(CELERITAS_EXPORT_VARIABLES) +macro(celeritas_export_var varname) + list(APPEND CELERITAS_EXPORT_VARIABLES "set(${varname} \"${${varname}}\")") +endmacro() +celeritas_export_var(Celeritas_VERSION_STRING) get_directory_property(_cachevar_keys CACHE_VARIABLES) foreach(_key IN LISTS _cachevar_keys) if(_key MATCHES "^CELERITAS_") - list(APPEND CELERITAS_EXPORT_VARIABLES "set(${_key} \"${${_key}}\")") + celeritas_export_var(${_key}) endif() endforeach() From 654af7b265c9d3624c996d7461189985f3f2f673 Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Tue, 1 Aug 2023 09:01:40 -0400 Subject: [PATCH 2/3] Export defaulted variables --- CMakeLists.txt | 8 +++++--- cmake/CeleritasUtils.cmake | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c518658e4a..1157c9cbe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -428,6 +428,7 @@ macro(celeritas_export_var varname) list(APPEND CELERITAS_EXPORT_VARIABLES "set(${varname} \"${${varname}}\")") endmacro() celeritas_export_var(Celeritas_VERSION_STRING) +list(APPEND CELERITAS_EXPORT_VARIABLES "\n# Configuration options") get_directory_property(_cachevar_keys CACHE_VARIABLES) foreach(_key IN LISTS _cachevar_keys) if(_key MATCHES "^CELERITAS_") @@ -435,13 +436,14 @@ foreach(_key IN LISTS _cachevar_keys) endif() endforeach() -# Add other cache variables, prefixed with CELERITAS_ -foreach(_key BUILD_SHARED_LIBS) +# Export defaulted variables +list(APPEND CELERITAS_EXPORT_VARIABLES "\n# Defaulted variables") +foreach(_key IN LISTS CELERITAS_DEFAULT_VARIABLES) list(APPEND CELERITAS_EXPORT_VARIABLES "set(CELERITAS_${_key} \"${${_key}}\")") endforeach() # Add hints for direct dependencies and indirect geant dependencies -list(APPEND CELERITAS_EXPORT_VARIABLES "# Hints for upstream dependencies") +list(APPEND CELERITAS_EXPORT_VARIABLES "\n# Hints for upstream dependencies") foreach(_key MPIEXEC_EXECUTABLE CUDAToolkit_BIN_DIR Geant4_DIR GTest_DIR HepMC3_DIR nlohmann_json_DIR Python_DIR ROOT_DIR diff --git a/cmake/CeleritasUtils.cmake b/cmake/CeleritasUtils.cmake index a01c462202..2c276a8209 100644 --- a/cmake/CeleritasUtils.cmake +++ b/cmake/CeleritasUtils.cmake @@ -136,6 +136,8 @@ include_guard(GLOBAL) include(CheckLanguage) +set(CELERITAS_DEFAULT_VARIABLES) + #-----------------------------------------------------------------------------# function(celeritas_optional_language lang) @@ -199,12 +201,13 @@ endmacro() #-----------------------------------------------------------------------------# -function(celeritas_set_default name value) +macro(celeritas_set_default name value) if(NOT DEFINED ${name}) message(VERBOSE "Celeritas: set default ${name}=${value}") - set(${name} "${value}" PARENT_SCOPE) + set(${name} "${value}") endif() -endfunction() + list(APPEND CELERITAS_DEFAULT_VARIABLES ${name}) +endmacro() #-----------------------------------------------------------------------------# From fdeb845005558bc5e2e4223e8c56954733fb3112 Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Tue, 1 Aug 2023 09:54:00 -0400 Subject: [PATCH 3/3] Use version string for vecgeom if available --- src/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b63c01c752..6efd92d112 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,8 +62,12 @@ endforeach() foreach(_var CLHEP_VERSION Geant4_VERSION VecGeom_VERSION) string(TOLOWER "${_var}" _lower) + if(DEFINED ${_var}_STRING) + set(_var "${_var}_STRING") + endif() + set(_value "${${_var}}") string(APPEND CELERITAS_CMAKE_STRINGS - "static const char celeritas_${_lower}[] = \"${${_var}}\";\n" + "static const char celeritas_${_lower}[] = \"${_value}\";\n" ) endforeach() celeritas_configure_file("celeritas_cmake_strings.h.in" "celeritas_cmake_strings.h" @ONLY)