Import Geant4 11.2.0.beta source tree
This commit is contained in:
@@ -49,15 +49,17 @@ include_guard(DIRECTORY)
|
||||
#
|
||||
# geant4_add_module(<name>
|
||||
# PUBLIC_HEADERS header1 [header2 ...]
|
||||
# PRIVATE_HEADERS header1 [header2 ..]
|
||||
# [SOURCES source1 [source2 ...]])
|
||||
#
|
||||
# Add a Geant4 module called ``<name>`` to the project, composed
|
||||
# of the source files listed in the ``PUBLIC_HEADERS`` and ``SOURCES``
|
||||
# arguments. The ``<name>`` must be unique within the project.
|
||||
# of the source files listed in the ``PUBLIC_HEADERS``, ``PRIVATE_HEADERS``,
|
||||
# and ``SOURCES`` arguments. The ``<name>`` must be unique within the project.
|
||||
# The directory in which the module is added (i.e. ``CMAKE_CURRENT_LIST_DIR``
|
||||
# for the CMake script in which ``geant4_add_module`` is called) must contain:
|
||||
#
|
||||
# * An ``include`` subdirectory for the public headers
|
||||
# * A ``include/private`` subdirectory for the private headers
|
||||
# * A ``src`` subdirectory for source files if the module provides these
|
||||
#
|
||||
# Any module with only ``PUBLIC_HEADERS`` has its ``IS_INTERFACE`` property
|
||||
@@ -69,6 +71,12 @@ include_guard(DIRECTORY)
|
||||
# this is interpreted as being relative to the ``include`` subdirectory of the module.
|
||||
# Absolute paths may also be supplied, e.g. if headers are generated by the project.
|
||||
#
|
||||
# The ``PRIVATE_HEADERS`` argument must list the headers comprising any
|
||||
# interfaces that are implementation details of the module. If a header is supplied
|
||||
# as a relative path, this is interpreted as being relative to the ``include/private``
|
||||
# subdirectory of the module. Absolute paths may also be supplied, e.g. if headers
|
||||
# are generated by the project.
|
||||
#
|
||||
# The ``SOURCES`` argument should list any source files for the module.
|
||||
# If a source is is supplied as a relative path, this is interpreted as being
|
||||
# relative to the ``src`` subdirectory of the module. Absolute paths may
|
||||
@@ -80,7 +88,7 @@ function(geant4_add_module _name)
|
||||
cmake_parse_arguments(G4ADDMOD
|
||||
""
|
||||
""
|
||||
"PUBLIC_HEADERS;SOURCES"
|
||||
"PUBLIC_HEADERS;PRIVATE_HEADERS;SOURCES"
|
||||
${ARGN}
|
||||
)
|
||||
__geant4_assert_no_unparsed_arguments(G4ADDMOD geant4_add_module)
|
||||
@@ -100,14 +108,20 @@ function(geant4_add_module _name)
|
||||
geant4_set_module_property(${_name} PROPERTY CMAKE_LIST_FILE "${CMAKE_CURRENT_LIST_FILE}")
|
||||
|
||||
# Compose header/source lists
|
||||
geant4_module_sources(${_name} PUBLIC_HEADERS ${G4ADDMOD_PUBLIC_HEADERS} SOURCES ${G4ADDMOD_SOURCES})
|
||||
geant4_module_sources(${_name}
|
||||
PUBLIC_HEADERS ${G4ADDMOD_PUBLIC_HEADERS}
|
||||
PRIVATE_HEADERS ${G4ADDMOD_PRIVATE_HEADERS}
|
||||
SOURCES ${G4ADDMOD_SOURCES})
|
||||
|
||||
# Set default usage requirements for this module, dependent on whether it is an INTERFACE or not
|
||||
# TODO: It's a hard error if a module is INTERFACE and has PRIVATE_HEADERS
|
||||
if(NOT G4ADDMOD_SOURCES)
|
||||
geant4_module_include_directories(${_name} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>)
|
||||
geant4_set_module_property(${_name} PROPERTY IS_INTERFACE TRUE)
|
||||
else()
|
||||
# Set the default include directory for this module
|
||||
# Private header inclusions are, for now, dealt with at the target level (until we require CMake >=3.18)
|
||||
# - See set_source_files_properties for details
|
||||
geant4_module_include_directories(${_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>)
|
||||
|
||||
# Some compile definitions are still transported via directory level
|
||||
@@ -131,6 +145,7 @@ endfunction()
|
||||
#
|
||||
# geant4_module_sources(<name>
|
||||
# PUBLIC_HEADERS header1 [header2 ...]
|
||||
# PRIVATE_HEADERS header1 [header2 ...]
|
||||
# [SOURCES source1 [source2 ...]])
|
||||
#
|
||||
# Append sources to a Geant4 module called ``<name>``, composed of the source
|
||||
@@ -146,7 +161,7 @@ function(geant4_module_sources _name)
|
||||
cmake_parse_arguments(G4MODSRCS
|
||||
""
|
||||
""
|
||||
"PUBLIC_HEADERS;SOURCES"
|
||||
"PUBLIC_HEADERS;PRIVATE_HEADERS;SOURCES"
|
||||
${ARGN}
|
||||
)
|
||||
__geant4_assert_no_unparsed_arguments(G4MODSRCS geant4_module_sources)
|
||||
@@ -169,6 +184,16 @@ function(geant4_module_sources _name)
|
||||
endforeach()
|
||||
geant4_set_module_property(${_name} APPEND PROPERTY PUBLIC_HEADERS ${__tmp_HEADERS})
|
||||
|
||||
set(__tmp_HEADERS)
|
||||
foreach(__elem ${G4MODSRCS_PRIVATE_HEADERS})
|
||||
if(IS_ABSOLUTE "${__elem}")
|
||||
list(APPEND __tmp_HEADERS "${__elem}")
|
||||
else()
|
||||
list(APPEND __tmp_HEADERS "${CMAKE_CURRENT_LIST_DIR}/include/private/${__elem}")
|
||||
endif()
|
||||
endforeach()
|
||||
geant4_set_module_property(${_name} APPEND PROPERTY PRIVATE_HEADERS ${__tmp_HEADERS})
|
||||
|
||||
set(__tmp_SOURCES)
|
||||
foreach(__elem ${G4MODSRCS_SOURCES})
|
||||
if(IS_ABSOLUTE "${__elem}")
|
||||
@@ -859,11 +884,12 @@ function(geant4_compose_targets)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# - For each module, write out files for
|
||||
# 1. module -> used modules adjacency list for detecting module-module cycles
|
||||
# - For each module
|
||||
# 1. Write out files for
|
||||
# 1.1. module -> used modules adjacency list for detecting module-module cycles
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/G4ModuleAdjacencyList.txt" "# Geant4 Module - Module Adjacencies\n")
|
||||
|
||||
# 2. module,location,public headers for developer query operations
|
||||
# 1.2. module,location,public headers for developer query operations
|
||||
# Basically need a dict of module : [headers, ...]
|
||||
# - Two main queries to run
|
||||
# - Given a module, what public headers does it provide?
|
||||
@@ -884,26 +910,51 @@ function(geant4_compose_targets)
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/G4ModuleInterfaceMap.csv" "")
|
||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/Modules/geant4_module_check.py" "${PROJECT_BINARY_DIR}/geant4_module_check.py" COPYONLY)
|
||||
|
||||
# 2. Check it does not link to a composed library composed of N>1 modules
|
||||
get_property(__g4definedlibraries GLOBAL PROPERTY GEANT4_DEFINED_CATEGORIES)
|
||||
set(__g4disallowedlinks ${__g4definedlibraries})
|
||||
list(REMOVE_ITEM __g4disallowedlinks ${__g4definedmodules})
|
||||
|
||||
foreach(__module ${__g4definedmodules})
|
||||
# Adjacency list - take all dependencies
|
||||
geant4_get_module_property(__publicdeps ${__module} PUBLIC_LINK_LIBRARIES)
|
||||
geant4_get_module_property(__privatedeps ${__module} PRIVATE_LINK_LIBRARIES)
|
||||
geant4_get_module_property(__interfacedeps ${__module} INTERFACE_LINK_LIBRARIES)
|
||||
|
||||
# 1.1 Adjacency list - take all dependencies
|
||||
set(__alldeps_l ${__publicdeps} ${__privatedeps} ${__interfacedeps})
|
||||
list(JOIN __alldeps_l " " __alldeps)
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/G4ModuleAdjacencyList.txt" "${__module} ${__alldeps}\n")
|
||||
|
||||
# 2. Module interfaces, needs CMAKE, PUBLIC_HEADER
|
||||
# 1.2 Module interfaces, needs CMAKE, PUBLIC_HEADER
|
||||
geant4_get_module_property(__listfile ${__module} CMAKE_LIST_FILE)
|
||||
geant4_get_module_property(__publichdrs ${__module} PUBLIC_HEADERS)
|
||||
geant4_get_module_property(__privatehdrs ${__module} PRIVATE_HEADERS)
|
||||
geant4_get_module_property(__srcs ${__module} SOURCES)
|
||||
geant4_get_module_property(__parent_target ${__module} PARENT_TARGET)
|
||||
get_filename_component(__listdir "${__listfile}" DIRECTORY)
|
||||
# Remove generated headers
|
||||
list(TRANSFORM __publichdrs REPLACE "^${PROJECT_BINARY_DIR}/.*$" "")
|
||||
list(TRANSFORM __publichdrs REPLACE "^/.*/" "")
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/G4ModuleInterfaceMap.csv" "${__module},${__listdir},${__publichdrs},${__publicdeps},${__privatedeps},${__interfacedeps},${__parent_target},${__gmc_build_settings}\n")
|
||||
list(TRANSFORM __privatehdrs REPLACE "^/.*/" "")
|
||||
list(TRANSFORM __srcs REPLACE "^/.*/" "")
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/G4ModuleInterfaceMap.csv" "${__module},${__listdir},${__publichdrs},${__privatehdrs},${__srcs},${__publicdeps},${__privatedeps},${__interfacedeps},${__parent_target},${__gmc_build_settings}\n")
|
||||
|
||||
# 2. Check for disallowed links in each link type
|
||||
foreach(__linktype IN ITEMS public private interface)
|
||||
foreach(__link ${__${__linktype}deps})
|
||||
if(__link IN_LIST __g4disallowedlinks)
|
||||
geant4_get_category_property(__linktothese ${__link} MODULES)
|
||||
string(REPLACE "${PROJECT_SOURCE_DIR}/" "" __badlistfile ${__listfile})
|
||||
message(FATAL_ERROR "Geant4 module '${__module}' has a ${__linktype} link to composed category '${__link}'."
|
||||
"It must link to one or more of its component modules instead:\n"
|
||||
"${__linktothese}\n"
|
||||
"in ${__badlistfile}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# Process all defined libraries
|
||||
get_property(__g4definedlibraries GLOBAL PROPERTY GEANT4_DEFINED_CATEGORIES)
|
||||
set(__g4builtlibraries)
|
||||
set(__g4public_headers)
|
||||
|
||||
@@ -1224,19 +1275,21 @@ function(__geant4_add_library _name _type)
|
||||
foreach(__g4mod ${__g4modules})
|
||||
# - Process sources...
|
||||
geant4_get_module_property(_headers ${__g4mod} PUBLIC_HEADERS)
|
||||
geant4_get_module_property(_headers_private ${__g4mod} PRIVATE_HEADERS)
|
||||
geant4_get_module_property(_srcs ${__g4mod} SOURCES)
|
||||
geant4_get_module_property(_cmakescript ${__g4mod} CMAKE_LIST_FILE)
|
||||
get_filename_component(_moddir "${_cmakescript}" DIRECTORY)
|
||||
|
||||
# - Group sources and scripts for IDEs
|
||||
# NB: Seemingly has to be done at same level we define target.
|
||||
# TODO: If lib name is same as mod name, don't group avoid extra
|
||||
# folder layer.
|
||||
source_group(${__g4mod}\\Headers FILES ${_headers})
|
||||
source_group(${__g4mod}\\Headers FILES ${_headers} ${_headers_private})
|
||||
source_group(${__g4mod}\\Sources FILES ${_srcs})
|
||||
source_group(${__g4mod} FILES ${_cmakescript})
|
||||
|
||||
# - Add sources to target - PRIVATE, because consuming targets don't need them
|
||||
target_sources(${_target_name} PRIVATE ${_headers} ${_srcs} ${_cmakescript})
|
||||
target_sources(${_target_name} PRIVATE ${_headers} ${_headers_private} ${_srcs} ${_cmakescript})
|
||||
|
||||
# - Process usage properties
|
||||
# Include dirs, compile definitions and libraries can be handled together
|
||||
@@ -1256,8 +1309,11 @@ function(__geant4_add_library _name _type)
|
||||
# declared its deps correctly (but then an error will occur
|
||||
# anyway, and point is that libs are linked, not modules!)
|
||||
# "Module" level really means "Source file" level, so same
|
||||
# sets of rules should apply (i.e. can't specify inc dirs
|
||||
# at source level).
|
||||
# sets of rules should apply.
|
||||
# Can use set_source_files_properties for module-level PRIVATE_HEADERS,
|
||||
# but that's it
|
||||
set_property(SOURCE ${_srcs} APPEND PROPERTY INCLUDE_DIRECTORIES "${_moddir}/include/private")
|
||||
|
||||
foreach(_prop ${_props_to_process})
|
||||
# Further gotcha with INTERFACE modules here
|
||||
# - If an interface module is composed into a non-interface module
|
||||
@@ -1306,7 +1362,7 @@ function(__geant4_add_library _name _type)
|
||||
# moc-ing, so hard code for now.
|
||||
# TODO: likely need an additional "module target properties" to hold things
|
||||
# that can be passed to set_target_properties
|
||||
if(__g4mod MATCHES "G4UIbasic|G4OpenGL|G4OpenInventor|G4ToolsSG" AND GEANT4_USE_QT)
|
||||
if(__g4mod MATCHES "G4UIimplementation|G4OpenGL|G4OpenInventor|G4ToolsSG" AND GEANT4_USE_QT)
|
||||
set_target_properties(${_target_name} PROPERTIES AUTOMOC ON)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
Reference in New Issue
Block a user