Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
+90 -9
View File
@@ -497,10 +497,11 @@ endfunction()
#
# .. code-block:: cmake
#
# geant4_add_category(<name> MODULES <module> [<module> ...])
# geant4_add_category(<name> [INTERFACE] [MODULES <module> [<module> ...]])
#
# Add a Geant4 category ``<name>`` to the project, composed of the modules
# supplied in the ``MODULES`` list.
# Add a Geant4 category ``<name>`` to the project. It can be composed from modules
# supplied in the ``MODULES`` list, or the ``INTERFACE`` option can be used
# to create an alias to one or more other categories.
#
# Calling this function does not create an actual CMake library target.
# Because modules declare dependencies on modules rather than libraries, we
@@ -512,12 +513,23 @@ function(geant4_add_category _name)
__geant4_category_assert_not_exists(${_name})
set_property(GLOBAL APPEND PROPERTY GEANT4_DEFINED_CATEGORIES ${_name})
cmake_parse_arguments(G4ADDCAT
""
"INTERFACE"
""
"MODULES"
${ARGN}
)
# - Modules must not be empty (Could also just be ARGN)
# INTERFACE/MODULES are mutually exclusive
if(G4ADDCAT_INTERFACE AND G4ADDCAT_MODULES)
message(FATAL_ERROR "geant4_add_category: INTERFACE and MODULES arguments are mutually exclusive")
endif()
if(G4ADDCAT_INTERFACE)
geant4_set_category_property(${_name} PROPERTY IS_ALIAS TRUE)
geant4_set_category_property(${_name} PROPERTY CATEGORIES)
return()
endif()
# - Modules must not be empty (Could also just be ARGN)
if(NOT G4ADDCAT_MODULES)
message(FATAL_ERROR "geant4_add_category: Missing/empty 'MODULES' argument")
endif()
@@ -532,6 +544,23 @@ function(geant4_add_category _name)
geant4_set_category_property(${_name} PROPERTY CMAKE_LIST_FILE "${CMAKE_CURRENT_LIST_FILE}")
endfunction()
#-----------------------------------------------------------------------
#.rst:
# .. cmake:command:: geant4_category_is_alias
#
# .. code-block:: cmake
#
# geant4_category_is_alias(<category> <outputvar>)
#
# Set ``outputvar`` to ``TRUE`` if ``<category>`` is an alias to one or
# more others.
#
function(geant4_category_is_alias _outvar _name)
__geant4_category_assert_exists(${_name})
geant4_get_category_property(_result ${_name} IS_ALIAS)
set(${_outvar} ${_result} PARENT_SCOPE)
endfunction()
#-----------------------------------------------------------------------
#.rst:
# .. cmake:command:: geant4_category_modules
@@ -544,6 +573,11 @@ endfunction()
#
function(geant4_category_modules _name)
__geant4_category_assert_exists(${_name})
geant4_category_is_alias(check ${_name})
if(check)
message(FATAL_ERROR "geant4_category_modules: Trying to add modules to ALIAS-type category '${_name}'")
endif()
# ARGN must not be empty
if(NOT ARGN)
message(FATAL_ERROR "no modules given to add to to category '${_name}'")
@@ -575,6 +609,34 @@ function(geant4_category_modules _name)
geant4_set_category_property(${_name} PROPERTY IS_INTERFACE ${__cat_is_interface})
endfunction()
#-----------------------------------------------------------------------
#.rst:
# .. cmake:command:: geant4_category_interfaces
#
# .. code-block:: cmake
#
# geant4_category_interfaces(<category> <cat> [<mat> ...]))
#
# Add categories to alias category ``<category>``
#
function(geant4_category_interfaces _name)
__geant4_category_assert_exists(${_name})
geant4_category_is_alias(check ${_name})
if(NOT check)
message(FATAL_ERROR "geant4_category_modules: Trying to add categories to non-ALIAS category '${_name}'")
endif()
# ARGN must not be empty
if(NOT ARGN)
message(FATAL_ERROR "no categories given to add to to category '${_name}'")
endif()
foreach(iface ${ARGN})
__geant4_category_assert_exists(${iface})
geant4_set_category_property(${_name} APPEND PROPERTY CATEGORIES ${iface})
endforeach()
endfunction()
#-----------------------------------------------------------------------
#.rst:
# .. cmake:command:: geant4_get_categories
@@ -627,6 +689,8 @@ endfunction()
# * ``IS_INTERFACE``
# * ``MODULES``
# * ``PUBLIC_HEADERS``
# * ``IS_ALIAS``
# * ``CATEGORIES``
#
# The properties of a category may be queried and set using the following
# commands.
@@ -1190,7 +1254,7 @@ endmacro()
# This is used internally by the property get/set functions.
#
function(__geant4_category_validate_property _property)
if(NOT (${_property} MATCHES "CMAKE_LIST_FILE|IS_INTERFACE|MODULES|PUBLIC_HEADERS"))
if(NOT (${_property} MATCHES "CMAKE_LIST_FILE|IS_INTERFACE|MODULES|PUBLIC_HEADERS|DEFINE_SYMBOL|IS_ALIAS|CATEGORIES"))
message(FATAL_ERROR "Undefined property '${_property}'")
endif()
endfunction()
@@ -1216,7 +1280,7 @@ function(__geant4_category_reset)
# Reset category properties, then categories
geant4_get_categories(__all_categories)
foreach(__cat ${__all_categories})
foreach(_prop CMAKE_LIST_FILE IS_INTERFACE MODULES PUBLIC_HEADERS)
foreach(_prop CMAKE_LIST_FILE IS_INTERFACE MODULES PUBLIC_HEADERS DEFINE_SYMBOL IS_ALIAS CATEGORIES)
geant4_set_category_property(${__cat} PROPERTY ${_prop})
endforeach()
endforeach()
@@ -1277,10 +1341,11 @@ function(__geant4_add_library _name _type)
message(FATAL_ERROR "Invalid library type '${_type}'")
endif()
# Check if the overall library is binary or header-only
# Check if the overall library is binary, header-only, or an alias (really an interface in CMake terms)
set(_lib_cmake_type ${_type})
geant4_get_category_property(_lib_is_interface ${_name} IS_INTERFACE)
if(_lib_is_interface)
geant4_get_category_property(_lib_is_alias ${_name} IS_ALIAS)
if(_lib_is_interface OR _lib_is_alias)
set(_lib_cmake_type "INTERFACE")
endif()
@@ -1297,6 +1362,16 @@ function(__geant4_add_library _name _type)
if(_lib_cmake_type STREQUAL "INTERFACE")
target_compile_features(${_target_name} INTERFACE ${GEANT4_TARGET_COMPILE_FEATURES})
set(_props_to_process "INTERFACE")
# Shortcut: If this category is also an "alias", we just extract the link interface directly
if(_is_lib_is_alias)
geant4_get_category_property(iface ${_name} CATEGORIES)
if(_type STREQUAL "STATIC")
list(TRANSFORM iface APPEND "-static")
endif()
target_link_libraries(${_target_name} INTERFACE ${iface})
return()
endif()
else()
target_compile_features(${_target_name} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
set(_props_to_process "PUBLIC" "PRIVATE" "INTERFACE")
@@ -1310,6 +1385,12 @@ function(__geant4_add_library _name _type)
target_compile_definitions(${_target_name} PUBLIC G4LIB_BUILD_DLL)
set_target_properties(${_target_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Check if we have a DEFINE_SYMBOL for this category
geant4_get_category_property(_lib_define_symbol ${_name} DEFINE_SYMBOL)
if(_lib_define_symbol)
set_target_properties(${_target_name} PROPERTIES DEFINE_SYMBOL ${_lib_define_symbol})
endif()
# MacOS
# Use '@rpath' in install names of libraries on macOS to provide relocatibility
# Add '@loader_path' to INSTALL_RPATH on macOS so that Geant4