Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
+123 -25
View File
@@ -1,47 +1,145 @@
-------------------------------------------------------------------
# Category cmake History
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
Category History file
---------------------
-------------------------------------------------------------------------------
History file for Geant4 CMake build scripts.
It DOES NOT substitute the SVN log-message one should put at every
committal in the SVN repository !
## 2022-06-09 Igor Semeniouk (cmake-V11-00-32)
- G4ConfigureGNUMakeHelpers.cmake (geant4.[c]sh, geant4.bat generation )
- use the environment variable GEANT4_DATA_DIR as top data dir
- the environment variables for individual dataset commented in scripts
Entries MUST use the following format:
## 2022-06-07 Ben Morgan (cmake-V11-00-31)
- Rationalize interlinked PTL/TBB build options
## 2022-05-30 Guilherme Amadio (cmake-V11-00-30)
- Add options --sh and --csh to geant4-config script
MONTH DAY YEAR - INITIAL.SURNAME (TAG)
- FILECHANGED : Document changes made.
## 2022-05-18 Guilherme Amadio (cmake-V11-00-29)
- Use more standard install location for CMake files
- Remove version from default installation directories
- Add required configuration to be able to generate DEB/RPM packages with CPack
- OTHERFILECHANGED : Document changes made.
## 2022-05-16 Guilherme Amadio (cmake-V11-00-28)
- Add source validation exception for G4FindDataDir.hh generated header
## 2022-05-03 Ben Morgan (cmake-V11-00-27)
- Preliminary configuration support for Qt5 and Qt6
You should keep two lines between each date.
TAG is optional. If your changes fix a bug listed in the Geant4 Bugzilla,
add this in the documentation for the changed file as [BUGFIX #BUGNUMBER].
## 2022-04-27 Gunter Folger (cmake-V11-00-26)
- add new dataset G4NDL 4.7 with new TermalScattering data
## 2022-04-11 Ben Morgan (cmake-V11-00-25)
- Allow library composition to be overriden in developer builds
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
## 2022-04-11 Ben Morgan (cmake-V11-00-24)
- Do not use "readlink -f" to support pre-Monterey macOS systems
06 April 2022 - Ben Morgan (cmake-V10-07-56)
## 2022-04-08 Ben Morgan (cmake-V11-00-23)
- Add -Og to GNU/Clang default debug flags
## 2022-04-06 Ben Morgan (cmake-V11-00-22)
- Don't add CLHEP_INCLUDE_DIRS directly through include_directories to prevent potential
issues with it holding relative paths (reported by Seth Johnson)
7 March 2022 - Gunter Folger (cmake-V10-07-55)
## 2022-04-05 Ben Morgan (cmake-V11-00-21)
- Copy .clang-tidy file to build directory to assist run-clang-tidy reporting.
## 2022-04-04 Igor Semeniouk (cmake-V11-00-20)
- In G4ConfigurePkgConfigHelpers.cmake, geant4-config.in (geant4-config generation)
- new flag "--features", add vtk and qt3d feature
- allow use md5sun if openssl missing
- canonicalize prefix path
- In G4ConfigureGNUMakeHelpers.cmake (geant4.[c]sh, geant4.bat generation )
- allow full path source in zsh, sh
- unset local variables at the end
- introduced GEANT4_DATA_DIR, all DS path relative to this
## 2022-03-25 Ben Morgan (cmake-V11-00-19)
- Add commands for working with categories analagous to module commands
## 2022-03-28 Ben Morgan (cmake-V11-00-18)
- Remove retired G4tasking library from configuration files
## 2022-03-28 Ben Morgan (cmake-V11-00-17)
- Fix typo in G4DeveloperAPI that prevented install of headers
## 2022-03-25 Ben Morgan (cmake-V11-00-16)
- Do not use CMAKE_VERBOSE_MAKEFILE when building tests
## 2022-03-22 Ben Morgan (cmake-V11-00-15)
- Add geant4_module_sources command to enable appending of headers/sources
to a module after creation
## 2022-03-18 Ben Morgan (cmake-V11-00-14)
- Change default value of GEANT4_BUILD_BUILTIN_BACKTRACE to OFF
## 2022-03-15 Ben Morgan (cmake-V11-00-13)
- Rationalize declaration and use of internal builds of required externals CLHEP,
zlib, expat, PTL and tools libraries.
## 2022-03-10 Ben Morgan (cmake-V11-00-12)
- Remove deprecated functions in G4DeveloperAPI
- Support declaration and composition of header-only modules and libraries
## 2022-03-03 Ben Morgan (cmake-V11-00-11)
- Provide GEANT4_BUILD_ENABLE_ASSERTIONS option to enable assert() in all
release build modes (Release, RelWithDebInfo, MinSizeRel)
- Addresses GitLab Issue #104
- Forward `CMAKE_<LANG>_FLAGS[_<MODE>]` flags to `geant4_add_test` so that
a consistent set is used through the project.
## 2022-03-07 Gunter Folger (cmake-V11-00-10)
- fix in CMakeCPackOptions.cmake.in to avoid PATH with only /, without \, for g4_small.bmp
11 February 2022 - Ben Morgan (cmake-V10-07-54)
## 2022-02-11 Gunter Folger (cmake-V11-00-09)
- add new dataset G4EMLOW 8.1
## 2022-02-11 Igor Semeniouk (cmake-V11-00-08)
- Bug fix introduced in cmake-V11-00-06
- G4ConfigureGNUMakeHelpers.cmake - Fix for _g4tc_prepend_path on geant4.bat genaration ( Windows only)
- History - fix comment syntax
## 2022-02-11 Ben Morgan (cmake-V11-00-07)
- Apply [GitHub PR 37](https://github.com/Geant4/geant4/pull/37) from gondiaz.
- Add G4ptl and G4tasking libraries to link list in geant4-config
- Fixup: place G4tasking in correct location in dependency list
- Fixup: Update order of G4analysis for ALICE patch:
- https://github.com/alisw/geant4/commit/ee32bad38f5ccfac458869d8c546e0df474f5529
- Fixup: place G4tasking in correct location in dependency list
## 2022-02-11 Igor Semeniouk (cmake-V11-00-06)
- Bug fix in functions _g4tc_prepend_path, _g4tc_apppend_path on geant4.bat genaration ( Windows only)
## 2022-02-10 Igor Semeniouk (cmake-V11-00-05)
- In G4ConfigureGNUMakeHelpers.cmake
- not set LD_LIBRARY_PATH configuration on MacOS (Darwin)
- add paths to DLL into PATH on Windows
## 2022-02-08 Ben Morgan (cmake-V11-00-04)
- Enable ToolsSG and backends based on use of external libraries (Qt, X11, Xm, Win32)
- Backends made non-mutally exclusive
- Remove GEANT4_USE_TOOLSSG public CMake option
- Addresses #117
## 2022-02-06 Gabriele Cosmo (cmake-V11-00-03)
- Updated compilation flags for Intel icc/icx compilers.
## 2022-02-05 Gunter Folger (cmake-V11-00-02)
- Add icpx/icx compiler to G4ConfigureGNUMakeHelpers.cmake
## 2022-01-28 Ben Morgan (cmake-V11-00-01)
- Correct logic error in checking whether module is already composed
- **DEPRECATIONS**
- `geant4_define_module`
- `geant4_global_library_target`
- Implementation reduced to emitting a CMake warning message on what to replace with
## 2021-12-10 Ben Morgan (cmake-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
09 November 2021 - Ben Morgan (cmake-V10-07-53)
- Only configure public release contribution guide if present
+406 -296
View File
@@ -1,350 +1,460 @@
# Module for locating Intel's Threading Building Blocks (TBB).
# - Find ThreadingBuildingBlocks include dirs and libraries
# Use this module by invoking find_package with the form:
# find_package(TBB
# [REQUIRED] # Fail with error if TBB is not found
# ) #
# Once done, this will define
#
# Customizable variables:
# TBB_ROOT_DIR
# Specifies TBB's root directory.
# TBB_FOUND - system has TBB
# TBB_INCLUDE_DIRS - the TBB include directories
# TBB_LIBRARIES - TBB libraries to be lined, doesn't include malloc or
# malloc proxy
# TBB::tbb - imported target for the TBB library
#
# Read-only variables:
# TBB_FOUND
# Indicates whether the library has been found.
# TBB_VERSION_MAJOR - Major Product Version Number
# TBB_VERSION_MINOR - Minor Product Version Number
# TBB_INTERFACE_VERSION - Engineering Focused Version Number
# TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major interface version
# still supported. This uses the engineering
# focused interface version numbers.
#
# TBB_INCLUDE_DIRS
# Specifies TBB's include directory.
# TBB_MALLOC_FOUND - system has TBB malloc library
# TBB_MALLOC_INCLUDE_DIRS - the TBB malloc include directories
# TBB_MALLOC_LIBRARIES - The TBB malloc libraries to be lined
# TBB::malloc - imported target for the TBB malloc library
#
# TBB_LIBRARIES
# Specifies TBB libraries that should be passed to target_link_libararies.
#
# TBB_<COMPONENT>_LIBRARIES
# Specifies the libraries of a specific <COMPONENT>.
#
# TBB_<COMPONENT>_FOUND
# Indicates whether the specified <COMPONENT> was found.
# TBB_MALLOC_PROXY_FOUND - system has TBB malloc proxy library
# TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB malloc proxy include directories
# TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc proxy libraries to be lined
# TBB::malloc_proxy - imported target for the TBB malloc proxy library
#
#
# Copyright (c) 2012 Sergiu Dotenco
# This module reads hints about search locations from variables:
# ENV TBB_ARCH_PLATFORM - for eg. set it to "mic" for Xeon Phi builds
# ENV TBB_ROOT or just TBB_ROOT - root directory of tbb installation
# ENV TBB_BUILD_PREFIX - specifies the build prefix for user built tbb
# libraries. Should be specified with ENV TBB_ROOT
# and optionally...
# ENV TBB_BUILD_DIR - if build directory is different than ${TBB_ROOT}/build
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# Modified by Robert Maynard from the original OGRE source
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTTBBLAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
INCLUDE (FindPackageHandleStandardArgs)
#------------------------------------------------------------------------------#
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# Paths
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
#
#------------------------------------------------------------------------------#
IF(CMAKE_VERSION VERSION_GREATER 2.8.7)
SET(_TBB_CHECK_COMPONENTS ON)
ELSE()
SET(_TBB_CHECK_COMPONENTS OFF)
ENDIF()
FIND_PATH(TBB_ROOT_DIR
NAMES include/tbb/tbb.h
PATHS ENV TBBROOT
ENV TBB40_INSTALL_DIR
ENV TBB30_INSTALL_DIR
ENV TBB22_INSTALL_DIR
ENV TBB21_INSTALL_DIR
ENV TBB_ROOT_DIR
DOC "TBB root directory")
FIND_PATH(TBB_INCLUDE_DIR
NAMES tbb/tbb.h
HINTS ${TBB_ROOT_DIR}
PATH_SUFFIXES include
DOC "TBB include directory")
#------------------------------------------------------------------------------#
#=============================================================================
# Copyright 2010-2012 Kitware, Inc.
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
#
# Library suffixes
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file COPYING-CMAKE-SCRIPTS for details.
#
#------------------------------------------------------------------------------#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
IF(MSVC11)
SET(_TBB_COMPILER vc11)
ELSEIF(MSVC10)
SET(_TBB_COMPILER vc10)
ELSEIF(MSVC90)
SET(_TBB_COMPILER vc9)
ELSEIF(MSVC80)
SET(_TBB_COMPILER vc8)
ELSEIF(WIN32)
SET(_TBB_COMPILER vc_mt)
ENDIF(MSVC11)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(_TBB_POSSIBLE_LIB_SUFFIXES lib/intel64/${_TBB_COMPILER})
SET(_TBB_POSSIBLE_BIN_SUFFIXES bin/intel64/${_TBB_COMPILER})
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(_TBB_POSSIBLE_LIB_SUFFIXES lib/ia32/${_TBB_COMPILER})
SET(_TBB_POSSIBLE_BIN_SUFFIXES bin/ia32/${_TBB_COMPILER})
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
LIST(APPEND _TBB_POSSIBLE_LIB_SUFFIXES lib/$ENV{TBB_ARCH_PLATFORM})
IF(UNIX)
FOREACH(_VERSION 4.7 4.4 4.1)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
LIST(APPEND _TBB_POSSIBLE_LIB_SUFFIXES lib/intel64/gcc${_VERSION})
ELSE()
LIST(APPEND _TBB_POSSIBLE_LIB_SUFFIXES lib/ia32/gcc${_VERSION})
ENDIF()
ENDFOREACH()
ENDIF()
#------------------------------------------------------------------------------#
#=============================================================================
# FindTBB helper functions and macros
#
# TBB library
# Use TBBConfig.cmake if possible.
set(_tbb_find_quiet)
if (TBB_FIND_QUIETLY)
set(_tbb_find_quiet QUIET)
endif ()
set(_tbb_find_components)
set(_tbb_find_optional_components)
foreach (_tbb_find_component IN LISTS TBB_FIND_COMPONENTS)
if (TBB_FIND_REQUIRED_${_tbb_find_component})
list(APPEND _tbb_find_components "${_tbb_find_component}")
else ()
list(APPEND _tbb_find_optional_components "${_tbb_find_component}")
endif ()
endforeach ()
unset(_tbb_find_component)
find_package(TBB CONFIG ${_tbb_find_quiet}
COMPONENTS ${_tbb_find_components}
OPTIONAL_COMPONENTS ${_tbb_find_optional_components})
unset(_tbb_find_quiet)
unset(_tbb_find_components)
unset(_tbb_find_optional_components)
if (TBB_FOUND)
return ()
endif ()
#====================================================
# Fix the library path in case it is a linker script
#====================================================
function(tbb_extract_real_library library real_library)
if(NOT UNIX OR NOT EXISTS ${library})
set(${real_library} "${library}" PARENT_SCOPE)
return()
endif()
#Read in the first 4 bytes and see if they are the ELF magic number
set(_elf_magic "7f454c46")
file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX)
if(_hex_data STREQUAL _elf_magic)
#we have opened a elf binary so this is what
#we should link to
set(${real_library} "${library}" PARENT_SCOPE)
return()
endif()
file(READ ${library} _data OFFSET 0 LIMIT 1024)
if("${_data}" MATCHES "INPUT \\(([^(]+)\\)")
#extract out the .so name from REGEX MATCH command
set(_proper_so_name "${CMAKE_MATCH_1}")
#construct path to the real .so which is presumed to be in the same directory
#as the input file
get_filename_component(_so_dir "${library}" DIRECTORY)
set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE)
else()
#unable to determine what this library is so just hope everything works
#and pass it unmodified.
set(${real_library} "${library}" PARENT_SCOPE)
endif()
endfunction()
#===============================================
# Do the final processing for the package find.
#===============================================
macro(findpkg_finish PREFIX TARGET_NAME)
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
set(${PREFIX}_FOUND TRUE)
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
else ()
if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY)
message(FATAL_ERROR "Required library ${PREFIX} not found.")
endif ()
endif ()
if (NOT TARGET "TBB::${TARGET_NAME}")
if (${PREFIX}_LIBRARY_RELEASE)
tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release)
endif ()
if (${PREFIX}_LIBRARY_DEBUG)
tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug)
endif ()
add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED)
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}")
if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE)
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
IMPORTED_LOCATION "${real_release}"
IMPORTED_LOCATION_DEBUG "${real_debug}"
IMPORTED_LOCATION_RELEASE "${real_release}")
elseif (${PREFIX}_LIBRARY_RELEASE)
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
IMPORTED_LOCATION "${real_release}")
elseif (${PREFIX}_LIBRARY_DEBUG)
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
IMPORTED_LOCATION "${real_debug}")
endif ()
endif ()
#mark the following variables as internal variables
mark_as_advanced(${PREFIX}_INCLUDE_DIR
${PREFIX}_LIBRARY
${PREFIX}_LIBRARY_DEBUG
${PREFIX}_LIBRARY_RELEASE)
endmacro()
#===============================================
# Generate debug names from given release names
#===============================================
macro(get_debug_names PREFIX)
foreach(i ${${PREFIX}})
set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
endforeach()
endmacro()
#===============================================
# See if we have env vars to help us find tbb
#===============================================
macro(getenv_path VAR)
set(ENV_${VAR} $ENV{${VAR}})
# replace won't work if var is blank
if (ENV_${VAR})
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
endif ()
endmacro()
#===============================================
# Couple a set of release AND debug libraries
#===============================================
macro(make_library_set PREFIX)
if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG)
set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG})
elseif (${PREFIX}_RELEASE)
set(${PREFIX} ${${PREFIX}_RELEASE})
elseif (${PREFIX}_DEBUG)
set(${PREFIX} ${${PREFIX}_DEBUG})
endif ()
endmacro()
#=============================================================================
# Now to actually find TBB
#
#------------------------------------------------------------------------------#
FIND_LIBRARY(TBB_LIBRARY_RELEASE
NAMES tbb
HINTS ${TBB_ROOT_DIR}
PATH_SUFFIXES ${_TBB_POSSIBLE_LIB_SUFFIXES}
DOC "TBB release library")
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(TBB_ROOT)
FIND_LIBRARY(TBB_LIBRARY_DEBUG
NAMES tbb_debug
HINTS ${TBB_ROOT_DIR}
PATH_SUFFIXES ${_TBB_POSSIBLE_LIB_SUFFIXES}
DOC "TBB debug library")
IF(TBB_LIBRARY_RELEASE AND TBB_LIBRARY_DEBUG)
IF(NOT TBB_LIBRARY)
SET(TBB_LIBRARY optimized ${TBB_LIBRARY_RELEASE} debug ${TBB_LIBRARY_DEBUG}
CACHE DOC "TBB library" FORCE)
ENDIF(NOT TBB_LIBRARY)
LIST(APPEND _TBB_ALL_LIBS optimized ${TBB_LIBRARY_RELEASE} debug ${TBB_LIBRARY_DEBUG})
ELSE()
IF(TBB_LIBRARY_DEBUG)
IF(NOT TBB_LIBRARY)
SET(TBB_LIBRARY ${TBB_LIBRARY_DEBUG} CACHE FILEPATH "TBB library" FORCE)
ENDIF(NOT TBB_LIBRARY)
LIST(APPEND _TBB_ALL_LIBS ${TBB_LIBRARY_DEBUG})
ENDIF(TBB_LIBRARY_DEBUG)
IF(TBB_LIBRARY_RELEASE)
IF(NOT TBB_LIBRARY)
SET(TBB_LIBRARY ${TBB_LIBRARY_RELEASE} CACHE FILEPATH "TBB library" FORCE)
ENDIF(NOT TBB_LIBRARY)
LIST(APPEND _TBB_ALL_LIBS ${TBB_LIBRARY_RELEASE})
ENDIF()
ENDIF(TBB_LIBRARY_RELEASE AND TBB_LIBRARY_DEBUG)
# initialize search paths
set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT})
set(TBB_INC_SEARCH_PATH "")
set(TBB_LIB_SEARCH_PATH "")
#------------------------------------------------------------------------------#
#
# Components
#
#------------------------------------------------------------------------------#
# If user built from sources
set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX})
if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT)
getenv_path(TBB_BUILD_DIR)
if (NOT ENV_TBB_BUILD_DIR)
set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build)
endif ()
SET(_TBB_POSSIBLE_COMPONENTS preview malloc malloc_proxy)
# include directory under ${ENV_TBB_ROOT}/include
list(APPEND TBB_LIB_SEARCH_PATH
${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release
${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug)
endif ()
FOREACH(_TBB_COMPONENT ${TBB_FIND_COMPONENTS})
STRING(REPLACE "_debug" "" _TBB_COMPONENT ${_TBB_COMPONENT})
STRING(TOUPPER ${_TBB_COMPONENT} _TBB_COMPONENT_UPPER)
SET(_TBB_LIBRARY_BASE TBB_${_TBB_COMPONENT_UPPER}_LIBRARY)
# For Windows, let's assume that the user might be using the precompiled
# TBB packages from the main website. These use a rather awkward directory
# structure (at least for automatically finding the right files) depending
# on platform and compiler, but we'll do our best to accommodate it.
# Not adding the same effort for the precompiled linux builds, though. Those
# have different versions for CC compiler versions and linux kernels which
# will never adequately match the user's setup, so there is no feasible way
# to detect the "best" version to use. The user will have to manually
# select the right files. (Chances are the distributions are shipping their
# custom version of tbb, anyway, so the problem is probably nonexistent.)
if (WIN32 AND MSVC)
set(COMPILER_PREFIX "vc7.1")
if (MSVC_VERSION EQUAL 1400)
set(COMPILER_PREFIX "vc8")
elseif(MSVC_VERSION EQUAL 1500)
set(COMPILER_PREFIX "vc9")
elseif(MSVC_VERSION EQUAL 1600)
set(COMPILER_PREFIX "vc10")
elseif(MSVC_VERSION EQUAL 1700)
set(COMPILER_PREFIX "vc11")
elseif(MSVC_VERSION EQUAL 1800)
set(COMPILER_PREFIX "vc12")
elseif(MSVC_VERSION GREATER_EQUAL 1900)
set(COMPILER_PREFIX "vc14")
endif ()
IF(${_TBB_COMPONENT} MATCHES "malloc*")
SET(_TBB_LIBRARY_NAME tbb${_TBB_COMPONENT})
ELSE()
SET(_TBB_LIBRARY_NAME tbb_${_TBB_COMPONENT})
ENDIF()
# for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path
foreach (dir IN LISTS TBB_PREFIX_PATH)
if (CMAKE_CL_64)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX})
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX})
else ()
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX})
endif ()
endforeach ()
endif ()
FIND_LIBRARY(${_TBB_LIBRARY_BASE}_RELEASE
NAMES ${_TBB_LIBRARY_NAME}
HINTS ${TBB_ROOT_DIR}
PATH_SUFFIXES ${_TBB_POSSIBLE_LIB_SUFFIXES}
DOC "TBB ${_TBB_COMPONENT} release library")
# For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9)
# and above and AppleClang
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0)
set (USE_LIBCXX OFF)
cmake_policy(GET CMP0025 POLICY_VAR)
FIND_LIBRARY(${_TBB_LIBRARY_BASE}_DEBUG
NAMES ${_TBB_LIBRARY_NAME}_debug
HINTS ${TBB_ROOT_DIR}
PATH_SUFFIXES ${_TBB_POSSIBLE_LIB_SUFFIXES}
DOC "TBB ${_TBB_COMPONENT} debug library")
if (POLICY_VAR STREQUAL "NEW")
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set (USE_LIBCXX ON)
endif ()
else ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (USE_LIBCXX ON)
endif ()
endif ()
MARK_AS_ADVANCED (${_TBB_LIBRARY_BASE} ${_TBB_LIBRARY_BASE}_DEBUG)
if (USE_LIBCXX)
foreach (dir IN LISTS TBB_PREFIX_PATH)
list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib)
endforeach ()
endif ()
endif ()
# default assumption
SET(TBB_${_TBB_COMPONENT_UPPER}_FOUND ON)
SET(TBB_${_TBB_COMPONENT}_FOUND ON)
# check compiler ABI
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_PREFIX)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
list(APPEND COMPILER_PREFIX "gcc4.8")
endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
list(APPEND COMPILER_PREFIX "gcc4.7")
endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
list(APPEND COMPILER_PREFIX "gcc4.4")
endif()
list(APPEND COMPILER_PREFIX "gcc4.1")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(COMPILER_PREFIX)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) # Complete guess
list(APPEND COMPILER_PREFIX "gcc4.8")
endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
list(APPEND COMPILER_PREFIX "gcc4.7")
endif()
list(APPEND COMPILER_PREFIX "gcc4.4")
else() # Assume compatibility with 4.4 for other compilers
list(APPEND COMPILER_PREFIX "gcc4.4")
endif ()
IF(${_TBB_LIBRARY_BASE}_DEBUG AND ${_TBB_LIBRARY_BASE}_RELEASE)
SET(${_TBB_LIBRARY_BASE}
debug ${${_TBB_LIBRARY_BASE}_DEBUG}
optimized ${${_TBB_LIBRARY_BASE}_RELEASE} CACHE STRING
"TBB ${_TBB_COMPONENT} library")
LIST(APPEND _TBB_ALL_LIBS
optimized ${${_TBB_LIBRARY_BASE}_RELEASE}
debug ${${_TBB_LIBRARY_BASE}_DEBUG})
LIST(APPEND TBB_FOUND_COMPONENTS ${_TBB_LIBRARY_BASE} ${_TBB_LIBRARY_BASE}_debug)
SET(TBB_${_TBB_COMPONENT_UPPER}_LIBRARY ${${_TBB_LIBRARY_BASE}_RELEASE})
ELSEIF(${_TBB_LIBRARY_BASE}_DEBUG)
SET(${_TBB_LIBRARY_BASE} ${${_TBB_LIBRARY_BASE}_DEBUG})
LIST(APPEND _TBB_ALL_LIBS ${${_TBB_LIBRARY_BASE}_DEBUG})
LIST(APPEND TBB_FOUND_COMPONENTS ${_TBB_LIBRARY_BASE})
SET(TBB_${_TBB_COMPONENT_UPPER}_LIBRARY ${${_TBB_LIBRARY_BASE}_DEBUG})
ELSEIF(${_TBB_LIBRARY_BASE}_RELEASE)
SET(${_TBB_LIBRARY_BASE} ${${_TBB_LIBRARY_BASE}_RELEASE}
CACHE FILEPATH "TBB ${_TBB_COMPONENT} library")
LIST(APPEND _TBB_ALL_LIBS ${${_TBB_LIBRARY_BASE}_RELEASE})
LIST(APPEND TBB_FOUND_COMPONENTS ${_TBB_LIBRARY_BASE}_debug)
SET(TBB_${_TBB_COMPONENT_UPPER}_LIBRARY ${${_TBB_LIBRARY_BASE}_RELEASE})
ELSE()
# Component missing: record it for a later report
LIST(APPEND _TBB_MISSING_COMPONENTS ${_TBB_COMPONENT})
SET(TBB_${_TBB_COMPONENT}_FOUND OFF)
SET(TBB_${_TBB_COMPONENT_UPPER}_FOUND OFF)
ENDIF()
# if platform architecture is explicitly specified
set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM})
if (TBB_ARCH_PLATFORM)
foreach (dir IN LISTS TBB_PREFIX_PATH)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM})
endforeach ()
endif ()
IF(${_TBB_LIBRARY_BASE})
# setup the TBB_<COMPONENT>_LIBRARIES variable
SET(TBB_${_TBB_COMPONENT_UPPER}_LIBRARIES ${${_TBB_LIBRARY_BASE}})
ELSE()
LIST(APPEND _TBB_MISSING_LIBRARIES ${_TBB_LIBRARY_BASE})
ENDIF()
foreach (dir IN LISTS TBB_PREFIX_PATH)
foreach (prefix IN LISTS COMPILER_PREFIX)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix})
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib)
else ()
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix})
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib)
endif ()
endforeach()
endforeach ()
ENDFOREACH(_TBB_COMPONENT ${TBB_FIND_COMPONENTS})
# add general search paths
foreach (dir IN LISTS TBB_PREFIX_PATH)
list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb
${dir}/Libs)
list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include
${dir}/include/tbb)
endforeach ()
#------------------------------------------------------------------------------#
#
# Standard variables
#
#------------------------------------------------------------------------------#
IF(_TBB_ALL_LIBS)
SET(TBB_LIBRARIES ${_TBB_ALL_LIBS})
ENDIF()
set(TBB_LIBRARY_NAMES tbb)
get_debug_names(TBB_LIBRARY_NAMES)
IF(TBB_INCLUDE_DIR)
SET(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
ENDIF()
IF(DEFINED _TBB_MISSING_COMPONENTS AND _TBB_CHECK_COMPONENTS)
IF(NOT TBB_FIND_QUIETLY)
MESSAGE(STATUS "One or more TBB components were not found:")
# Display missing components indented, each on a separate line
FOREACH(_TBB_MISSING_COMPONENT ${_TBB_MISSING_COMPONENTS})
MESSAGE(STATUS " " ${_TBB_MISSING_COMPONENT})
ENDFOREACH(_TBB_MISSING_COMPONENT ${_TBB_MISSING_COMPONENTS})
ENDIF(NOT TBB_FIND_QUIETLY)
ENDIF(DEFINED _TBB_MISSING_COMPONENTS AND _TBB_CHECK_COMPONENTS)
find_path(TBB_INCLUDE_DIR
NAMES tbb/tbb.h
PATHS ${TBB_INC_SEARCH_PATH})
#------------------------------------------------------------------------------#
#
# Library's version
#
#------------------------------------------------------------------------------#
find_library(TBB_LIBRARY_RELEASE
NAMES ${TBB_LIBRARY_NAMES}
PATHS ${TBB_LIB_SEARCH_PATH})
find_library(TBB_LIBRARY_DEBUG
NAMES ${TBB_LIBRARY_NAMES_DEBUG}
PATHS ${TBB_LIB_SEARCH_PATH})
make_library_set(TBB_LIBRARY)
SET(_TBB_VERSION_HEADER ${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h)
findpkg_finish(TBB tbb)
IF(EXISTS ${_TBB_VERSION_HEADER})
FILE(READ ${_TBB_VERSION_HEADER} _TBB_VERSION_CONTENTS)
#if we haven't found TBB no point on going any further
if (NOT TBB_FOUND)
return()
endif ()
STRING(REGEX REPLACE ".*#define TBB_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
TBB_VERSION_MAJOR "${_TBB_VERSION_CONTENTS}")
STRING(REGEX REPLACE ".*#define TBB_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
TBB_VERSION_MINOR "${_TBB_VERSION_CONTENTS}")
#=============================================================================
# Look for TBB's malloc package
set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc)
get_debug_names(TBB_MALLOC_LIBRARY_NAMES)
SET(TBB_VERSION ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR})
SET(TBB_VERSION_COMPONENTS 2)
ENDIF()
find_path(TBB_MALLOC_INCLUDE_DIR
NAMES tbb/tbb.h
PATHS ${TBB_INC_SEARCH_PATH})
IF(WIN32)
FIND_PROGRAM(LIB_EXECUTABLE NAMES lib
HINTS
"$ENV{VS110COMNTOOLS}/../../VC/bin"
"$ENV{VS100COMNTOOLS}/../../VC/bin"
"$ENV{VS90COMNTOOLS}/../../VC/bin"
"$ENV{VS71COMNTOOLS}/../../VC/bin"
"$ENV{VS80COMNTOOLS}/../../VC/bin"
DOC "Library manager")
find_library(TBB_MALLOC_LIBRARY_RELEASE
NAMES ${TBB_MALLOC_LIBRARY_NAMES}
PATHS ${TBB_LIB_SEARCH_PATH})
find_library(TBB_MALLOC_LIBRARY_DEBUG
NAMES ${TBB_MALLOC_LIBRARY_NAMES_DEBUG}
PATHS ${TBB_LIB_SEARCH_PATH})
make_library_set(TBB_MALLOC_LIBRARY)
MARK_AS_ADVANCED (LIB_EXECUTABLE)
ENDIF()
findpkg_finish(TBB_MALLOC tbbmalloc)
MACRO(GET_LIB_REQUISITES LIB REQUISITES)
IF(LIB_EXECUTABLE)
GET_FILENAME_COMPONENT(_LIB_PATH ${LIB_EXECUTABLE} PATH)
#=============================================================================
# Look for TBB's malloc proxy package
set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy)
get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES)
IF(MSVC)
# Do not redirect the output
UNSET(ENV{VS_UNICODE_OUTPUT})
ENDIF()
find_path(TBB_MALLOC_PROXY_INCLUDE_DIR
NAMES tbb/tbbmalloc_proxy.h
PATHS ${TBB_INC_SEARCH_PATH})
EXECUTE_PROCESS(COMMAND ${LIB_EXECUTABLE} /nologo /list ${LIB}
WORKING_DIRECTORY ${_LIB_PATH}/../../Common7/IDE
OUTPUT_VARIABLE _LIB_OUTPUT ERROR_QUIET)
find_library(TBB_MALLOC_PROXY_LIBRARY_RELEASE
NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES}
PATHS ${TBB_LIB_SEARCH_PATH})
find_library(TBB_MALLOC_PROXY_LIBRARY_DEBUG
NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES_DEBUG}
PATHS ${TBB_LIB_SEARCH_PATH})
make_library_set(TBB_MALLOC_PROXY_LIBRARY)
STRING(REPLACE "\n" ";" "${REQUISITES}" "${_LIB_OUTPUT}")
LIST(REMOVE_DUPLICATES ${REQUISITES})
ENDIF()
ENDMACRO()
findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy)
IF(_TBB_ALL_LIBS)
# collect lib requisites using the lib tool
FOREACH(_TBB_COMPONENT ${_TBB_ALL_LIBS})
GET_LIB_REQUISITES(${_TBB_COMPONENT} _TBB_REQUISITES)
ENDFOREACH(_TBB_COMPONENT)
ENDIF()
IF(NOT TBB_BINARY_DIR)
SET(_TBB_UPDATE_BINARY_DIR ON)
ELSE()
SET(_TBB_UPDATE_BINARY_DIR OFF)
ENDIF()
#=============================================================================
#parse all the version numbers from tbb
if(NOT TBB_VERSION)
if (EXISTS "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h")
file(STRINGS
"${TBB_INCLUDE_DIR}/oneapi/tbb/version.h"
TBB_VERSION_CONTENTS
REGEX "VERSION")
else()
#only read the start of the file
file(STRINGS
"${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h"
TBB_VERSION_CONTENTS
REGEX "VERSION")
endif()
SET(_TBB_BINARY_DIR_HINTS ${_TBB_POSSIBLE_BIN_SUFFIXES})
string(REGEX REPLACE
".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}")
IF(_TBB_REQUISITES)
FIND_FILE(TBB_BINARY_DIR NAMES ${_TBB_REQUISITES}
HINTS ${TBB_ROOT_DIR}
PATH_SUFFIXES ${_TBB_BINARY_DIR_HINTS} NO_DEFAULT_PATH)
ENDIF()
string(REGEX REPLACE
".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}")
IF(TBB_BINARY_DIR AND _TBB_UPDATE_BINARY_DIR)
SET(_TBB_BINARY_DIR ${TBB_BINARY_DIR})
UNSET(TBB_BINARY_DIR CACHE)
string(REGEX REPLACE
".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
IF(_TBB_BINARY_DIR)
GET_FILENAME_COMPONENT(TBB_BINARY_DIR ${_TBB_BINARY_DIR} PATH)
ENDIF()
ENDIF()
string(REGEX REPLACE
".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1"
TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
SET(TBB_BINARY_DIR ${TBB_BINARY_DIR} CACHE PATH "TBB binary directory")
set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}")
MARK_AS_ADVANCED(TBB_INCLUDE_DIR TBB_LIBRARY TBB_LIBRARY_RELEASE
TBB_LIBRARY_DEBUG TBB_BINARY_DIR)
endif()
IF(NOT _TBB_CHECK_COMPONENTS)
SET(_TBB_FPHSA_ADDITIONAL_ARGS HANDLE_COMPONENTS)
ENDIF()
LIST(APPEND _TBB_FPHSA_ADDITIONAL_ARGS VERSION_VAR TBB_VERSION)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TBB
REQUIRED_VARS
TBB_ROOT_DIR
TBB_INCLUDE_DIR
TBB_LIBRARY
${_TBB_MISSING_LIBRARIES}
HANDLE_COMPONENTS
${_TBB_FPHSA_ADDITIONAL_ARGS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TBB
REQUIRED_VARS TBB_INCLUDE_DIR TBB_LIBRARY
VERSION_VAR TBB_VERSION)
+36 -1
View File
@@ -276,6 +276,41 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|.*Clang")
geant4_add_feature(GEANT4_BUILD_SANITIZER "Compiling/linking with sanitizer '${GEANT4_BUILD_SANITIZER}'")
endif()
endif()
#.rst:
# - ``GEANT4_BUILD_ENABLE_ASSERTIONS``
# - Build libraries with assertions enabled even in release build types (Release, RelWithDebInfo, MinSizeRel)
#
option(GEANT4_BUILD_ENABLE_ASSERTIONS "Enable assertions regardless of build mode" OFF)
geant4_add_feature(GEANT4_BUILD_ENABLE_ASSERTIONS "Compiling Geant4 with assertions enabled in all build types")
mark_as_advanced(GEANT4_BUILD_ENABLE_ASSERTIONS)
# "Dumb" strip of NDEBUG definition from build type flags
if(GEANT4_BUILD_ENABLE_ASSERTIONS)
foreach(__build_type Release MinSizeRel RelWithDebInfo)
string(TOUPPER ${__build_type} __build_type_uc)
foreach(__lang C CXX)
set(FLAGSET_TO_MODIFY "CMAKE_${__lang}_FLAGS_${__build_type_uc}")
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " new_flags "${${FLAGSET_TO_MODIFY}}")
set(${FLAGSET_TO_MODIFY} "${new_flags}")
endforeach()
endforeach()
endif()
# Copy .clang-tidy file to build dir
# - clang-tidy/run-clang-tidy state that by default:
#
# "clang-tidy will attempt to find a file named .clang-tidy for each source file in its parent directories."
#
# Whilst this does appear to be the case, `run-clang-tidy` will report enabled checks
# as the default set, or that of any .clang-tidy found in parent directories of the build dir
# To avoid confusion, copy .clang-tidy into build directory so that run-clang-tidy
# should report correctly
#
if(EXISTS "${PROJECT_SOURCE_DIR}/.clang-tidy")
configure_file("${PROJECT_SOURCE_DIR}/.clang-tidy" "${PROJECT_BINARY_DIR}/.clang-tidy" COPYONLY)
endif()
#-----------------------------------------------------------------------
# Multithreading
#-----------------------------------------------------------------------
@@ -380,7 +415,7 @@ mark_as_advanced(GEANT4_BUILD_VERBOSE_CODE)
if(UNIX)
option(GEANT4_BUILD_BUILTIN_BACKTRACE
"Enable automatic G4Backtrace signal handling in G4RunManager. Switch off for applications implementing their own signal handling"
ON)
OFF)
mark_as_advanced(GEANT4_BUILD_BUILTIN_BACKTRACE)
endif()
+2 -2
View File
@@ -138,8 +138,8 @@ set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH
"Read-only architecture-independent data root (share)")
set(CMAKE_INSTALL_DATADIR
"${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}" CACHE PATH
"Read-only architecture-independent data (DATAROOTDIR/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION})")
"${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}" CACHE PATH
"Read-only architecture-independent data (DATAROOTDIR/${PROJECT_NAME})")
#
# CMake's builtin `GNUInstallDirs` module is used to set and provide variables
-1
View File
@@ -42,7 +42,6 @@ endif()
#
# This module includes the following modules:
include(CMakeDependentOption)
include(Geant4MacroLibraryTargets)
#-----------------------------------------------------------------------
# CMAKE EXTENSIONS
+10 -1
View File
@@ -45,6 +45,7 @@ configure_file(LICENSE LICENSE.txt COPYONLY) # Suffix must be .txt
#
set(CPACK_PACKAGE_NAME "geant4")
set(CPACK_PACKAGE_VENDOR "Geant4 Collaboration")
set(CPACK_PACKAGE_CONTACT "Geant4 Collaboration <https://geant4.cern.ch/collaboration/contacts>")
set(CPACK_PACKAGE_VERSION ${Geant4_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${Geant4_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${Geant4_VERSION_MINOR})
@@ -54,6 +55,15 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Geant4-${Geant4_VERSION_MAJOR}.${Geant4_VER
set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/Templates/g4_small.bmp")
set(CPACK_PACKAGE_CHECKSUM "SHA256")
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_SECTION "science")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS TRUE)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "cmake, make, g++")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libexpat1-dev, libxerces-c-dev, zlib1g-dev")
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "")
# - Common Resource files
set(CPACK_RESOURCE_FILE_README "${PROJECT_BINARY_DIR}/README.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_BINARY_DIR}/LICENSE.txt")
@@ -127,7 +137,6 @@ list(APPEND CPACK_INSTALL_SCRIPTS "${CMAKE_CURRENT_BINARY_DIR}/source_package_ex
# Binary package common settings
#
set(CPACK_PACKAGE_RELOCATABLE ${CMAKE_INSTALL_IS_NONRELOCATABLE})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Geant4-${Geant4_VERSION_MAJOR}.${Geant4_VERSION_MINOR}")
if(WIN32)
set(CPACK_GENERATOR "NSIS;ZIP")
+1 -1
View File
@@ -225,7 +225,7 @@ configure_file(
# - Generate Install Tree Configuration Files
#-----------------------------------------------------------------------
# Set needed variables for the install tree
set(GEANT4_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION})
set(GEANT4_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
# Header path for install tree is dependent on whether we have a relocatable
# install.
+118 -49
View File
@@ -119,6 +119,8 @@ elseif(MSVC)
set(GEANT4_COMPILER "VC")
elseif(CMAKE_CXX_COMPILER MATCHES "icpc.*|icc.*")
set(GEANT4_COMPILER "icc")
elseif(CMAKE_CXX_COMPILER MATCHES "icpx.*|icx.*")
set(GEANT4_COMPILER "icx")
else()
set(GEANT4_COMPILER "UNSUPPORTED")
endif()
@@ -174,27 +176,31 @@ function(_g4tc_selflocate TEMPLATE_NAME SHELL_FAMILY SCRIPT_NAME LOCATION_VARIAB
if(${SHELL_FAMILY} STREQUAL "bourne")
set(${TEMPLATE_NAME}
"# Self locate script when sourced
if [ -z \"\$BASH_VERSION\" ]; then
# Not bash, so rely on sourcing from correct location
g4sls_sourced_dir=\$\(dirname \${BASH_SOURCE[0]:-$0}\)
if [ \"\${g4sls_sourced_dir}\" = \".\" ]; then
if [ ! -f ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ]; then
# Not bash, zsh or sh so rely on sourcing from correct location
echo 'ERROR: ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} could NOT self-locate Geant4 installation'
echo 'This is most likely because you are using ksh, zsh or similar'
echo 'This is most likely because you are using ksh, dash or similar'
echo 'To fix this issue, cd to the directory containing this script'
echo 'and source it in that directory.'
unset g4sls_sourced_dir
return 1
fi
${LOCATION_VARIABLE}=\$\(pwd\)
else
g4sls_sourced_dir=\$\(dirname \${BASH_ARGV[0]}\)
${LOCATION_VARIABLE}=$\(cd \$g4sls_sourced_dir > /dev/null ; pwd\)
fi
${LOCATION_VARIABLE}=$\(cd \$g4sls_sourced_dir > /dev/null ; pwd\)
"
PARENT_SCOPE
)
# For bourne shell, set the values of the guard variables
set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
set(GEANT4_TC_ENDIF_SELFLOCATED "" PARENT_SCOPE)
set(GEANT4_TC_ENDIF_SELFLOCATED "
# unset local variables
unset g4sls_sourced_dir
unset ${LOCATION_VARIABLE}
"
PARENT_SCOPE)
elseif(${SHELL_FAMILY} STREQUAL "cshell")
set(${TEMPLATE_NAME}
@@ -255,15 +261,21 @@ set ${LOCATION_VARIABLE}=\"`cd \${g4sls_sourced_dir} > /dev/null ; pwd`\"
# For C-shell, set the values of the guard variables
set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
set(GEANT4_TC_ENDIF_SELFLOCATED "" PARENT_SCOPE)
elseif(${SHELL_FAMILY} STREQUAL "cmd")
set(GEANT4_TC_ENDIF_SELFLOCATED "
# unset local variables
unset g4sls_sourced_dir
unset ${LOCATION_VARIABLE}
"
PARENT_SCOPE)
elseif(${SHELL_FAMILY} STREQUAL "cmd")
set(${TEMPLATE_NAME}
"set ${LOCATION_VARIABLE}=
rem Self locate script when sourced
for /F %%i in (\"%0\") do set BINDIR=%%~dpi
set BINDIR=%BINDIR:~0,-1%
set ${LOCATION_VARIABLE}=%BINDIR%
set \"BINDIR=%BINDIR:~0,-1%\"
set \"${LOCATION_VARIABLE}=%BINDIR%\"
rem unset temparary variable
set BINDIR=
"
@@ -271,7 +283,10 @@ set BINDIR=
)
# Set the values of the guard variables
set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
set(GEANT4_TC_ENDIF_SELFLOCATED "" PARENT_SCOPE)
set(GEANT4_TC_ENDIF_SELFLOCATED "
rem unset local variables
set ${LOCATION_VARIABLE}=
" PARENT_SCOPE)
endif()
endfunction()
@@ -293,7 +308,7 @@ function(_g4tc_setenv_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_
)
elseif(${SHELL_FAMILY} STREQUAL "cmd")
set(${TEMPLATE_NAME}
"set ${VARIABLE_NAME}=${VARIABLE_VALUE}"
"set \"${VARIABLE_NAME}=${VARIABLE_VALUE}\""
PARENT_SCOPE
)
endif()
@@ -334,7 +349,7 @@ endif
set(${TEMPLATE_NAME}
"
IF NOT DEFINED ${VARIABLE_NAME} (
set ${VARIABLE_NAME}=${VARIABLE_VALUE}
set \"${VARIABLE_NAME}=${VARIABLE_VALUE}\"
)
"
PARENT_SCOPE
@@ -378,12 +393,10 @@ endif
)
# -- cmd.exe block
elseif(${SHELL_FAMILY} STREQUAL "cmd")
# Assime verible name passed hire
file(TO_NATIVE_PATH ${APPEND_VARIABLE} APPEND_VARIABLE)
set(${TEMPLATE_NAME}
"
set ${PATH_VARIABLE}=%${APPEND_VARIABLE}%;%${PATH_VARIABLE}%
set ${APPEND_VARIABLE}=
set \"${PATH_VARIABLE}=${APPEND_VARIABLE};%${PATH_VARIABLE}%\"
"
PARENT_SCOPE
)
@@ -426,12 +439,10 @@ endif
)
# -- cmd.exe block
elseif(${SHELL_FAMILY} STREQUAL "cmd")
# Assime verible name passed hire
file(TO_NATIVE_PATH ${APPEND_VARIABLE} APPEND_VARIABLE)
set(${TEMPLATE_NAME}
"
set ${PATH_VARIABLE}=%${PATH_VARIABLE}%;%${APPEND_VARIABLE}%
set ${APPEND_VARIABLE}=
set \"${PATH_VARIABLE}=%${PATH_VARIABLE}%;${APPEND_VARIABLE}\"
"
PARENT_SCOPE
)
@@ -868,22 +879,26 @@ file(RELATIVE_PATH
# Resource Files
# - Data
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
geant4_get_dataset_property(${_ds} INSTALL_DIR ${_ds}_PATH)
if(NOT IS_ABSOLUTE ${${_ds}_PATH})
if(NOT IS_ABSOLUTE ${GEANT4_INSTALL_DATADIR})
file(RELATIVE_PATH
G4ENV_BINDIR_TO_DATADIR
${CMAKE_INSTALL_FULL_BINDIR}
${${_ds}_PATH}
${GEANT4_INSTALL_FULL_DATADIR}
)
set(${_ds}_PATH "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATADIR} > /dev/null \; pwd`\"")
set(GEANT4_DATA_DIR "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATADIR} > /dev/null \; pwd`\"")
file(TO_NATIVE_PATH ${G4ENV_BINDIR_TO_DATADIR} G4ENV_BINDIR_TO_DATADIR)
set(GEANT4_DATA_DIRW "\%geant4_envbindir\%\\${G4ENV_BINDIR_TO_DATADIR}")
else()
set(${_ds}_PATH "\"${${_ds}_PATH}\"")
set(GEANT4_DATA_DIR "\"${GEANT4_INSTALL_DATADIR}\"")
file(TO_NATIVE_PATH ${GEANT4_INSTALL_DATADIR} GEANT4_INSTALL_DATADIR)
set(GEANT4_DATA_DIRW "${GEANT4_INSTALL_DATADIR}")
endif()
endforeach()
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
geant4_get_dataset_property(${_ds} DIRECTORY ${_ds}_PATH)
endforeach()
# - Fonts
file(RELATIVE_PATH
@@ -899,6 +914,9 @@ if(WIN32)
list(APPEND shells_list cmd)
endif()
#os which use LD_LIBRARY_PATH
set(_oswithldpath Linux)
# - Configure for each shell
foreach(_shell IN LISTS shells_list)
# Setup the shell
@@ -923,7 +941,7 @@ foreach(_shell IN LISTS shells_list)
)
# Set library path, based on relative paths between bindir and libdir
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(${CMAKE_SYSTEM_NAME} IN_LIST _oswithldpath)
_g4tc_prepend_path(GEANT4_ENV_LIBPATH_SETUP
${_shell}
LD_LIBRARY_PATH
@@ -940,7 +958,7 @@ foreach(_shell IN LISTS shells_list)
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(${CMAKE_SYSTEM_NAME} IN_LIST _oswithldpath)
_g4tc_append_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP
${_shell}
LD_LIBRARY_PATH
@@ -956,7 +974,7 @@ foreach(_shell IN LISTS shells_list)
if(GEANT4_USE_GDML)
get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" REALPATH)
get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" DIRECTORY)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(${CMAKE_SYSTEM_NAME} IN_LIST _oswithldpath)
_g4tc_append_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP
${_shell}
LD_LIBRARY_PATH
@@ -967,12 +985,17 @@ foreach(_shell IN LISTS shells_list)
endif()
endif()
# - Set data paths
set(GEANT4_ENV_DATASETS )
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
_g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} ${${_ds}_PATH})
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
_g4tc_setenv_command(_dssetenvcmd ${_shell} GEANT4_DATA_DIR ${GEANT4_DATA_DIR})
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
set(_dssetenvcmd "
# - Variables for individual datasets
# Uncomment the line and edit the path to the dataset if installed in not standard location.")
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n\n")
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
_g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} "$GEANT4_DATA_DIR/${${_ds}_PATH}")
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}# ${_dssetenvcmd}\n")
endforeach()
# - Set Font Path
@@ -999,7 +1022,7 @@ foreach(_shell IN LISTS shells_list)
_g4tc_prepend_path(GEANT4_ENV_BINPATH_SETUP
${_shell}
PATH
"geant4_envbindir"
"%geant4_envbindir%"
)
## Set library path, based on relative paths between bindir and libdir
@@ -1013,21 +1036,67 @@ foreach(_shell IN LISTS shells_list)
# Third party lib paths
# - CLHEP, if system
set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "rem no configuration required")
set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "rem # - Builtin CLHEP used")
if(GEANT4_USE_SYSTEM_CLHEP)
# Handle granular vs singular cases
get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
_g4tc_append_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP
${_shell}
PATH
"${_CLHEP_LIB_DIR}"
)
else()
set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "rem # System CLHEP in use, no configuration required")
endif()
endif()
# - XercesC
set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "rem no configuration required")
set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "rem # GDML SUPPORT NOT AVAILABLE")
if(GEANT4_USE_GDML)
get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" REALPATH)
get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" DIRECTORY)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
_g4tc_append_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP
${_shell}
PATH
"${_XERCESC_LIB_DIR}"
)
else()
set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "rem # GDML Supported, no configuration of Xerces-C required")
endif()
endif()
# - Set data paths
set(GEANT4_ENV_DATASETS )
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
set(GEANT4_ENV_DATASETS )
_g4tc_setenv_command(_dssetenvcmd ${_shell} GEANT4_DATA_DIR ${GEANT4_DATA_DIRW})
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
set(_dssetenvcmd "FOR /F %%i IN ( \"%GEANT4_DATA_DIR%\" ) DO set \"GEANT4_DATA_DIR=%%~fi\"")
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n\n")
set(_dssetenvcmd "
rem - Variables for individual datasets
rem Uncomment the line and edit the path to the dataset if installed in not standard location.")
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n\n")
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
file(TO_NATIVE_PATH ${${_ds}_PATH} _native_path)
_g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} ${_native_path})
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
_g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} "%GEANT4_DATA_DIR%\\${_native_path}")
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}rem ${_dssetenvcmd}\n")
endforeach()
# - Set Font Path
set(GEANT4_ENV_TOOLS_FONT_PATH "rem no configuration required")
# ??? We need this variable ?
# ??? path to freetype2 library ???
set(GEANT4_ENV_TOOLS_FONT_PATH "rem # FREETYPE SUPPORT NOT AVAILABLE")
if(GEANT4_USE_FREETYPE)
_g4tc_append_path(GEANT4_ENV_TOOLS_FONT_PATH
${_shell}
TOOLS_FONT_PATH
"${TOOLS_FONT_PATH}"
)
endif()
configure_file(
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-bat-skeleton.in
@@ -261,6 +261,13 @@ if(NOT GEANT4_BUILD_GRANULAR_LIBS)
set(G4_BUILTWITH_QT "no")
endif()
# - QT3D
if(GEANT4_USE_QT3D)
set(G4_BUILTWITH_QT3D "yes")
else()
set(G4_BUILTWITH_QT3D "no")
endif()
# - Motif
if(GEANT4_USE_XM)
set(G4_BUILTWITH_MOTIF "yes")
@@ -292,6 +299,13 @@ if(NOT GEANT4_BUILD_GRANULAR_LIBS)
set(G4_BUILTWITH_INVENTOR "no")
endif()
# - VTK
if(GEANT4_USE_VTK)
set(G4_BUILTWITH_VTK "yes")
else()
set(G4_BUILTWITH_VTK "no")
endif()
# If we have a module that uses X11, We have to play with the X11
# paths to get a clean set suitable for inclusion
if(G4_CONFIG_NEEDS_X11)
+4 -4
View File
@@ -8,21 +8,21 @@
# - NDL
geant4_add_dataset(
NAME G4NDL
VERSION 4.6
VERSION 4.7
FILENAME G4NDL
EXTENSION tar.gz
ENVVAR G4NEUTRONHPDATA
MD5SUM d07e43499f607e01f2c1ce06d7a09f3e
MD5SUM b001a2091bf9392e6833830347672ea2
)
# - Low energy electromagnetics
geant4_add_dataset(
NAME G4EMLOW
VERSION 8.0
VERSION 8.1
FILENAME G4EMLOW
EXTENSION tar.gz
ENVVAR G4LEDATA
MD5SUM 6795805f39ac73a71333276756004d99
MD5SUM e4abc7d2cd73a2f6d19837e9bcce984a
)
# - Photon evaporation
File diff suppressed because it is too large Load Diff
+67 -67
View File
@@ -56,37 +56,15 @@ if(GEANT4_USE_INVENTOR_QT)
set(GEANT4_USE_INVENTOR ON)
endif()
# - ToolsSG/Xt/X11/Qt/Win
# Though this option has platform differences, we configure here because it can
# trigger the Qt requirement
if(WIN32)
set(_g4_toolssg_backends "OFF" "WIN32")
else()
# TODO: Difference between X11, XT?
set(_g4_toolssg_backends "OFF" "X11" "XT" "QT")
endif()
enum_option(GEANT4_USE_TOOLSSG
DOC "Build Geant4 ToolsSG Visualization Driver with Backend"
VALUES ${_g4_toolssg_backends}
)
geant4_add_feature(GEANT4_USE_TOOLSSG "Build ToolsSG Visualization Driver with backend '${GEANT4_USE_TOOLSSG}'")
foreach(_tsg_backend IN LISTS _g4_toolssg_backends)
set(GEANT4_USE_TOOLSSG_${_tsg_backend}_GLES OFF)
if(_tsg_backend STREQUAL GEANT4_USE_TOOLSSG)
set(GEANT4_USE_TOOLSSG_${_tsg_backend}_GLES ON)
endif()
endforeach()
# - Qt (may be required by Coin/ToolsSG driver)
# - Qt
# May be required by Coin driver
# Selection also enables ToolsSG driver
option(GEANT4_USE_QT "Build Geant4 with Qt support" OFF)
if((GEANT4_USE_INVENTOR_QT OR GEANT4_USE_TOOLSSG_QT_GLES) AND NOT GEANT4_USE_QT)
if(GEANT4_USE_INVENTOR_QT AND NOT GEANT4_USE_QT)
set(GEANT4_USE_QT ON CACHE BOOL "Build Geant4 with Qt support" FORCE)
message(STATUS "Forcing GEANT4_USE_QT to ON, required by Inventor/ToolsSG Driver(s)")
message(STATUS "Forcing GEANT4_USE_QT to ON, required by selection of GEANT4_USE_INVENTOR_QT as ON")
endif()
geant4_add_feature(GEANT4_USE_QT "Build Geant4 with Qt support")
set(GEANT4_USE_TOOLSSG_QT_GLES ${GEANT4_USE_QT})
# - Vtk
option(GEANT4_USE_VTK "Build Geant4 with VTK visualisation" OFF)
@@ -94,23 +72,26 @@ mark_as_advanced(GEANT4_USE_VTK)
if(GEANT4_USE_VTK)
find_package(VTK 8.2 REQUIRED)
endif()
geant4_add_feature(GEANT4_USE_VTK "Using VTK for visualisation (EXPERIMENTAL)")
# - Unix only
if(UNIX)
# - Motif UI/Vis (may be required by Coin Vis driver)
# - Motif UI/Vis
# May be required by Coin Vis driver
# Selection also enables ToolsSG driver Xt backend
option(GEANT4_USE_XM "Build Geant4 with Motif (X11) support" OFF)
if((GEANT4_USE_INVENTOR AND NOT GEANT4_USE_INVENTOR_QT)
AND NOT GEANT4_USE_XM)
set(GEANT4_USE_XM ON CACHE BOOL "Build Geant4 with Motif (X11) support" FORCE)
message(STATUS "Forcing GEANT4_USE_XM to ON, required by Inventor driver")
endif()
set(GEANT4_USE_TOOLSSG_XT_GLES ${GEANT4_USE_XM})
geant4_add_feature(GEANT4_USE_XM "Build Geant4 with Xm Support")
# OpenGL/X11 Vis Driver
# - OpenGL/X11 Vis Driver
# Selection also enables ToolsSG driver X11 backend
option(GEANT4_USE_OPENGL_X11 "Build Geant4 OpenGL driver with X11 support" OFF)
set(GEANT4_USE_TOOLSSG_X11_GLES ${GEANT4_USE_OPENGL_X11})
geant4_add_feature(GEANT4_USE_OPENGL_X11 "Build Geant4 OpenGL driver with X11 support")
# RayTracer driver with X11 support
@@ -120,10 +101,20 @@ endif()
# Windows only
if(WIN32)
option(GEANT4_USE_OPENGL_WIN32 "Build OpenGL driver with Win32 support")
option(GEANT4_USE_OPENGL_WIN32 "Build OpenGL driver with Win32 support" OFF)
set(GEANT4_USE_TOOLSSG_WINDOWS_GLES ${GEANT4_USE_OPENGL_WIN32})
geant4_add_feature(GEANT4_USE_OPENGL_WIN32 "Build OpenGL driver with Win32 support")
endif()
# Overall ToolsSG enable flag
set(GEANT4_USE_TOOLSSG OFF)
if(GEANT4_USE_TOOLSSG_QT_GLES
OR GEANT4_USE_TOOLSSG_XT_GLES
OR GEANT4_USE_TOOLSSG_X11_GLES
OR GEANT4_USE_TOOLSSG_WINDOWS_GLES)
set(GEANT4_USE_TOOLSSG ON)
endif()
#-----------------------------------------------------------------------
# Find dependencies
#
@@ -151,46 +142,61 @@ if(GEANT4_USE_INVENTOR)
endif()
endif()
# - Qt5
# - Qt5/6
if(GEANT4_USE_QT)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
set(QT_QTCORE_LIBRARY Qt5::Core Qt5::PrintSupport)
set(QT_QTGUI_LIBRARY Qt5::Gui Qt5::Widgets)
set(QT_OPENGL_LIBRARY Qt5::Gui Qt5::OpenGL)
set(QT_LIBRARIES Qt5::OpenGL Qt5::Gui Qt5::PrintSupport Qt5::Widgets)
get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
geant4_save_package_variables(Qt5 Qt5Core_DIR Qt5Gui_DIR Qt5Widgets_DIR Qt5OpenGL_DIR Qt5PrintSupport_DIR)
# Use versioned targets to support Qt5 < 5.15
# Once 5.15 is the minimum version, the "Qt${QT_VERSION_MAJOR}_..." variables can be dropped
# - https://doc.qt.io/qt-6/cmake-manual.html
find_package(QT NAMES Qt5 Qt6 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets OpenGL PrintSupport REQUIRED)
if(QT_VERSION_MAJOR VERSION_LESS 6)
get_target_property(QT_QMAKE_EXECUTABLE ${Qt${QT_VERSION_MAJOR}Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
else()
get_target_property(QT_QMAKE_EXECUTABLE Qt6::qmake IMPORTED_LOCATION)
endif()
geant4_save_package_variables(Qt${QT_VERSION_MAJOR}
Qt${QT_VERSION_MAJOR}Core_DIR
Qt${QT_VERSION_MAJOR}Gui_DIR
Qt${QT_VERSION_MAJOR}Widgets_DIR
Qt${QT_VERSION_MAJOR}OpenGL_DIR
Qt${QT_VERSION_MAJOR}PrintSupport_DIR)
geant4_add_feature(GEANT4_USE_QT "Build Geant4 with Qt${QT_VERSION_MAJOR} support")
# Qt3D is only supported on 5.15 and above, but always on if available
set(QT3D_MINIMUM_VERSION 5.15.0)
set(GEANT4_USE_QT3D OFF)
if(Qt5Core_VERSION GREATER_EQUAL QT3D_MINIMUM_VERSION)
find_package(Qt53DCore ${QT3D_MINIMUM_VERSION} QUIET)
find_package(Qt53DExtras ${QT3D_MINIMUM_VERSION} QUIET)
find_package(Qt53DRender ${QT3D_MINIMUM_VERSION} QUIET)
if(QT_VERSION GREATER_EQUAL QT3D_MINIMUM_VERSION)
find_package(Qt${QT_VERSION_MAJOR}3DCore ${QT_VERSION} EXACT QUIET)
find_package(Qt${QT_VERSION_MAJOR}3DExtras ${QT_VERSION} EXACT QUIET)
find_package(Qt${QT_VERSION_MAJOR}3DRender ${QT_VERSION} EXACT QUIET)
if(Qt53DCore_FOUND AND Qt53DExtras_FOUND AND Qt53DRender_FOUND)
# Forward correct minimum version to CMake/etc files
set(QT3D_MINIMUM_VERSION ${QT_VERSION})
if(Qt${QT_VERSION_MAJOR}3DCore_FOUND AND Qt${QT_VERSION_MAJOR}3DExtras_FOUND AND Qt${QT_VERSION_MAJOR}3DRender_FOUND)
set(GEANT4_USE_QT3D ON)
geant4_save_package_variables(Qt5 Qt53DCore_DIR Qt53DExtras_DIR Qt53DRender_DIR)
geant4_save_package_variables(Qt${QT_VERSION_MAJOR}
Qt${QT_VERSION_MAJOR}3DCore_DIR
Qt${QT_VERSION_MAJOR}3DExtras_DIR
Qt${QT_VERSION_MAJOR}3DRender_DIR)
geant4_add_feature(GEANT4_USE_QT3D "Build Geant4 Qt3D driver")
else()
set(_g4_qt53d_missing)
if(NOT Qt53DCore_FOUND)
list(APPEND _g4_qt53d_missing "Qt53DCore")
set(_g4_qt3d_missing)
if(NOT Qt${QT_VERSION_MAJOR}3DCore_FOUND)
list(APPEND _g4_qt3d_missing "Qt${QT_VERSION_MAJOR}3DCore")
endif()
if(NOT Qt53DExtras_FOUND)
list(APPEND _g4_qt53d_missing "Qt53DExtras")
if(NOT Qt${QT_VERSION_MAJOR}3DExtras_FOUND)
list(APPEND _g4_qt3d_missing "Qt${QT_VERSION_MAJOR}3DExtras")
endif()
if(NOT Qt53DRender_FOUND)
list(APPEND _g4_qt53d_missing "Qt53DRender")
if(NOT Qt${QT_VERSION_MAJOR}3DRender_FOUND)
list(APPEND _g4_qt3d_missing "Qt${QT_VERSION_MAJOR}3DRender")
endif()
message(STATUS "Disabling Geant4 Qt3D driver, missing Qt5 packages: ${_g4_qt53d_missing}")
message(STATUS "Disabling Geant4 Qt3D driver, missing Qt packages: ${_g4_qt3d_missing}")
endif()
endif()
# Variables for export to GNUmake
@@ -203,7 +209,6 @@ if(GEANT4_USE_INVENTOR
OR GEANT4_USE_QT
OR GEANT4_USE_OPENGL_X11
OR GEANT4_USE_XM
OR GEANT4_USE_TOOLSSG
OR GEANT4_USE_OPENGL_WIN32)
find_package(OpenGL REQUIRED)
geant4_save_package_variables(OpenGL OPENGL_INCLUDE_DIR OPENGL_gl_LIBRARY)
@@ -212,9 +217,7 @@ if(GEANT4_USE_INVENTOR
if(APPLE AND
(GEANT4_USE_INVENTOR_XT
OR GEANT4_USE_OPENGL_X11
OR GEANT4_USE_XM
OR GEANT4_USE_TOOLSSG_X11_GLES
OR GEANT4_USE_TOOLSSG_XT_GLES))
OR GEANT4_USE_XM))
find_package(XQuartzGL REQUIRED)
geant4_save_package_variables(XQuartzGL XQuartzGL_INCLUDE_DIR XQuartzGL_gl_LIBRARY)
endif()
@@ -233,9 +236,7 @@ if(UNIX)
if(GEANT4_USE_OPENGL_X11
OR GEANT4_USE_RAYTRACER_X11
OR GEANT4_USE_XM
OR GEANT4_USE_INVENTOR_XT
OR GEANT4_USE_TOOLSSG_X11_GLES
OR GEANT4_USE_TOOLSSG_XT_GLES)
OR GEANT4_USE_INVENTOR_XT)
find_package(X11 REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/G4X11Shim.cmake")
@@ -270,4 +271,3 @@ if(UNIX)
geant4_save_package_variables(Motif MOTIF_INCLUDE_DIR MOTIF_LIBRARIES)
endif()
endif()
+14 -61
View File
@@ -32,20 +32,18 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(CMAKE_CXX_FLAGS_INIT "-W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow")
# Use pipes rather than temp files
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -pipe")
# Additional per-mode flags
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
# Assist auto-vectorization
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -fno-trapping-math -ftree-vectorize -fno-math-errno")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g")
# Remove superfluous "unused argument" and "GL deprecation" "warnings" from Clang
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -Qunused-arguments -DGL_SILENCE_DEPRECATION")
endif()
# Additional per-mode flags
# Assist auto-vectorization in Release
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -fno-trapping-math -ftree-vectorize -fno-math-errno")
# Use Debug-safe optimization
set(CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT} -Og")
# Extra Geant4 modes
# - Debug_FPE: Core Debug mode plus FPE)
set(CMAKE_CXX_FLAGS_DEBUG_FPE_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT} -DG4FPE_DEBUG")
@@ -61,7 +59,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(GEANT4_MULTITHREADED_CXX_FLAGS "-pthread")
endif()
#-----------------------------------------------------------------------
# MSVC - all (?) versions
if(MSVC)
@@ -71,7 +68,7 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-MDd -Od -Zi")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-MD -Ox -DNDEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-MD -Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-MD -O2 -Zi")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-MD -O2 -Zi -DNDEBUG")
# Extra modes
set(CMAKE_CXX_FLAGS_TESTRELEASE_INIT "-MDd -Zi -G4DEBUG_VERBOSE")
@@ -83,11 +80,15 @@ endif()
#
# Sufficient id on all platforms?
if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(CMAKE_CXX_FLAGS_INIT "-w1 -Wno-non-virtual-dtor -Wpointer-arith -Wwrite-strings -fp-model precise")
# Warnings
set(CMAKE_CXX_FLAGS_INIT "-W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -fp-model precise")
# Use pipes rather than temp files
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -pipe")
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
# Extra modes
set(CMAKE_CXX_FLAGS_TESTRELEASE_INIT "-g -G4DEBUG_VERBOSE")
@@ -100,51 +101,3 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
# Linker flags
set(CMAKE_EXE_LINKER_FLAGS "-limf")
endif()
#-----------------------------------------------------------------------
# Ye Olde *NIX/Compiler Systems
# NB: *NOT* Supported... Only provided as legacy.
# None are tested...
# Whilst these use flags taken from existing Geant4 setup, may want to see if
# CMake defaults on these platforms are good enough...
#
if(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX)
#---------------------------------------------------------------------
# IBM xlC compiler
#
if(CMAKE_CXX_COMPILER MATCHES "xlC")
set(CMAKE_CXX_FLAGS_INIT "")
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g -qdbextra -qcheck=all -qfullpath -qtwolink -+")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -qtwolink -+")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3 -qtwolink -+")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O3 -g -qdbextra -qcheck=all -qfullpath -qtwolink -+")
endif()
#---------------------------------------------------------------------
# HP aC++ Compiler
#
if(CMAKE_CXX_COMPILER MATCHES "aCC")
set(CMAKE_CXX_FLAGS_INIT "+DAportable +W823")
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "+O2 +Onolimit")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O2 +Onolimit")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 +Onolimit -g")
endif()
#---------------------------------------------------------------------
# IRIX MIPSpro CC Compiler
#
if(CMAKE_CXX_COMPILER MATCHES "CC" AND CMAKE_SYSTEM_NAME MATCHES "IRIX")
set(CMAKE_CXX_FLAGS_INIT "-ptused -DSOCKET_IRIX_SOLARIS")
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O -OPT:Olimit=5000")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O -OPT:Olimit=5000")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O -OPT:Olimit=5000 -g")
endif()
#---------------------------------------------------------------------
# SunOS CC Compiler
# - CMake may do a reasonable job on its own here...
endif()
+23 -25
View File
@@ -56,7 +56,6 @@ geant4_add_feature(GEANT4_USE_SYSTEM_CLHEP "Using system CLHEP library")
# to the internal location of expat headers and library target so Geant4
# clients of expat have a consistent interface.
#
# KNOWNISSUE : For internal expat, how to deal with static and shared?
if(WIN32)
set(EXPAT_FOUND TRUE)
set(GEANT4_USE_BUILTIN_EXPAT TRUE)
@@ -117,40 +116,39 @@ endif()
geant4_add_feature(GEANT4_USE_SYSTEM_ZLIB "Using system zlib library")
#-----------------------------------------------------------------------
# TBB support
#
set(_default_use_tbb OFF)
if(TBB_DIR)
set(_default_use_tbb ON)
endif()
# Find required PTL, optional TBB support, defaulting to internal
option(GEANT4_USE_SYSTEM_PTL "Use system PTL library" OFF)
option(GEANT4_USE_TBB "Use TBB as PTL's tasking backend" OFF)
cmake_dependent_option(GEANT4_USE_PTL_LOCKS "Enable mutex locking in PTL task subqueues" OFF "NOT GEANT4_USE_SYSTEM_PTL" OFF)
mark_as_advanced(GEANT4_USE_SYSTEM_PTL GEANT4_USE_PTL_LOCKS GEANT4_USE_TBB)
option(GEANT4_USE_TBB "Enable (optional) use of TBB as a tasking backend" ${_default_use_tbb})
if(GEANT4_USE_TBB)
find_package(TBB REQUIRED)
geant4_save_package_variables(TBB TBB_INCLUDE_DIR TBB_LIBRARY TBB_LIBRARY_DEBUG TBB_LIBRARY_RELEASE TBB_ROOT_DIR)
endif()
geant4_add_feature(GEANT4_USE_TBB "Enable (optional) use of TBB as a tasking backend")
#-----------------------------------------------------------------------
# Find required PTL package, defaulting to internal
option(GEANT4_USE_SYSTEM_PTL "Use system zlib library" OFF)
if(GEANT4_USE_SYSTEM_PTL)
find_package(PTL 2.0.0 REQUIRED)
# Backward compatibility for sources.cmake using the variable
if(GEANT4_USE_TBB)
find_package(PTL 2.0.0 REQUIRED TBB)
else()
find_package(PTL 2.0.0 REQUIRED)
if(PTL_TBB_FOUND AND NOT GEANT4_USE_TBB)
set(GEANT4_USE_TBB ON CACHE BOOL "Use TBB as PTL's tasking backend (forced)" FORCE)
message(STATUS "Forcing GEANT4_USE_TBB to ON, required by system PTL: ${PTL_DIR}")
endif()
endif()
set(PTL_LIBRARIES PTL::ptl)
geant4_save_package_variables(PTL PTL_DIR)
else()
# Prempt PTL's find of TBB so we can cache the variables
if(GEANT4_USE_TBB)
find_package(TBB REQUIRED)
endif()
set(PTL_FOUND TRUE)
set(GEANT4_USE_BUILTIN_PTL TRUE)
set(PTL_LIBRARIES G4ptl)
endif()
mark_as_advanced(GEANT4_USE_SYSTEM_PTL)
geant4_add_feature(GEANT4_USE_SYSTEM_PTL "Using system PTL library")
# Internal PTL offers adding locks in task queues to help debugging
cmake_dependent_option(GEANT4_USE_PTL_LOCKS "Enable mutex locking in PTL task subqueues" OFF "NOT GEANT4_USE_SYSTEM_PTL" OFF)
mark_as_advanced(GEANT4_USE_PTL_LOCKS)
geant4_add_feature(GEANT4_USE_SYSTEM_PTL "Using system PTL library")
geant4_add_feature(GEANT4_USE_PTL_LOCKS "Enabled mutex locking in PTL task subqueues")
geant4_add_feature(GEANT4_USE_TBB "Using TBB as PTL's tasking backend")
# Always cache TBB even if not used. Empty vars will not be exported.
geant4_save_package_variables(TBB TBB_DIR TBB_INCLUDE_DIR TBB_LIBRARY TBB_LIBRARY_DEBUG TBB_LIBRARY_RELEASE)
#-----------------------------------------------------------------------
# Optional Support for GDML - requires Xerces-C package
+11 -13
View File
@@ -1,18 +1,16 @@
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
# Category cmake-modules History
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarise all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
## 2021-12-10 Ben Morgan (cmake-modules-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
24th May 2011 Ben Morgan
- *** All History MUST be reported in the main CMake Category History file ***
+302
View File
@@ -0,0 +1,302 @@
#!/usr/bin/env python3
"""Check Geant4 source code modules
Geant4 organises source code into "Modules", with each Module being a
directory containing headers and sources in `include/` and `src/`
subdirectories respectively. One or more Modules are grouped/compiled
into the actual libraries.
This program can be used to query Modules as declared to the build system to:
- List all declared modules
- Print the list of public headers provided by a module
- Print modules required by a module based on inclusion of headers
- Check consistency between declared dependencies of a module and
those its sources actually use via inclusion of headers
- Check for cycles in the graph of declared module dependencies
"""
import argparse
import csv
import os
import sys
import re
import json
import graphlib
def initdb(filename):
db = {}
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
db[row[0]] = {'location': row[1],
'headers': set(row[2].split(';')) - set(['']),
'public_deps': set(row[3].split(';')) - set(['']),
'private_deps': set(row[4].split(';')) - set(['']),
'interface_deps': set(row[5].split(';')) - set([''])}
return db
def scan_includes(input_file):
result = set()
lines = open(input_file).readlines()
for line in lines:
m = re.search("^ *# *include *\"(.*)\"", line)
if m:
result.add(m.group(1))
return result
def scan_files(input_path):
used_headers = set()
with os.scandir(input_path) as hdr_it:
for entry in hdr_it:
used_headers |= scan_includes(entry.path)
return used_headers
def find_modules(list_of_headers, module_db):
found_modules = set()
orphan_hdrs = set()
for h in list_of_headers:
ms = [k for k, v in module_db.items() if h in v['headers']]
found_modules |= set(ms)
if not ms:
orphan_hdrs.add(h)
return {'modules': found_modules, 'headers': orphan_hdrs}
def usage_requirements(module_name, module_db):
""" Find modules needed publically and privately by input module
"""
module_path = module_db[module_name]['location']
module_headers = module_db[module_name]['headers']
# Determine public usage reqs
includes_from_headers = scan_files(os.path.join(module_path, "include"))
includes_from_headers -= module_headers
public_deps = find_modules(includes_from_headers, module_db)
# The same for private
includes_from_srcs = scan_files(os.path.join(module_path, "src"))
includes_from_srcs -= module_headers
private_deps = find_modules(includes_from_srcs, module_db)
# Public deps are higher priority
private_deps['modules'] -= public_deps['modules']
private_deps['headers'] -= public_deps['headers']
# Transform results to output dict
d = {'module': module_name,
'dependencies': {
'public': sorted(public_deps['modules']),
'private': sorted(private_deps['modules'])
},
'external_headers': {
'public': sorted(public_deps['headers']),
'private': sorted(private_deps['headers'])
}
}
return d
def check_consistency(module_name, module_db):
""" Check module declared/apparent dependencies for consistency
"""
# NB: Can have false positives from externals G4expat, G4clhep, G4zlib, G4tools (plus imported :: targets)
def filter_dependencies(dep_list):
return set([x for x in dep_list if not re.match("^.+::.+", x)]) - set(['G4expat', 'G4clhep', 'G4zlib', 'G4tools', 'G4ptl'])
ur = usage_requirements(module_name, module_db)
apparent_public_deps = filter_dependencies(ur['dependencies']['public'])
apparent_private_deps = filter_dependencies(ur['dependencies']['private'])
declared_public_deps = filter_dependencies(
module_db[module_name]['public_deps'])
declared_private_deps = filter_dependencies(
module_db[module_name]['private_deps'])
# Collate any consistency errors
report = []
# - Declared dependencies duplicated between public/private
# Later checks will help distinguish what to do with this
duplicated_deps = declared_public_deps & declared_private_deps
if duplicated_deps:
report.append(
f'- has duplicated PUBLIC/PRIVATE dependencies: {duplicated_deps}')
# - Apparent dep not declared
missing_public_deps = apparent_public_deps - declared_public_deps
if missing_public_deps:
report.append(
f'- may require PUBLIC dependencies: {missing_public_deps}')
missing_private_deps = apparent_private_deps - declared_private_deps
if missing_private_deps:
report.append(
f'- may require PRIVATE dependencies: {missing_private_deps}')
# - Declared dep not in apparent (overdeclared)
overdeclared_public_deps = declared_public_deps - apparent_public_deps
if overdeclared_public_deps:
report.append(
f'- may not require PUBLIC dependencies: {overdeclared_public_deps}')
overdeclared_private_deps = declared_private_deps - apparent_private_deps
if overdeclared_private_deps:
report.append(
f'- may not require PRIVATE dependencies: {overdeclared_private_deps}')
return report
def find_cycles(module_db, verbose):
""" Check for any cycles in the complete module dependency graph
"""
# Build adjacency list
adjlist = {}
for k, v in module_db.items():
adjlist[k] = list(v['public_deps'] | v['private_deps']
| v['interface_deps'])
try:
# Topo sort throws cycle error if one occurs during prepare
ts = graphlib.TopologicalSorter(adjlist)
ts.prepare()
# Verbose print of nodes in topological order
# NB: This uses the full graphlib interface in case we want to
# print out nodes grouped by level in the graph.
if verbose:
generation = 0
while ts.is_active():
nodes = ts.get_ready()
print(f'Generation: {generation}')
for n in nodes:
print(f' {n}')
ts.done(*nodes)
generation += 1
print(f"pass: No cycles detected in module dependency graph")
except graphlib.CycleError as err:
print(
f"error: cycles detected in module dependency graph",
file=sys.stderr,
)
cycle = " <- ".join(err.args[1])
print(f"cycle: {cycle}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
# Parse command line to get command to run
parser = argparse.ArgumentParser(
description=str(__doc__), formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("-db", default='G4ModuleInterfaceMap.csv',
metavar="FILE", help="module interface map file")
parser.add_argument("-v", "--verbose",
action="store_true", help="verbose output")
query_group = parser.add_mutually_exclusive_group(required=True)
query_group.add_argument(
"-l", "--list",
action='store_true',
help="list declared source code modules"
)
query_group.add_argument(
"-i", "--interface",
metavar="<module>",
help="print public headers of module",
)
query_group.add_argument(
"-p", "--provides",
metavar="<header>",
help="print module that provides this header"
)
query_group.add_argument(
"-u", "--usage-requirements",
metavar="<module>",
help="determine and print usage requirements of module"
)
query_group.add_argument(
"-c", "--check-consistency",
metavar="<module>",
help="check declared and apparent module dependencies for basic consistency"
)
query_group.add_argument(
"--find-cycles",
action="store_true",
help="find cycles in graph of declared modules dependencies"
)
query_group.add_argument(
"--find-inconsistencies",
action="store_true",
help="find inconsistencies in apparent/declared dependencies of all modules"
)
args = parser.parse_args()
# Initialize the module/header "database"
try:
db = initdb(args.db)
except OSError as err:
print(f"Could not initalize module DB: {err}", file=sys.stderr)
sys.exit(1)
# Implementations
if args.list:
print("\n".join(db.keys()))
elif args.interface:
try:
print("\n".join(db[args.interface]['headers']))
except KeyError as err:
print(f"No module named {err}", file=sys.stderr)
sys.exit(1)
elif args.provides:
# find the header, there should not be duplicates!
mods = [k for k, v in db.items() if args.provides in v['headers']]
if len(mods) == 0:
print(
f"No module provides header '{args.provides}'",
file=sys.stderr)
sys.exit(1)
if len(mods) > 1:
print(
f"Header '{args.provides}' is provided by multiple modules: {mods}",
file=sys.stderr)
sys.exit(1)
print(mods[0])
elif args.usage_requirements:
ur = usage_requirements(args.usage_requirements, db)
print(json.dumps(ur, indent=2))
elif args.check_consistency:
cc = check_consistency(args.check_consistency, db)
if cc:
print(f'{args.check_consistency}:', file=sys.stderr)
print("\n".join(cc), file=sys.stderr)
sys.exit(1)
else:
print(
f'{args.check_consistency} appears consistent')
elif args.find_cycles:
find_cycles(db, args.verbose)
elif args.find_inconsistencies:
inconsistent = {}
for m in db.keys():
cc = check_consistency(m, db)
if cc:
inconsistent[m] = "\n".join(cc)
if len(inconsistent) > 0:
print(f'Inconsistent dependencies in modules:', file=sys.stderr)
for k, v in inconsistent.items():
print(f'{k}:\n{v}', file=sys.stderr)
sys.exit(1)
+22 -21
View File
@@ -80,7 +80,7 @@
# ui_win32 (WIN32 Style Application Command Line Interface)
#
# motif (Motif-X11/OpenGL Graphical User Interface)
# qt (Qt5/OpenGL Graphical User Interface)
# qt (Qt/OpenGL Graphical User Interface)
#
# vis_opengl_x11 (OpenGL visualization with X11 interface)
# vis_opengl_win32 (OpenGL visualization with X11 interface)
@@ -264,17 +264,24 @@ if(NOT Geant4_builtin_zlib_FOUND)
find_dependency(ZLIB @ZLIB_VERSION_STRING@)
endif()
# PTL/TBB
# - Refind of PTL will refind TBB
set(Geant4_system_ptl_FOUND @GEANT4_USE_SYSTEM_PTL@)
set(Geant4_TBB_FOUND @GEANT4_USE_TBB@)
if(Geant4_system_ptl_FOUND)
set(Geant4_builtin_ptl_FOUND FALSE)
find_dependency(PTL @PTL_VERSION_STRING@)
if(Geant4_TBB_FOUND)
find_dependency(PTL @PTL_VERSION@ COMPONENTS TBB)
else()
find_dependency(PTL @PTL_VERSION@)
endif()
else()
# We know exactly where PTL is
set(Geant4_builtin_ptl_FOUND TRUE)
if(CMAKE_VERSION VERSION_GREATER 3.8.9999)
find_dependency(PTL @PTL_VERSION_STRING@ NO_DEFAULT_PATH PATHS "@PACKAGE_PTL_PREFIX@")
find_dependency(PTL NO_DEFAULT_PATH PATHS "@PACKAGE_PTL_PREFIX@")
else()
find_package(PTL @PTL_VERSION_STRING@ REQUIRED NO_DEFAULT_PATH PATHS "@PACKAGE_PTL_PREFIX@")
find_package(PTL REQUIRED NO_DEFAULT_PATH PATHS "@PACKAGE_PTL_PREFIX@")
endif()
endif()
@@ -300,12 +307,6 @@ set(Geant4_smartstack_FOUND @GEANT4_USE_SMARTSTACK@)
# - ParticleHP as HP
set(Geant4_php_as_hp_FOUND @GEANT4_BUILD_PHP_AS_HP@)
# - TBB
set(Geant4_TBB_FOUND @GEANT4_USE_TBB@)
if(Geant4_TBB_FOUND)
find_dependency(TBB @TBB_VERSION@)
endif()
# - TiMemory
set(Geant4_timemory_FOUND @GEANT4_USE_TIMEMORY@)
if(Geant4_timemory_FOUND)
@@ -399,18 +400,18 @@ endif()
set(Geant4_qt_FOUND @GEANT4_USE_QT@)
set(Geant4_qt3d_FOUND @GEANT4_USE_QT3D@)
if(Geant4_qt_FOUND)
# Must always refind Qt5 to recreate imported targets. Because these
# Must always refind Qt to recreate imported targets. Because these
# are in the public interface, always need linking.
find_dependency(Qt5Core REQUIRED)
find_dependency(Qt5Gui REQUIRED)
find_dependency(Qt5Widgets REQUIRED)
find_dependency(Qt5OpenGL REQUIRED)
find_dependency(Qt5PrintSupport REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@Core REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@Gui REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@Widgets REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@OpenGL REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@PrintSupport REQUIRED)
if(Geant4_qt3d_FOUND)
find_dependency(Qt53DCore @QT3D_MINIMUM_VERSION@ REQUIRED)
find_dependency(Qt53DExtras @QT3D_MINIMUM_VERSION@ REQUIRED)
find_dependency(Qt53DRender @QT3D_MINIMUM_VERSION@ REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@3DCore @QT3D_MINIMUM_VERSION@ REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@3DExtras @QT3D_MINIMUM_VERSION@ REQUIRED)
find_dependency(Qt@QT_VERSION_MAJOR@3DRender @QT3D_MINIMUM_VERSION@ REQUIRED)
endif()
# Also require OpenGL
@@ -712,7 +713,6 @@ list(APPEND _geant4_internal_libraries
${_geant4_physicslists_library}
Geant4::G4run${_geant4_lib_use_suffix}
Geant4::G4event${_geant4_lib_use_suffix}
Geant4::G4tasking${_geant4_lib_use_suffix}
Geant4::G4tracking${_geant4_lib_use_suffix}
Geant4::G4parmodels${_geant4_lib_use_suffix}
Geant4::G4processes${_geant4_lib_use_suffix}
@@ -724,7 +724,8 @@ list(APPEND _geant4_internal_libraries
Geant4::G4graphics_reps${_geant4_lib_use_suffix}
Geant4::G4intercoms${_geant4_lib_use_suffix}
Geant4::G4global${_geant4_lib_use_suffix}
Geant4::G4tools${_geant4_lib_use_suffix}
# G4tools is INTERFACE, so same for both static/shared.
Geant4::G4tools
)
# - Any externals built by Geant4
+8 -90
View File
@@ -1,94 +1,12 @@
# - Use file for Geant4
# This file may be included after a find_package call has successfully
# located Geant4 to set global compile definitions, include directories,
# and compiler flags for building and linking to the Geant4 libraries.
#
# If Geant4 has been located via the Geant4Config.cmake config file, the
# following variable will be set:
#
# Geant4_USE_FILE : Point to the location of the use file for the found
# Geant4 installation.
#
# Inclusion of this file, e.g. via
#
# include(${Geant4_USE_FILE})
#
# results in the addition of the Geant4 compile definitions and
# include directories to those of the directory in which this file is
# included.
#
# Header paths are added via include_directories as SYSTEM type directories
#
# The recommended Geant4 compiler flags are also prepended to
# CMAKE_CXX_FLAGS but duplicated flags are NOT removed. This permits
# client of UseGeant4 to override Geant4's recommended flags if required
# and at their own risk.
#
# Advanced users requiring special sets of flags, or the removal of
# duplicate flags should therefore *not* use this file, preferring the
# direct use of the Geant4_XXXX variables set by the Geant4Config file.
#
# The last thing the module does is to optionally include an internal Use
# file. This file can contain variables, functions and macros for strict
# internal use in Geant4, such as building and running validation tests.
# Optional inclusion of internal Use file. This file can contain
# variables, functions and macros for strict internal use in Geant4,
# such as building and running validation tests.
#
include(${CMAKE_CURRENT_LIST_DIR}/UseGeant4_internal.cmake OPTIONAL)
#-----------------------------------------------------------------------
# We need to set the compile definitions and include directories
#
add_definitions(${Geant4_DEFINITIONS})
include_directories(AFTER SYSTEM ${Geant4_INCLUDE_DIRS})
#-----------------------------------------------------------------------
# Because Geant4 is sensitive to the compiler flags, set the base
# set here. This reproduces as far as possible the behaviour of the
# original makefile system.
#
set(CMAKE_CXX_FLAGS "${Geant4_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${Geant4_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${Geant4_CXX_FLAGS_MINSIZEREL} ${CMAKE_CXX_FLAGS_MINSIZEREL}")
set(CMAKE_CXX_FLAGS_RELEASE "${Geant4_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${Geant4_CXX_FLAGS_RELWITHDEBINFO} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_EXE_LINKER_FLAGS "${Geant4_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
#-----------------------------------------------------------------------
# Update build type information ONLY for single mode build tools, adding
# type used to build this install if none has been set, but otherwise leaving
# value alone.
# NB: this doesn't allow "None" for the build type - would need something
# more sophisticated using an internal cache variable.
# Good enough for now!
#
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
# Default to type used to build this install.
set(CMAKE_BUILD_TYPE "${Geant4_BUILD_TYPE}"
CACHE STRING "Choose the type of build, options are: None Release MinSizeRel Debug RelWithDebInfo MinSizeRel."
FORCE
)
else()
# Force to the cache, but use existing value.
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}"
CACHE STRING "Choose the type of build, options are: None Release MinSizeRel Debug RelWithDebInfo MinSizeRel."
FORCE
)
endif()
endif()
#-----------------------------------------------------------------------
# Locate ourselves
#
get_filename_component(_use_geant4_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
#-----------------------------------------------------------------------
# Append the local module path to CMAKE_MODULE_PATH to automatically
# make FindXXX modules for examples available
#
list(APPEND CMAKE_MODULE_PATH ${_use_geant4_dir}/Modules)
#-----------------------------------------------------------------------
# Include internal use file if it exists. It should only exist in the
# build tree!
#
include(${_use_geant4_dir}/UseGeant4_internal.cmake OPTIONAL)
# Add Module directory so that examples can use internal "FindXXX"
# modules. Appended to minimize any conflict with consumer project
# settings
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
+10
View File
@@ -159,7 +159,17 @@ function(geant4_add_test test)
--no-warn-unused-cli
-DGeant4_DIR=${CMAKE_BINARY_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
-DCMAKE_DISABLE_FIND_PACKAGE_ROOT=$<BOOL:${CMAKE_DISABLE_FIND_PACKAGE_ROOT}>
)
set_property(TEST ${__build_test_name} PROPERTY ENVIRONMENT Geant4_DIR=${CMAKE_BINARY_DIR})
+109 -8
View File
@@ -48,6 +48,9 @@ scriptloc=`dirname $script`
# Expansion and calculation of all needed variables
#
prefix=@GEANT4_CONFIG_INSTALL_PREFIX@
# canonicalize path
prefix=`cd "$prefix" 2>/dev/null; pwd -P`
exec_prefix=@GEANT4_CONFIG_EXECPREFIX@
libdir=@GEANT4_CONFIG_LIBDIR@
includedirs="@GEANT4_CONFIG_INCLUDE_DIRS@"
@@ -113,16 +116,15 @@ done
libs="-lG4interfaces \
-lG4persistency \
-lG4analysis \
-lG4error_propagation \
-lG4readout \
-lG4physicslists \
-lG4tasking \
-lG4run \
-lG4event \
-lG4tracking \
-lG4parmodels \
-lG4processes \
-lG4analysis \
-lG4digits_hits \
-lG4track \
-lG4particles \
@@ -131,7 +133,6 @@ libs="-lG4interfaces \
-lG4graphics_reps \
-lG4intercoms \
-lG4global \
-lG4tools \
@G4_LINK_CXX_FILESYSTEM@"
#-----------------------------------------------------------------------
@@ -224,6 +225,11 @@ fi
geant4_uses_opengl="yes"
fi
# - QT3D
have_qt3d="@G4_BUILTWITH_QT3D@"
feature_list="${feature_list} qt3d[${have_qt3d}]"
# - Motif
have_motif="@G4_BUILTWITH_MOTIF@"
feature_list="${feature_list} motif[${have_motif}]"
@@ -264,6 +270,11 @@ if test "x${have_openinventor}" = "xyes" ; then
vis_libs="-lG4OpenInventor ${vis_libs}"
fi
# - VTK
have_vtk="@G4_BUILTWITH_VTK@"
feature_list="${feature_list} vtk[${have_vtk}]"
# - If we have any OpenGL based feature, then we need to add in the
# OpenGL global define and the G4OpenGL/G4gl2ps libraries.
if test "x${geant4_uses_opengl}" = "xyes" ; then
@@ -304,6 +315,36 @@ print_datasets()
exit 0
}
#-----------------------------------------------------------------------
# function print_datasets_sh
# print dataset information with one line per dataset and each
# line in the format
# export <ENVVARNAME>="<PATH>"
print_datasets_sh()
{
for ds in ${dataset_list} ; do
dataset_envvar=$(echo $ds | cut -d "|" -f2)
dataset_path=$(echo $ds | cut -d "|" -f3)
echo "export ${dataset_envvar}=\"${dataset_path}\""
done
exit 0
}
#-----------------------------------------------------------------------
# function print_datasets_csh
# print dataset information with one line per dataset and each
# line in the format
# setenv <ENVVARNAME> "<PATH>";
print_datasets_csh()
{
for ds in ${dataset_list} ; do
dataset_envvar=$(echo $ds | cut -d "|" -f2)
dataset_path=$(echo $ds | cut -d "|" -f3)
echo "setenv ${dataset_envvar} \"${dataset_path}\";"
done
exit 0
}
#-----------------------------------------------------------------------
# function check_datasets
# Check whether datasets exist as directories at the expected
@@ -336,8 +377,15 @@ install_datasets()
G4OPENSSL=$(which openssl)
if test "x${G4OPENSSL}" = "x" ; then
echo "- error: no openssl executable found"
G4MD5SUM=$(which md5sum)
if test "x${G4MD5SUM}" = "x" ; then
echo "- error: no openssl or md5sum executable found"
exit 1
else
G4MD5CMD="${G4MD5SUM} --tag"
fi
else
G4MD5CMD="${G4OPENSSL} dgst -md5"
fi
G4TAR=$(which tar)
@@ -390,7 +438,7 @@ install_datasets()
# Validate bundle hash (basic)
dataset_md5=$(echo $ds | cut -d "|" -f5)
actual_md5=$(${G4OPENSSL} dgst -md5 ${g4downloaddir}/${dataset_file} | cut -d" " -f2)
actual_md5=$(${G4MD5CMD} ${g4downloaddir}/${dataset_file} | tr -d ' ' | cut -d"=" -f2)
echo "+ checking md5 of ${dataset_file}"
if [ "${actual_md5}" != "${dataset_md5}" ] ; then
echo "- md5 mismatch for '${dataset_file}' : ${actual_md5}(actual) != ${dataset_md5}(expected)"
@@ -440,6 +488,21 @@ install_datasets()
exit 1
}
#-----------------------------------------------------------------------
# function list_features
# print list of enabled and disabled features.
#
list_features()
{
cat<<EOF
Known Features:
EOF
for f in ${feature_list} ; do
echo " $f"
done
exit 0
}
#-----------------------------------------------------------------------
# function help
# print help on available command line arguments and enabled
@@ -465,6 +528,16 @@ Usage: geant4-config [OPTION...]
--has-feature FEATURE output yes if FEATURE is supported,
or no if not supported
--features print list of features
--sh print shell commands required to set environment
variables for Geant4, which can be evaluated in
the calling shell with "eval \$(geant4-config --sh)"
--csh print C shell commands required to set environment
variables for Geant4, which can be evaluated in
the calling shell with "eval \`geant4-config --csh\`"
--datasets output dataset name, environment variable
and path, with one line per dataset
@@ -514,14 +587,16 @@ fi
while test $# -gt 0 ; do
case "$1" in
-*=*)
optflag=`echo "$1" | sed 's/=[-_a-zA-Z0-9]*//'`
optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*)
optflag=$1
optarg=
;;
esac
case "$1" in
case "$optflag" in
--prefix)
echo ${prefix}
;;
@@ -555,9 +630,17 @@ while test $# -gt 0 ; do
;;
--has-feature)
shift
if [ x$optarg = x ]; then
if [ $# -gt 1 ]; then
shift
optarg=$1
else
echo "$optflag - missing parameter"
exit 1
fi
fi
case "$1" in
case "$optarg" in
static)
echo ${have_staticlibs}
;;
@@ -594,6 +677,12 @@ while test $# -gt 0 ; do
qt)
echo ${have_qt}
;;
qt3d)
echo ${have_qt3d}
;;
vtk)
echo ${have_vtk}
;;
motif)
echo ${have_motif}
;;
@@ -615,6 +704,10 @@ while test $# -gt 0 ; do
esac
;;
--features)
list_features
;;
--datasets)
print_datasets
;;
@@ -627,6 +720,14 @@ while test $# -gt 0 ; do
install_datasets
;;
--sh)
print_datasets_sh
;;
--csh)
print_datasets_csh
;;
-?)
help
;;
@@ -28,6 +28,7 @@
#
set(GEANT4_FALSEPOSITIVE_SOURCES
# G4{Global,Geom}Config.hh generated
G4FindDataDir.hh
G4GlobalConfig.hh
G4GeomConfig.hh
# - Xaw is deprecated...