Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
# - Finds ROOT instalation
|
||||
# This module sets up ROOT information
|
||||
# This module sets up ROOT information
|
||||
# It defines:
|
||||
# ROOT_FOUND If the ROOT is found
|
||||
# ROOT_INCLUDE_DIR PATH to the include directory (deprecated)
|
||||
# ROOT_INCLUDE_DIRS PATH to the include directory
|
||||
# ROOT_LIBRARIES Most common libraries
|
||||
# ROOT_LIBRARY_DIR PATH to the library directory
|
||||
# ROOT_LIBRARY_DIR PATH to the library directory
|
||||
# ROOT_BIN_DIR PATH to the excutables directory
|
||||
# ROOT_PYTHONVER Compatible python version string
|
||||
|
||||
# First search for ROOTConfig.cmake on the path defined via user setting
|
||||
# First search for ROOTConfig.cmake on the path defined via user setting
|
||||
# ROOT_DIR
|
||||
|
||||
if(EXISTS ${ROOT_DIR}/ROOTConfig.cmake)
|
||||
@@ -25,16 +25,16 @@ find_program(ROOT_CONFIG_EXECUTABLE root-config
|
||||
|
||||
if(NOT ROOT_CONFIG_EXECUTABLE)
|
||||
set(ROOT_FOUND FALSE)
|
||||
else()
|
||||
else()
|
||||
set(ROOT_FOUND TRUE)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
|
||||
OUTPUT_VARIABLE ROOTSYS
|
||||
COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
|
||||
OUTPUT_VARIABLE ROOTSYS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${ROOT_CONFIG_EXECUTABLE} --version
|
||||
COMMAND ${ROOT_CONFIG_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE ROOT_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
@@ -57,7 +57,7 @@ else()
|
||||
COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir
|
||||
OUTPUT_VARIABLE ROOT_BIN_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
|
||||
|
||||
#set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof)
|
||||
#set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics)
|
||||
@@ -75,18 +75,18 @@ endif()
|
||||
if (NOT ROOT_FOUND)
|
||||
if (ROOT_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "ROOT required, but not found")
|
||||
endif (ROOT_FIND_REQUIRED)
|
||||
endif (ROOT_FIND_REQUIRED)
|
||||
endif()
|
||||
|
||||
include(CMakeMacroParseArguments)
|
||||
include(CMakeParseArguments)
|
||||
find_program(ROOTCINT_EXECUTABLE rootcint PATHS $ENV{ROOTSYS}/bin)
|
||||
find_program(GENREFLEX_EXECUTABLE genreflex PATHS $ENV{ROOTSYS}/bin)
|
||||
find_package(GCCXML)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# function ROOT_GENERATE_DICTIONARY( dictionary
|
||||
# header1 header2 ...
|
||||
# LINKDEF linkdef1 ...
|
||||
# function ROOT_GENERATE_DICTIONARY( dictionary
|
||||
# header1 header2 ...
|
||||
# LINKDEF linkdef1 ...
|
||||
# OPTIONS opt1...)
|
||||
function(ROOT_GENERATE_DICTIONARY dictionary)
|
||||
CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN})
|
||||
@@ -109,7 +109,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
|
||||
# rootcint (info from Andrea Dotti, and info from post:
|
||||
# http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=15086
|
||||
get_directory_property(incdirs INCLUDE_DIRECTORIES)
|
||||
set(includedirs)
|
||||
set(includedirs)
|
||||
foreach( d ${incdirs})
|
||||
if(NOT ${d} STREQUAL "/usr/include")
|
||||
set(includedirs ${includedirs} -I${d})
|
||||
@@ -120,7 +120,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
|
||||
foreach( f ${ARG_LINKDEF})
|
||||
if( IS_ABSOLUTE ${f})
|
||||
set(linkdefs ${linkdefs} ${f})
|
||||
else()
|
||||
else()
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
|
||||
set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f})
|
||||
else()
|
||||
@@ -130,17 +130,17 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
|
||||
endforeach()
|
||||
#---call rootcint------------------------------------------
|
||||
add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h
|
||||
COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx
|
||||
-c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs}
|
||||
COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx
|
||||
-c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs}
|
||||
DEPENDS ${headerfiles} ${linkdefs})
|
||||
endfunction()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# function REFLEX_GENERATE_DICTIONARY(dictionary
|
||||
# header1 header2 ...
|
||||
# SELECTION selectionfile ...
|
||||
# function REFLEX_GENERATE_DICTIONARY(dictionary
|
||||
# header1 header2 ...
|
||||
# SELECTION selectionfile ...
|
||||
# OPTIONS opt1...)
|
||||
function(REFLEX_GENERATE_DICTIONARY dictionary)
|
||||
function(REFLEX_GENERATE_DICTIONARY dictionary)
|
||||
CMAKE_PARSE_ARGUMENTS(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN})
|
||||
#---Get the list of header files-------------------------
|
||||
set(headerfiles)
|
||||
@@ -157,18 +157,18 @@ function(REFLEX_GENERATE_DICTIONARY dictionary)
|
||||
#---Get Selection file------------------------------------
|
||||
if(IS_ABSOLUTE ${ARG_SELECTION})
|
||||
set(selectionfile ${ARG_SELECTION})
|
||||
else()
|
||||
else()
|
||||
set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION})
|
||||
endif()
|
||||
#---Get the list of include directories------------------
|
||||
get_directory_property(incdirs INCLUDE_DIRECTORIES)
|
||||
set(includedirs)
|
||||
foreach( d ${incdirs})
|
||||
set(includedirs)
|
||||
foreach( d ${incdirs})
|
||||
set(includedirs ${includedirs} -I${d})
|
||||
endforeach()
|
||||
#---Get preprocessor definitions--------------------------
|
||||
get_directory_property(defs COMPILE_DEFINITIONS)
|
||||
foreach( d ${defs})
|
||||
foreach( d ${defs})
|
||||
set(definitions ${definitions} -D${d})
|
||||
endforeach()
|
||||
#---Names and others---------------------------------------
|
||||
@@ -179,7 +179,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary)
|
||||
set(gccxmlopts "--gccxmlopt=--gccxml-compiler g++ ")
|
||||
else()
|
||||
set(gccxmlopts)
|
||||
endif()
|
||||
endif()
|
||||
#set(rootmapname ${dictionary}Dict.rootmap)
|
||||
#set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict)
|
||||
#---Check GCCXML and get path-----------------------------
|
||||
@@ -189,9 +189,9 @@ function(REFLEX_GENERATE_DICTIONARY dictionary)
|
||||
message(WARNING "GCCXML not found. Install and setup your environment to find 'gccxml' executable")
|
||||
endif()
|
||||
#---Actual command----------------------------------------
|
||||
add_custom_command(OUTPUT ${gensrcdict} ${rootmapname}
|
||||
add_custom_command(OUTPUT ${gensrcdict} ${rootmapname}
|
||||
COMMAND ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} ${gccxmlopts} ${rootmapopts} --select=${selectionfile}
|
||||
--gccxmlpath=${gccxmlpath} ${ARG_OPTIONS} ${includedirs} ${definitions}
|
||||
DEPENDS ${headerfiles} ${selectionfile})
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
#.rst:
|
||||
# G4BuildSettings.cmake
|
||||
# ---------------------
|
||||
#
|
||||
# Set defaults for core CMake settings for compiling and linking
|
||||
# Geant4 libraries and tests,
|
||||
#
|
||||
# In addition to the core compiler/linker flags (configured in the
|
||||
# Geant4MakeRules_<LANG>.cmake files) for Geant4, the build may require
|
||||
# further configuration. This module performs this task whicj includes:
|
||||
#
|
||||
# 1) Extra build modes for developers
|
||||
# 2) Additional compiler definitions to assist visualization or optimize
|
||||
# performance.
|
||||
# 3) Additional compiler flags which may be added optionally.
|
||||
# 4) Whether to build shared and/or static libraries.
|
||||
# 5) Whether to build libraries in global or granular format.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
if(NOT __G4BUILDSETTINGS_INCLUDED)
|
||||
set(__G4BUILDSETTINGS_INCLUDED TRUE)
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Included Modules
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module includes the following modules:
|
||||
#
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(IntelCompileFeatures)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Build Modes
|
||||
# ^^^^^^^^^^^
|
||||
#
|
||||
# Geant4 supports the standard CMake build types/configurations of
|
||||
#
|
||||
# - ``Release``
|
||||
# - ``Debug``
|
||||
# - ``MinSizeRel``
|
||||
# - ``RelWithDebInfo``
|
||||
#
|
||||
# For single build type tools like `make` and `ninja`, the build
|
||||
# defaults to ``Release`` mode unless ``CMAKE_BUILD_TYPE`` is set.
|
||||
# Multi build type tools like Visual Studio and Xcode will default
|
||||
# to
|
||||
#
|
||||
# On non-WIN32 platforms, two types specifically for development are added:
|
||||
#
|
||||
if(NOT WIN32)
|
||||
|
||||
#.rst:
|
||||
# - ``TestRelease``:
|
||||
# For trial production and extended testing. It has verbose
|
||||
# output, has debugging symbols, and adds definitions to allow FPE
|
||||
# and physics conservation law testing where supported.
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS_TESTRELEASE "${CMAKE_CXX_FLAGS_TESTRELEASE_INIT}"
|
||||
CACHE STRING "Flags used by the compiler during TestRelease builds"
|
||||
)
|
||||
mark_as_advanced(CMAKE_CXX_FLAGS_TESTRELEASE)
|
||||
|
||||
#.rst:
|
||||
# - ``Maintainer``:
|
||||
# For development of the toolkit. It adds debugging, and enables the use
|
||||
# of library specific debugging via standardized definitions.
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS_MAINTAINER "${CMAKE_CXX_FLAGS_MAINTAINER_INIT}"
|
||||
CACHE STRING "Flags used by the compiler during Maintainer builds"
|
||||
)
|
||||
mark_as_advanced(CMAKE_CXX_FLAGS_MAINTAINER)
|
||||
|
||||
#.rst:
|
||||
# Compiler flags specific to these build types are set in the cache, and
|
||||
# the types are added to the ``CMAKE_BUILD_TYPES`` cache string and to
|
||||
# ``CMAKE_CONFIGURATION_TYPES`` if appropriate to the build tool being used.
|
||||
#
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
# Single mode build tools like Make, Ninja,
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
# Default to a Release build if nothing else...
|
||||
set(CMAKE_BUILD_TYPE Release
|
||||
CACHE STRING "Choose the type of build, options are: None Release TestRelease MinSizeRel Debug RelWithDebInfo MinSizeRel Maintainer."
|
||||
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 TestRelease MinSizeRel Debug RelWithDebInfo MinSizeRel Maintainer."
|
||||
FORCE
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
# Multimode tools like VS, Xcode
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES TestRelease)
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
|
||||
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}"
|
||||
CACHE STRING "Geant4 configurations for multimode build tools"
|
||||
FORCE
|
||||
)
|
||||
endif()
|
||||
|
||||
endif() #NOT WIN32
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Compilation Options
|
||||
# ^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# The following options affect the compilation of the Geant4 libraries
|
||||
#
|
||||
|
||||
#.rst
|
||||
# - ``GEANT4_BUILD_CXXSTD`` (Allowed values: 11, 14, c++11, c++14)
|
||||
#
|
||||
# - Choose C++ Standard to build against from supported list.
|
||||
#
|
||||
enum_option(GEANT4_BUILD_CXXSTD
|
||||
DOC "C++ Standard to compile against"
|
||||
VALUES 11 14 c++11 c++14
|
||||
CASE_INSENSITIVE
|
||||
)
|
||||
|
||||
string(REGEX REPLACE "^c\\+\\+" "" GEANT4_BUILD_CXXSTD "${GEANT4_BUILD_CXXSTD}")
|
||||
mark_as_advanced(GEANT4_BUILD_CXXSTD)
|
||||
|
||||
# Require at least C++11 with no extensions and the following features
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(GEANT4_TARGET_COMPILE_FEATURES
|
||||
cxx_alias_templates
|
||||
cxx_auto_type
|
||||
cxx_delegating_constructors
|
||||
cxx_enum_forward_declarations
|
||||
cxx_explicit_conversions
|
||||
cxx_final
|
||||
cxx_lambdas
|
||||
cxx_nullptr
|
||||
cxx_override
|
||||
cxx_range_for
|
||||
cxx_strong_enums
|
||||
cxx_uniform_initialization
|
||||
# Features that MSVC 18.0 cannot support but in list of Geant4 coding
|
||||
# guidelines - to be required once support for that compiler is dropped.
|
||||
# Version 10.2 is coded without these being required.
|
||||
#cxx_deleted_functions
|
||||
#cxx_generalized_initializers
|
||||
#cxx_constexpr
|
||||
#cxx_inheriting_constructors
|
||||
)
|
||||
|
||||
# If a standard higher than 11 has been selected, check that compiler has
|
||||
# at least one feature from that standard and append these to the required
|
||||
# feature list
|
||||
if(GEANT4_BUILD_CXXSTD GREATER 11)
|
||||
if(CMAKE_CXX${GEANT4_BUILD_CXXSTD}_COMPILE_FEATURES)
|
||||
list(APPEND GEANT4_TARGET_COMPILE_FEATURES ${CMAKE_CXX${GEANT4_BUILD_CXXSTD}_COMPILE_FEATURES})
|
||||
else()
|
||||
message(FATAL_ERROR "Geant4 requested to be compiled against C++ standard '${GEANT4_BUILD_CXXSTD}'\nbut detected compiler '${CMAKE_CXX_COMPILER_ID}', version '${CMAKE_CXX_COMPILER_VERSION}'\ndoes not support any features of that standard")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - Check for Standard Library Implementation Features
|
||||
# Smart pointers are a library implementation feature
|
||||
# Hashed containers are a library implementation feature
|
||||
# Random numbers are a library implementation feature?
|
||||
# - Thread local? Yes, though on AppleClang platforms, see this:
|
||||
#http://stackoverflow.com/questions/28094794/why-does-apple-clang-disallow-c11-thread-local-when-official-clang-supports
|
||||
# An example of where a workaround is needed
|
||||
# Rest of concurrency a library implementation feature
|
||||
|
||||
# Add Definition to flags for temporary back compatibility
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DG4USE_STD11")
|
||||
|
||||
# Hold any appropriate compile flag(s) in variable for later export to
|
||||
# config files. Needed to support clients using late CMake 2.8 where compile features
|
||||
# are not available.
|
||||
set(GEANT4_CXXSTD_FLAGS "${CMAKE_CXX${GEANT4_BUILD_CXXSTD}_STANDARD_COMPILE_OPTION}")
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Multithreading
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# - ``GEANT4_BUILD_MULTITHREADED`` (Default: ``OFF``)
|
||||
#
|
||||
# If set to ``ON``, compile Geant4 with support for multithreading.
|
||||
# At present, this is only supported on Unix platforms.
|
||||
#
|
||||
option(GEANT4_BUILD_MULTITHREADED "Enable multithreading in Geant4" OFF)
|
||||
|
||||
if(WIN32)
|
||||
mark_as_advanced(GEANT4_BUILD_MULTITHREADED)
|
||||
endif()
|
||||
|
||||
geant4_add_feature(GEANT4_BUILD_MULTITHREADED "Build multithread enabled libraries")
|
||||
|
||||
#.rst:
|
||||
# - ``GEANT4_BUILD_TLS_MODEL`` (Default: ``initial-exec``)
|
||||
#
|
||||
# If ``GEANT4_BUILD_MULTITHREADED`` is ``ON`` and a GNU/Clang/Intel
|
||||
# compiler is being used, then this option may be used to choose the
|
||||
# Thread Local Storage model. A default of ``initial-exec`` is used
|
||||
# to provide optimize performance for applications directly linking
|
||||
# to the Geant4 libraries
|
||||
#
|
||||
if(GEANT4_BUILD_MULTITHREADED)
|
||||
# - Need Thread Local Storage support (POSIX)
|
||||
if(UNIX)
|
||||
check_cxx_source_compiles("__thread int i; int main(){return 0;}" HAVE_TLS)
|
||||
if(NOT HAVE_TLS)
|
||||
message(FATAL_ERROR "Configured compiler ${CMAKE_CXX_COMPILER} does not support thread local storage")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - Emit warning on Windows - message will format oddly on CMake prior
|
||||
# to 2.8, but still print
|
||||
if(WIN32)
|
||||
message(WARNING "GEANT4_BUILD_MULTITHREADED IS NOT SUPPORTED on Win32. This option should only be activated by developers")
|
||||
endif()
|
||||
|
||||
# - Allow advanced users to select the thread local storage model,
|
||||
# if the compiler supports it, defaulting to that recommended by Geant4
|
||||
if(TLSMODEL_IS_AVAILABLE)
|
||||
enum_option(GEANT4_BUILD_TLS_MODEL
|
||||
DOC "Build libraries with Thread Local Storage model"
|
||||
VALUES ${TLSMODEL_IS_AVAILABLE}
|
||||
CASE_INSENSITIVE
|
||||
)
|
||||
mark_as_advanced(GEANT4_BUILD_TLS_MODEL)
|
||||
geant4_add_feature(GEANT4_BUILD_TLS_MODEL "Building with TLS model '${GEANT4_BUILD_TLS_MODEL}'")
|
||||
|
||||
set(GEANT4_MULTITHREADED_CXX_FLAGS "${GEANT4_MULTITHREADED_CXX_FLAGS} ${${GEANT4_BUILD_TLS_MODEL}_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Set Defs/Compiler Flags
|
||||
# TODO: Migrate def to header
|
||||
add_definitions(-DG4MULTITHREADED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GEANT4_MULTITHREADED_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Miscellaneous
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# - ``GEANT4_BUILD_STORE_TRAJECTORY`` (Default: ON)
|
||||
#
|
||||
# - Switching off can improve performance. Needs to be on
|
||||
# for visualization to work fully. Mark as advanced because most users
|
||||
# should not need to worry about it.
|
||||
#
|
||||
option(GEANT4_BUILD_STORE_TRAJECTORY
|
||||
"Store trajectories in event processing. Switch off for improved performance but note that visualization of trajectories will not be possible"
|
||||
ON)
|
||||
mark_as_advanced(GEANT4_BUILD_STORE_TRAJECTORY)
|
||||
|
||||
# TODO: Migrate this to header
|
||||
if(GEANT4_BUILD_STORE_TRAJECTORY)
|
||||
add_definitions(-DG4_STORE_TRAJECTORY)
|
||||
endif()
|
||||
|
||||
#.rst:
|
||||
# - ``GEANT4_BUILD_VERBOSE_CODE`` (Default: ON)
|
||||
#
|
||||
# - Switching off can improve performance, but at the cost
|
||||
# of fewer informational or warning messages.
|
||||
# Mark as advanced because most users should not need to worry about it.
|
||||
#
|
||||
option(GEANT4_BUILD_VERBOSE_CODE
|
||||
"Enable verbose output from Geant4 code. Switch off for better performance at the cost of fewer informational messages or warnings"
|
||||
ON)
|
||||
mark_as_advanced(GEANT4_BUILD_VERBOSE_CODE)
|
||||
|
||||
# TODO: Migrate this to header
|
||||
if(GEANT4_BUILD_VERBOSE_CODE)
|
||||
add_definitions(-DG4VERBOSE)
|
||||
endif()
|
||||
|
||||
#.rst:
|
||||
# - ``GEANT4_BUILD_MSVC_MP`` (Windows only, Default: OFF)
|
||||
#
|
||||
# - Provide optional file level parallelization with MSVC compiler.
|
||||
#
|
||||
|
||||
# NB: This will only work if the build tool performs compilations
|
||||
# with multiple sources, e.g. "cl.exe a.cc b.cc c.cc"
|
||||
if(MSVC)
|
||||
option(GEANT4_BUILD_MSVC_MP "Use /MP option with MSVC for file level parallel builds" OFF)
|
||||
mark_as_advanced(GEANT4_BUILD_MSVC_MP)
|
||||
|
||||
if(GEANT4_BUILD_MSVC_MP)
|
||||
set(CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Library Mode and Link Options
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
|
||||
#.rst:
|
||||
# - ``BUILD_SHARED_LIBS`` (Default: ``ON``)
|
||||
#
|
||||
# - Build shared libraries (`.so` on Unix, `.dylib` on macOS, `.dll/.lib` on Windows)
|
||||
#
|
||||
# - ``BUILD_STATIC_LIBS`` (Default: ``OFF``)
|
||||
#
|
||||
# - Build static libraries (`.a` on Unices, `.lib` on Windows)
|
||||
#
|
||||
# Both options are adavanced and may be selected together to build
|
||||
# both types. If neither is selected, an error is emitted.
|
||||
#
|
||||
option(BUILD_SHARED_LIBS "Build Geant4 shared libraries" ON)
|
||||
option(BUILD_STATIC_LIBS "Build Geant4 static libraries" OFF)
|
||||
mark_as_advanced(BUILD_SHARED_LIBS BUILD_STATIC_LIBS)
|
||||
|
||||
# Because both could be switched off accidently, FATAL_ERROR if neither
|
||||
# option has been selected.
|
||||
if(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "Neither static nor shared libraries will be built")
|
||||
endif()
|
||||
|
||||
# Always build global libraries - always FATAL_ERROR if old
|
||||
# granular library switch is set, e.g. from command line
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
message(FATAL_ERROR " Granular libraries are no longer supported!")
|
||||
endif()
|
||||
|
||||
# On WIN32, we need to build the genwindef application to create export
|
||||
# def files for building DLLs.
|
||||
# We only use it as a helper application at the moment so we exclude it from
|
||||
# the ALL target.
|
||||
# TODO: We could move this section into the Geant4MacroLibraryTargets.cmake
|
||||
# if it can be protected so that the genwindef target wouldn't be defined
|
||||
# more than once... Put it here for now...
|
||||
# TODO: Investigate use of CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS from CMake 3.4
|
||||
# and/or other forms of symbol visibility
|
||||
if(WIN32)
|
||||
# Assume the sources are co-located
|
||||
get_filename_component(_genwindef_src_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
add_executable(genwindef EXCLUDE_FROM_ALL
|
||||
${_genwindef_src_dir}/genwindef/genwindef.cpp
|
||||
${_genwindef_src_dir}/genwindef/LibSymbolInfo.h
|
||||
${_genwindef_src_dir}/genwindef/LibSymbolInfo.cpp)
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Build Output Directories
|
||||
# ------------------------
|
||||
#
|
||||
# Because of the highly nested structure of Geant4, built libraries and
|
||||
# programs will be distributed throughout the build tree. To simplify
|
||||
# use and testing of the build, CMake is setup to output these products
|
||||
# to a directory hierarchy based on the configured install locations.
|
||||
|
||||
# - Match output layout, so must have variables from GNUInstallDirs...
|
||||
if((NOT DEFINED CMAKE_INSTALL_BINDIR) OR (NOT DEFINED CMAKE_INSTALL_LIBDIR))
|
||||
message(FATAL_ERROR "Cannot configure build output dirs as install directories have not yet been defined")
|
||||
endif()
|
||||
|
||||
#.rst
|
||||
# In all cases, build products are stored in a directory tree rooted
|
||||
# in a directory named ``BuildProducts`` under the ``PROJECT_BINARY_DIRECTORY``.
|
||||
#
|
||||
set(BASE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/BuildProducts")
|
||||
|
||||
#.rst:
|
||||
# For single mode build generators (make, ninja), the following
|
||||
# hierarchy is used:
|
||||
#
|
||||
# .. code-block:: console
|
||||
#
|
||||
# +- <PROJECT_BINARY_DIR>/
|
||||
# +- BuildProducts/
|
||||
# +- <CMAKE_INSTALL_BINDIR>/
|
||||
# +- ... "runtime" targets ...
|
||||
# +- <CMAKE_INSTALL_LIBDIR>/
|
||||
# +- ... "library" and "archive" targets ...
|
||||
#
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_INSTALL_BINDIR}")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
#.rst:
|
||||
# For multimode build generators (Xcode, Visual Studio), each mode
|
||||
# is separated using the hierarchy
|
||||
#
|
||||
# .. code-block:: console
|
||||
#
|
||||
# +- <PROJECT_BINARY_DIR>
|
||||
# +- BuildProducts/
|
||||
# +- <CONFIG>/
|
||||
# +- <CMAKE_INSTALL_BINDIR>/
|
||||
# +- ... "runtime" targets ...
|
||||
# +- <CMAKE_INSTALL_LIBDIR>/
|
||||
# +- ... "library" and "archive" targets ...
|
||||
# +- ...
|
||||
#
|
||||
# where ``<CONFIG>`` is repeated for each build configuration listed in
|
||||
# :cmake:variable:`CMAKE_CONFIGURATION_TYPES <cmake:variable:CMAKE_CONFIGURATION_TYPES>`, e.g. Release, Debug, RelWithDebInfo etc.
|
||||
|
||||
foreach(_conftype ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${_conftype} _conftype_uppercase)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${_conftype_uppercase}
|
||||
"${BASE_OUTPUT_DIRECTORY}/${_conftype}/${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${_conftype_uppercase}
|
||||
"${BASE_OUTPUT_DIRECTORY}/${_conftype}/${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${_conftype_uppercase}
|
||||
"${BASE_OUTPUT_DIRECTORY}/${_conftype}/${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
#.rst:
|
||||
# G4CMakeMain
|
||||
# -----------
|
||||
#
|
||||
# Main script for Geant4 CMake build scripting.
|
||||
#
|
||||
# Stored separately from top level script purely for clarity in tagging.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# Include once and fail if already included
|
||||
if(NOT __G4CMAKEMAIN_INCLUDED)
|
||||
set(__G4CMAKEMAIN_INCLUDED TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "G4CMakeMain can only be included once")
|
||||
endif()
|
||||
|
||||
# Shouldn't need to set CMAKE_MODULE_PATH here as done at top level.
|
||||
# Review whether this is a more appropriate location.
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Add functionality provided by standard and custom modules
|
||||
# See the documentation in each of these modules for further details.
|
||||
|
||||
# - Core CMake settings and options
|
||||
include(G4CMakeSettings)
|
||||
|
||||
# - Core Compile/Link settings and options
|
||||
include(G4BuildSettings)
|
||||
|
||||
# - Core API
|
||||
include(G4DeveloperAPI)
|
||||
|
||||
# - Provide interface to control use of optional components
|
||||
include(Geant4OptionalComponents)
|
||||
|
||||
# - Provide interface to control use of UI/Vis components
|
||||
# Written in a separate module from other optional components because
|
||||
# there are many complex options to handle.
|
||||
include(Geant4InterfaceOptions)
|
||||
|
||||
# - Provide options to enable wrapping of Geant4 by other languages
|
||||
include(Geant4Wrapping)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Add the source and environments subdirectories
|
||||
# source : Process all the Geant4 core targets
|
||||
# environments : Process optional wrappings of Geant4 (NOTYETIMPLEMENTED)
|
||||
add_subdirectory(source)
|
||||
#add_subdirectory(environments)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Perform all post build tasks
|
||||
# At the CMake level, this simply means that we must know about targets
|
||||
# and other properties processed in source and environments trees before
|
||||
# these tasks can be performed.
|
||||
#
|
||||
# - Installation of optional read-only architecture independent data files.
|
||||
# E.g. Examples, data libraries, documentation.
|
||||
# Done before toolchain generation because it may affect what we have to do
|
||||
# there!
|
||||
#
|
||||
include(Geant4InstallData)
|
||||
|
||||
# - Generate any Use/Config/Support files here once everything else has
|
||||
# been processed e.g. "UseGeant4.cmake", "Geant4Config.cmake", library
|
||||
# dependencies etc.
|
||||
# - Geant4Make.gmk
|
||||
include(G4ConfigureGNUMakeHelpers)
|
||||
|
||||
# - Pkg-Config and geant4-config
|
||||
include(G4ConfigurePkgConfigHelpers)
|
||||
|
||||
# - Geant4Config.cmake et al
|
||||
include(G4ConfigureCMakeHelpers)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Testing configuration.
|
||||
# Done here, as projects under 'tests' require Geant4Config.
|
||||
include(Geant4CTest)
|
||||
if(GEANT4_ENABLE_TESTING)
|
||||
add_subdirectory(tests)
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/benchmarks)
|
||||
add_subdirectory(benchmarks)
|
||||
endif()
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/verification)
|
||||
add_subdirectory(verification)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Examples build/install
|
||||
# NB: Build of examples is a *testing* proceedure. It is *not* intended
|
||||
# that examples be built and installed as part of a full Geant4 install.
|
||||
option(GEANT4_BUILD_EXAMPLES "Build all the examples of the project" OFF)
|
||||
GEANT4_ADD_FEATURE(GEANT4_BUILD_EXAMPLES "Build all the examples of the project")
|
||||
mark_as_advanced(GEANT4_BUILD_EXAMPLES)
|
||||
|
||||
if(GEANT4_BUILD_EXAMPLES)
|
||||
set(Geant4_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Current build directory")
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# - Install example code to datarootdir
|
||||
install(DIRECTORY examples
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}
|
||||
COMPONENT Examples
|
||||
PATTERN "CVS" EXCLUDE
|
||||
PATTERN ".svn" EXCLUDE
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - CPack-aging
|
||||
include(Geant4CPackBase)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Final output - show what's been enabled so that user knows what's
|
||||
# happening - also useful for later problem solving!
|
||||
#
|
||||
GEANT4_PRINT_ENABLED_FEATURES()
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#.rst:
|
||||
# G4CMakeSettings.cmake
|
||||
# ---------------------
|
||||
#
|
||||
# Set defaults for core CMake behaviour useful or required for building,
|
||||
# testing and installing Geant4.
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
if(NOT __G4CMAKESETTINGS_INCLUDED)
|
||||
set(__G4CMAKESETTINGS_INCLUDED TRUE)
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# General Configuration Settings
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# The following CMake modules and variables are used to control configuration time
|
||||
# behaviour such as location of dependencies.
|
||||
#
|
||||
|
||||
#.rst:
|
||||
# - ``G4CMakeUtilities`
|
||||
#
|
||||
# - Included to provide additional macros and functions
|
||||
#
|
||||
include(G4CMakeUtilities)
|
||||
|
||||
#
|
||||
# - ``CMAKE_EXPORT_NO_PACKAGE_REGISTRY`` : ON
|
||||
# - ``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` : ON
|
||||
# - ``CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`` : ON
|
||||
#
|
||||
# - These variables are set to ensure that CMake never creates or searches
|
||||
# for config files in any package registry. This prevents the
|
||||
# :cmake:command:`find_package <cmake:command:find_package>`
|
||||
# command from locating potentially spurious config files.
|
||||
#
|
||||
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
|
||||
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON)
|
||||
set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# General Build Settings
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# The following CMake variables and options are configured by default
|
||||
# when including this module:
|
||||
#
|
||||
# - ``CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE`` : ON
|
||||
#
|
||||
# - Force project directories to appear first in any list of include paths.
|
||||
# This applies to both full paths and those created by generator expressions.
|
||||
#
|
||||
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
|
||||
|
||||
#.rst:
|
||||
# - ``CMAKE_LINK_DEPENDS_NO_SHARED`` : ON
|
||||
#
|
||||
# - Do not relink a target to any shared library dependencies when
|
||||
# only the shared library implementation has changed.
|
||||
#
|
||||
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
|
||||
|
||||
#.rst:
|
||||
# A custom ``validate_sources`` targets is declared to compare files listed
|
||||
# in `sources.cmake` scripts with on-disk files. As sources.cmake lists
|
||||
# source files of Geant4 explicitely, we can often a mismatch can occur
|
||||
# between this list and what's actually on disk.
|
||||
#
|
||||
# The ``validate_sources`` target executes a CMake script to
|
||||
# check for these errors and report mismatches. It fails with FATAL_ERROR
|
||||
# if any mismatch is found, but will not do so until it has reported
|
||||
# all errors.
|
||||
# Configure the script
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/geant4_validate_sources.cmake.in
|
||||
${PROJECT_BINARY_DIR}/geant4_validate_sources.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Create the target
|
||||
add_custom_target(validate_sources
|
||||
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/geant4_validate_sources.cmake
|
||||
COMMENT "Validating Geant4 Module Source Lists"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# General Installation Settings
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# CMake's builtin `GNUInstallDirs` module is used to set and provide variables
|
||||
# for the destinations to which for executables, libraries and other files
|
||||
# should be installed.
|
||||
#
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Check for non-relocatable install directories
|
||||
foreach(dir
|
||||
BINDIR
|
||||
LIBDIR
|
||||
INCLUDEDIR
|
||||
DATAROOTDIR
|
||||
DATADIR
|
||||
MANDIR
|
||||
DOCDIR
|
||||
)
|
||||
if(IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
|
||||
set(CMAKE_INSTALL_IS_NONRELOCATABLE 1)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#.rst:
|
||||
# The following CMake variables are additionally set to control install
|
||||
# policy and reporting:
|
||||
|
||||
#.rst:
|
||||
# - ``CMAKE_INSTALL_MESSAGE`` : ``LAZY``
|
||||
#
|
||||
# - Only report new or updated files installed by the ``install`` target.
|
||||
#
|
||||
set(CMAKE_INSTALL_MESSAGE LAZY)
|
||||
|
||||
#.rst:
|
||||
# An `uninstall` target is provided to assist in removing previously installed
|
||||
# files. It will not remove any installed directories per standard behaviour.
|
||||
# Note that if files are removed from the install manifest between invocations
|
||||
# of the `install` and `uninstall` targets, they will *not* be removed by the
|
||||
# latter.
|
||||
#
|
||||
include(CMakeUninstallTarget)
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
#.rst:
|
||||
# G4CMakeUtilities
|
||||
# ----------------
|
||||
#
|
||||
# Extra functions and macros for encapsulating common tasks.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
if(NOT __G4CMAKEUTILITIES_INCLUDED)
|
||||
set(__G4CMAKEUTILITIES_INCLUDED TRUE)
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
#.rst:
|
||||
# Included Modules
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module includes the following modules:
|
||||
include(CMakeDependentOption)
|
||||
include(Geant4MacroDefineModule)
|
||||
include(Geant4MacroLibraryTargets)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# CMAKE EXTENSIONS
|
||||
#-----------------------------------------------------------------------
|
||||
# macro set_ifnot(<var> <value>)
|
||||
# If variable var is not set, set its value to that provided
|
||||
#
|
||||
macro(set_ifnot _var _value)
|
||||
if(NOT ${_var})
|
||||
set(${_var} ${_value})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function enum_option(<option>
|
||||
# VALUES <value1> ... <valueN>
|
||||
# TYPE <valuetype>
|
||||
# DOC <docstring>
|
||||
# [DEFAULT <elem>]
|
||||
# [CASE_INSENSITIVE])
|
||||
# Declare a cache variable <option> that can only take values
|
||||
# listed in VALUES. TYPE may be FILEPATH, PATH or STRING.
|
||||
# <docstring> should describe that option, and will appear in
|
||||
# the interactive CMake interfaces. If DEFAULT is provided,
|
||||
# <elem> will be taken as the zero-indexed element in VALUES
|
||||
# to which the value of <option> should default to if not
|
||||
# provided. Otherwise, the default is taken as the first
|
||||
# entry in VALUES. If CASE_INSENSITIVE is present, then
|
||||
# checks of the value of <option> against the allowed values
|
||||
# will ignore the case when performing string comparison.
|
||||
#
|
||||
function(enum_option _var)
|
||||
set(options CASE_INSENSITIVE)
|
||||
set(oneValueArgs DOC TYPE DEFAULT)
|
||||
set(multiValueArgs VALUES)
|
||||
cmake_parse_arguments(_ENUMOP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# - Validation as needed arguments
|
||||
if(NOT _ENUMOP_VALUES)
|
||||
message(FATAL_ERROR "enum_option must be called with non-empty VALUES\n(Called for enum_option '${_var}')")
|
||||
endif()
|
||||
|
||||
# - Set argument defaults as needed
|
||||
if(_ENUMOP_CASE_INSENSITIVE)
|
||||
set(_ci_values )
|
||||
foreach(_elem ${_ENUMOP_VALUES})
|
||||
string(TOLOWER "${_elem}" _ci_elem)
|
||||
list(APPEND _ci_values "${_ci_elem}")
|
||||
endforeach()
|
||||
set(_ENUMOP_VALUES ${_ci_values})
|
||||
endif()
|
||||
|
||||
set_ifnot(_ENUMOP_TYPE STRING)
|
||||
set_ifnot(_ENUMOP_DEFAULT 0)
|
||||
list(GET _ENUMOP_VALUES ${_ENUMOP_DEFAULT} _default)
|
||||
|
||||
if(NOT DEFINED ${_var})
|
||||
set(${_var} ${_default} CACHE ${_ENUMOP_TYPE} "${_ENUMOP_DOC} (${_ENUMOP_VALUES})")
|
||||
else()
|
||||
set(_var_tmp ${${_var}})
|
||||
if(_ENUMOP_CASE_INSENSITIVE)
|
||||
string(TOLOWER ${_var_tmp} _var_tmp)
|
||||
endif()
|
||||
|
||||
list(FIND _ENUMOP_VALUES ${_var_tmp} _elem)
|
||||
if(_elem LESS 0)
|
||||
message(FATAL_ERROR "Value '${${_var}}' for variable ${_var} is not allowed\nIt must be selected from the set: ${_ENUMOP_VALUES} (DEFAULT: ${_default})\n")
|
||||
else()
|
||||
# - convert to lowercase
|
||||
if(_ENUMOP_CASE_INSENSITIVE)
|
||||
set(${_var} ${_var_tmp} CACHE ${_ENUMOP_TYPE} "${_ENUMOP_DOC} (${_ENUMOP_VALUES})" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GENERAL GEANT4
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_add_feature(<NAME> <DOCSTRING>)
|
||||
# Add a Geant4 feature, whose activation is specified by the
|
||||
# existence of the variable <NAME>, to the list of enabled/disabled
|
||||
# features, plus a docstring describing the feature
|
||||
#
|
||||
function(geant4_add_feature _var _description)
|
||||
if(${_var})
|
||||
set_property(GLOBAL APPEND PROPERTY GEANT4_ENABLED_FEATURES ${_var})
|
||||
else()
|
||||
set_property(GLOBAL APPEND PROPERTY GEANT4_DISABLED_FEATURES ${_var})
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY ${_var}_DESCRIPTION "${_description}")
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_print_enabled_features()
|
||||
# Print enabled Geant4 features plus their docstrings.
|
||||
#
|
||||
function(geant4_print_enabled_features)
|
||||
set(_currentFeatureText "The following Geant4 features are enabled:")
|
||||
get_property(_enabledFeatures GLOBAL PROPERTY GEANT4_ENABLED_FEATURES)
|
||||
|
||||
foreach(_feature ${_enabledFeatures})
|
||||
set(_currentFeatureText "${_currentFeatureText}\n${_feature}")
|
||||
|
||||
get_property(_desc GLOBAL PROPERTY ${_feature}_DESCRIPTION)
|
||||
|
||||
if(_desc)
|
||||
set(_currentFeatureText "${_currentFeatureText}: ${_desc}")
|
||||
set(_desc NOTFOUND)
|
||||
endif(_desc)
|
||||
endforeach(_feature)
|
||||
|
||||
message(STATUS "${_currentFeatureText}\n")
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GEANT4 DATASETS
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_latest_version(<dir> <name> <output variable>)
|
||||
# Locate latest version of dataset <name> in <dir>, setting value
|
||||
# of output variable to the full path to the dataset
|
||||
#
|
||||
function(geant4_latest_version dir name var)
|
||||
file(GLOB files RELATIVE ${dir} ${dir}/${name}*)
|
||||
set(newer)
|
||||
foreach(file ${files})
|
||||
string(REPLACE ${name} "" version ${file})
|
||||
if("${version}" VERSION_GREATER "${newer}")
|
||||
set(newer ${version})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${var} ${dir}/${name}${newer} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GEANT4 TESTING
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_add_unit_tests(test1 test2 ... [dir1 ...]
|
||||
# INCLUDE_DIRS dir1 dir2 ...
|
||||
# LIBRARIES library1 library2 ...)
|
||||
#
|
||||
function(geant4_add_unit_tests)
|
||||
cmake_parse_arguments(ARG "" "" "INCLUDE_DIRS;LIBRARIES" ${ARGN})
|
||||
|
||||
foreach(incdir ${ARG_INCLUDE_DIRS})
|
||||
if(IS_ABSOLUTE ${incdir})
|
||||
include_directories(${incdir})
|
||||
else()
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/${incdir})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(ARG_UNPARSED_ARGUMENTS)
|
||||
set(tnames ${ARG_UNPARSED_ARGUMENTS})
|
||||
else()
|
||||
set(tnames test*.cc)
|
||||
endif()
|
||||
|
||||
set(alltests)
|
||||
foreach(tname ${tnames})
|
||||
if(tname STREQUAL ".")
|
||||
set(tests ".")
|
||||
else()
|
||||
file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${tname})
|
||||
endif()
|
||||
set(alltests ${alltests} ${tests})
|
||||
endforeach()
|
||||
|
||||
if(NOT TARGET tests)
|
||||
add_custom_target(tests)
|
||||
endif()
|
||||
|
||||
foreach(test ${alltests})
|
||||
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${test})
|
||||
file(GLOB sources ${test}/src/*.cc)
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${test}/include)
|
||||
file(GLOB test ${test}/*.cc)
|
||||
else()
|
||||
set(sources)
|
||||
endif()
|
||||
get_filename_component(name ${test} NAME_WE)
|
||||
add_executable(${name} EXCLUDE_FROM_ALL ${test} ${sources})
|
||||
target_link_libraries(${name} ${ARG_LIBRARIES})
|
||||
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name})
|
||||
add_dependencies(tests ${name})
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
set_property(TEST ${name} PROPERTY LABELS UnitTests)
|
||||
set_property(TEST ${name} PROPERTY TIMEOUT 60)
|
||||
endforeach()
|
||||
endfunction()
|
||||
@@ -0,0 +1,282 @@
|
||||
#.rst:
|
||||
# G4ConfigureCMakeHelpers
|
||||
# -----------------------
|
||||
#
|
||||
# This module configures and installs CMake modules allowing clients
|
||||
# to find and use Geant4 libraries using CMake's find_package command.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Collect all global variables we need to export to the config files
|
||||
# Do this here for now, later on we could collect them as we go.
|
||||
#
|
||||
|
||||
# Compiler flags (because user apps are a bit dependent on them...)
|
||||
set(GEANT4_COMPILER_FLAG_HINTS "#
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(Geant4_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${GEANT4_CXXSTD_FLAGS}\")
|
||||
set(Geant4_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\")")
|
||||
|
||||
foreach(_mode DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
|
||||
set(GEANT4_COMPILER_FLAG_HINTS "${GEANT4_COMPILER_FLAG_HINTS}
|
||||
set(Geant4_CXX_FLAGS_${_mode} \"${CMAKE_CXX_FLAGS_${_mode}}\")")
|
||||
endforeach()
|
||||
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(GEANT4_COMPILER_FLAG_HINTS "${GEANT4_COMPILER_FLAG_HINTS}
|
||||
set(Geant4_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")")
|
||||
endif()
|
||||
|
||||
# Core compile definitions...
|
||||
set(GEANT4_CORE_DEFINITIONS )
|
||||
|
||||
# Third party includes (libraries *should* be handled by the imports)
|
||||
set(GEANT4_THIRD_PARTY_INCLUDES )
|
||||
|
||||
# Imports of third party packages used with imported targets
|
||||
set(GEANT4_THIRD_PARTY_IMPORT_SETUP )
|
||||
|
||||
# Externals libraries that may be present
|
||||
set(GEANT4_EXTERNALS_TARGETS )
|
||||
|
||||
# - Stuff from Geant4LibraryBuildOptions.cmake
|
||||
if(GEANT4_BUILD_STORE_TRAJECTORY)
|
||||
list(APPEND GEANT4_CORE_DEFINITIONS -DG4_STORE_TRAJECTORY)
|
||||
endif()
|
||||
|
||||
if(GEANT4_BUILD_VERBOSE_CODE)
|
||||
list(APPEND GEANT4_CORE_DEFINITIONS -DG4VERBOSE)
|
||||
endif()
|
||||
|
||||
# - Stuff from Geant4OptionalComponents.cmake
|
||||
# - CLHEP
|
||||
# If it's internal, add it to the externals list
|
||||
if(NOT GEANT4_USE_SYSTEM_CLHEP)
|
||||
list(APPEND GEANT4_EXTERNALS_TARGETS G4clhep)
|
||||
endif()
|
||||
|
||||
# - Expat
|
||||
# If it's internal, add it to the externals list
|
||||
if(NOT GEANT4_USE_SYSTEM_EXPAT)
|
||||
list(APPEND GEANT4_EXTERNALS_TARGETS G4expat)
|
||||
endif()
|
||||
|
||||
# - ZLIB
|
||||
# If it's internal, add it to the externals list
|
||||
if(NOT GEANT4_USE_SYSTEM_ZLIB)
|
||||
list(APPEND GEANT4_EXTERNALS_TARGETS G4zlib)
|
||||
endif()
|
||||
|
||||
# - GDML
|
||||
# Need to include Xerces-C headers becuase these do appear in the public
|
||||
# interface of GDML. The library should then be in the LINK_INTERFACE of
|
||||
# persistency...
|
||||
if(GEANT4_USE_GDML)
|
||||
list(APPEND GEANT4_THIRD_PARTY_INCLUDES ${XERCESC_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# - USolids
|
||||
# Compile definitions
|
||||
if(GEANT4_USE_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
|
||||
set(GEANT4_USE_USOLIDS_EITHER ON)
|
||||
list(APPEND GEANT4_CORE_DEFINITIONS ${GEANT4_USOLIDS_COMPILE_DEFINITIONS})
|
||||
|
||||
# System USolids headers, because these do appear in Geant4's
|
||||
# public interface. The library should be in the link interface
|
||||
# of G4geometry (may need refinding)
|
||||
list(APPEND GEANT4_THIRD_PARTY_INCLUDES "${USOLIDS_INCLUDE_DIRS} ${VECGEOM_EXTERNAL_INCLUDES}")
|
||||
endif()
|
||||
|
||||
# - Stuff from Geant4InterfaceOptions.cmake
|
||||
if(GEANT4_USE_QT)
|
||||
list(APPEND GEANT4_THIRD_PARTY_INCLUDES
|
||||
${QT_INCLUDE_DIR}
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
${QT_QTGUI_INCLUDE_DIR}
|
||||
${QT_QTOPENGL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# On WIN32, re-import the Qt targets.
|
||||
if(WIN32)
|
||||
set(GEANT4_QT4_IMPORT_SETUP "
|
||||
# Qt reimport on WIN32
|
||||
set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE})
|
||||
set(QT_USE_IMPORTED_TARGETS ON)
|
||||
find_package(Qt4 REQUIRED)
|
||||
")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Generate Build Tree Configuration Files
|
||||
#-----------------------------------------------------------------------
|
||||
# Set needed variables for the build tree
|
||||
set(GEANT4_CMAKE_DIR "${PROJECT_BINARY_DIR}")
|
||||
|
||||
# Set include path for build tree. This is always an absolute path, or
|
||||
# rather paths. We extract the paths from the global
|
||||
# GEANT4_BUILDTREE_INCLUDE_DIRS property and use this to create the
|
||||
# header setup
|
||||
#
|
||||
get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
|
||||
GEANT4_BUILDTREE_INCLUDE_DIRS
|
||||
)
|
||||
|
||||
set(GEANT4_INCLUDE_DIR_SETUP "
|
||||
# Geant4 configured for use from the build tree - absolute paths are used.
|
||||
set(Geant4_INCLUDE_DIR ${__geant4_buildtree_include_dirs})
|
||||
")
|
||||
|
||||
set(GEANT4_MODULE_PATH_SETUP "
|
||||
# Geant4 configured for use CMake modules from source tree
|
||||
set(CMAKE_MODULE_PATH \${CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH})
|
||||
")
|
||||
|
||||
# Geant4 data used in build tree
|
||||
geant4_export_datasets(BUILD GEANT4_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Export targets from the build tree. We rely on the GEANT4_EXPORTED_TARGETS
|
||||
# global property to list these for us.
|
||||
#
|
||||
get_property(__geant4_exported_targets GLOBAL PROPERTY GEANT4_EXPORTED_TARGETS)
|
||||
|
||||
export(TARGETS ${__geant4_exported_targets}
|
||||
FILE ${PROJECT_BINARY_DIR}/Geant4LibraryDepends.cmake
|
||||
)
|
||||
|
||||
# Configure the build tree config file...
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4Config.cmake.in
|
||||
${PROJECT_BINARY_DIR}/Geant4Config.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Configure the build tree versioning file
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4ConfigVersion.cmake.in
|
||||
${PROJECT_BINARY_DIR}/Geant4ConfigVersion.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Copy the custom modules into the build tree
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules/IntelCompileFeatures.cmake
|
||||
${PROJECT_BINARY_DIR}/Modules/IntelCompileFeatures.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
foreach(_mod AIDA HepMC Pythia6 ROOT StatTest TBB)
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules/Find${_mod}.cmake
|
||||
${PROJECT_BINARY_DIR}/Modules/Find${_mod}.cmake
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Copy the Main and Internal Use file into the build tree
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4.cmake
|
||||
${PROJECT_BINARY_DIR}/UseGeant4.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4_internal.cmake
|
||||
${PROJECT_BINARY_DIR}/UseGeant4_internal.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Generate Install Tree Configuration Files
|
||||
#-----------------------------------------------------------------------
|
||||
# Set needed variables for the install tree
|
||||
set(GEANT4_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION})
|
||||
|
||||
# Header path for install tree is dependent on whether we have a relocatable
|
||||
# install.
|
||||
if(CMAKE_INSTALL_IS_NONRELOCATABLE)
|
||||
# Use ABSOLUTE paths...
|
||||
set(GEANT4_INCLUDE_DIR_SETUP "
|
||||
# Geant4 configured for the install tree with absolute paths, so use these
|
||||
set(Geant4_INCLUDE_DIR \"${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4\")
|
||||
")
|
||||
else()
|
||||
# Use RELATIVE paths... Where we measure relative to GEANT4_CMAKE_DIR
|
||||
file(RELATIVE_PATH GEANT4_RELATIVE_HEADER_PATH
|
||||
${CMAKE_INSTALL_PREFIX}/${GEANT4_CMAKE_DIR}
|
||||
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
)
|
||||
|
||||
set(GEANT4_INCLUDE_DIR_SETUP "
|
||||
# Geant4 configured for the install with relative paths, so use these
|
||||
get_filename_component(Geant4_INCLUDE_DIR \"\${_geant4_thisdir}/${GEANT4_RELATIVE_HEADER_PATH}\" ABSOLUTE)
|
||||
")
|
||||
endif()
|
||||
|
||||
set(GEANT4_MODULE_PATH_SETUP)
|
||||
|
||||
# Geant4 data used in install tree
|
||||
geant4_export_datasets(INSTALL GEANT4_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Install exported targets file for the install tree - we just install
|
||||
# the named export
|
||||
install(EXPORT Geant4LibraryDepends
|
||||
DESTINATION ${GEANT4_CMAKE_DIR}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
# Configure the install tree config file...
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4Config.cmake.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4Config.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Configure the install tree config versioning file...
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4ConfigVersion.cmake.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4ConfigVersion.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install the config, config versioning and use files
|
||||
install(FILES
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4Config.cmake
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4ConfigVersion.cmake
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4.cmake
|
||||
DESTINATION ${GEANT4_CMAKE_DIR}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
# Install the custom modules for the examples
|
||||
install(DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/Modules
|
||||
DESTINATION ${GEANT4_CMAKE_DIR}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
@@ -0,0 +1,974 @@
|
||||
#.rst:
|
||||
# G4ConfigureGNUMakeHelpers
|
||||
# -------------------------
|
||||
#
|
||||
# This module configures and installs GNU Makefile fragments which
|
||||
# clients can include in their Makefiles to utilize Geant4's
|
||||
# Make-based application building toolchain.
|
||||
#
|
||||
# The GNU make based buildsystem for Geant4 provides a toolchain for
|
||||
# users building simple Geant4 applications. The old style build and
|
||||
# install of Geant4 provides a customized set of non-standard install
|
||||
# paths with use of the toolchain dependent on environment variables
|
||||
# pointing to the install paths.
|
||||
#
|
||||
# This script processes information on the CMake install paths, system
|
||||
# and compiler to determine the following variables for backward
|
||||
# compatibility:
|
||||
#
|
||||
# GEANT4_SYSTEM Old style system name, e.g. 'Linux', 'Darwin'
|
||||
# or 'WIN32'
|
||||
#
|
||||
# GEANT4_COMPILER Old system compiler id, e.g. 'g++', 'VC'.
|
||||
#
|
||||
# G4INSTALL Location of 'config' subdirectory which contains
|
||||
# all the GNU make toolchain fragments
|
||||
#
|
||||
# G4INCLUDE Old style path to location of Geant4 headers
|
||||
#
|
||||
# G4LIB Old style library directory path. Rather than
|
||||
# containing the actual libraries, it is expected to
|
||||
# contain subdirectories named
|
||||
# GEANT4_SYSTEM-GEANT4_COMPILER
|
||||
#
|
||||
# These variables are used in a CMake configuration file which is used
|
||||
# to generate shell scripts (C and Bourne flavour) the user can source
|
||||
# to set up their environment for use of the old toolchain.
|
||||
# These replace the old 'env.(c)sh' scripts to allow users to work with
|
||||
# the new CMake built libraries transparently if their application
|
||||
# relies on the old style toolchain.
|
||||
#
|
||||
# The scripts are generated for both the build and install trees so that
|
||||
# developers wishing to write test applications do not have to install
|
||||
# their fresh build of Geant4.
|
||||
#
|
||||
# Compatibility with the library path style:
|
||||
#
|
||||
# <prefix>/lib/G4SYSTEM-G4COMPILER
|
||||
#
|
||||
# is provided by installing a directory 'geant4-<version>' in the
|
||||
# <prefix>/lib directory and creating a symbolic link inside here
|
||||
# pointing up one directory level.
|
||||
# This will not work on Windows however, and here users are recommended
|
||||
# to use Visual Studio directly, or to use CMake for application
|
||||
# configuration.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GEANT4GMAKE
|
||||
# On Unices, we try to make the output directory backward compatible
|
||||
# with the old style 'SYSTEM-COMPILER' format so that applications may be
|
||||
# built against the targets in the build tree.
|
||||
#
|
||||
# Note that for multi-configuration generators like VS and Xcode, these
|
||||
# directories will have the configuration type (e.g. Debug) appended to
|
||||
# them, so are not backward compatible with the old Make toolchain in
|
||||
# these cases.
|
||||
#
|
||||
# Also, we only do this on UNIX because we don't support Geant4GMake on
|
||||
# Windows and also want to avoid mixing static and dynamic libraries on
|
||||
# windows until the differences are better understood.
|
||||
#------------------------------------------------------------------------
|
||||
# Determine the backward compatible system name
|
||||
#
|
||||
if(NOT WIN32)
|
||||
set(GEANT4_SYSTEM ${CMAKE_SYSTEM_NAME})
|
||||
else()
|
||||
set(GEANT4_SYSTEM "WIN32")
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Determine the backward compatible compiler name
|
||||
# NB: At present Clang detection only works on CMake > 2.8.1
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(GEANT4_COMPILER "g++")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
set(GEANT4_COMPILER "clang")
|
||||
|
||||
# - Newer g++ on OS X may identify as Clang
|
||||
if(APPLE AND (CMAKE_CXX_COMPILER MATCHES ".*g\\+\\+"))
|
||||
set(GEANT4_COMPILER "g++")
|
||||
endif()
|
||||
|
||||
elseif(MSVC)
|
||||
set(GEANT4_COMPILER "VC")
|
||||
elseif(CMAKE_CXX_COMPILER MATCHES "icpc.*|icc.*")
|
||||
set(GEANT4_COMPILER "icc")
|
||||
else()
|
||||
set(GEANT4_COMPILER "UNSUPPORTED")
|
||||
endif()
|
||||
|
||||
# - Create libdir/softlink to fool geant4make, but only for single mode case
|
||||
if(UNIX AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink . ${GEANT4_SYSTEM}-${GEANT4_COMPILER}
|
||||
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Functions and Macros to help configuration of shell scripts.
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_shell_setup(<shell>)
|
||||
# Set shell parameters such as program, family and common builtins
|
||||
# for supplied shell (e.g. 'bourne' or 'cshell'
|
||||
#
|
||||
macro(_g4tc_shell_setup SHELL_FAMILY)
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
set(GEANT4_TC_SHELL_PROGRAM "/bin/sh")
|
||||
set(GEANT4_TC_SHELL_FAMILY "Bourne shell")
|
||||
set(GEANT4_TC_UNSET_COMMAND "unset")
|
||||
set(GEANT4_TC_SHELL_EXTENSION ".sh")
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(GEANT4_TC_SHELL_PROGRAM "/bin/csh")
|
||||
set(GEANT4_TC_SHELL_FAMILY "C shell")
|
||||
set(GEANT4_TC_UNSET_COMMAND "unsetenv")
|
||||
set(GEANT4_TC_SHELL_EXTENSION ".csh")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported shell '${SHELL_FAMILY}'")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_selflocate(<output> <shell> <script> <variable name>)
|
||||
# Set output to string containing shell commands needed to
|
||||
# locate the directory in which script is located if the
|
||||
# script is sourced. This derived location is set as the
|
||||
# value of the shell variable name.
|
||||
#
|
||||
function(_g4tc_selflocate TEMPLATE_NAME SHELL_FAMILY SCRIPT_NAME LOCATION_VARIABLE)
|
||||
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
|
||||
if [ ! -f ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ]; then
|
||||
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 'To fix this issue, cd to the directory containing this script'
|
||||
echo 'and source it in that directory.'
|
||||
return 1
|
||||
fi
|
||||
${LOCATION_VARIABLE}=\$\(pwd\)
|
||||
else
|
||||
g4sls_sourced_dir=\$\(dirname \${BASH_ARGV[0]}\)
|
||||
${LOCATION_VARIABLE}=$\(cd \$g4sls_sourced_dir > /dev/null ; pwd\)
|
||||
fi
|
||||
"
|
||||
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)
|
||||
|
||||
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(${TEMPLATE_NAME}
|
||||
"# Self locate script when sourced
|
||||
# If sourced interactively, we can use $_ as this should be
|
||||
#
|
||||
# source path_to_script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
#
|
||||
unset g4sls_sourced_dir
|
||||
unset ${LOCATION_VARIABLE}
|
||||
|
||||
set ARGS=($_)
|
||||
if (\"$ARGS\" != \"\") then
|
||||
if (\"$ARGS[2]\" =~ */${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}) then
|
||||
set g4sls_sourced_dir=\"`dirname \${ARGS[2]}`\"
|
||||
endif
|
||||
endif
|
||||
|
||||
if (! \$?g4sls_sourced_dir) then
|
||||
# Oh great, we were sourced non-interactively. This means that $_
|
||||
# won't be set, so we need an external source of information on
|
||||
# where the script is located.
|
||||
# We obtain this in one of two ways:
|
||||
# 1) Current directory:
|
||||
# cd script_dir ; source ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
#
|
||||
# 2) Supply the directory as an argument to the script:
|
||||
# source script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} script_dir
|
||||
#
|
||||
if ( -e ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ) then
|
||||
set g4sls_sourced_dir=\"`pwd`\"
|
||||
else if ( \"\$1\" != \"\" ) then
|
||||
if ( -e \${1}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ) then
|
||||
set g4sls_sourced_dir=\${1}
|
||||
else
|
||||
echo \"ERROR \${1} does not contain a Geant4 installation\"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if (! \$?g4sls_sourced_dir) then
|
||||
echo \"ERROR: ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} could NOT self-locate Geant4 installation\"
|
||||
echo \"because it was sourced (i.e. embedded) in another script.\"
|
||||
echo \"This is due to limitations of (t)csh but can be worked around by providing\"
|
||||
echo \"the directory where ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} is located\"
|
||||
echo \"to it, either via cd-ing to the directory before sourcing:\"
|
||||
echo \" cd where_script_is ; source ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}\"
|
||||
echo \"or by supplying the directory as an argument to the script:\"
|
||||
echo \" source where_script_is/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} where_script_is\"
|
||||
echo \" \"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
set ${LOCATION_VARIABLE}=\"`cd \${g4sls_sourced_dir} > /dev/null ; pwd`\"
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
# For C-shell, set the values of the guard variables
|
||||
set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
|
||||
set(GEANT4_TC_ENDIF_SELFLOCATED "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_setenv_command(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# set an environment variable with name and value
|
||||
#
|
||||
function(_g4tc_setenv_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_VALUE)
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
set(${TEMPLATE_NAME}
|
||||
"export ${VARIABLE_NAME}=${VARIABLE_VALUE}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(${TEMPLATE_NAME}
|
||||
"setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_setenv_ifnotset_command(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# set an environment variable with name and value if the
|
||||
# variable is not already set
|
||||
#
|
||||
function(_g4tc_setenv_ifnotset_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_VALUE)
|
||||
# -- bourne
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
# Have to make this section verbatim to get correct formatting
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if test \"x\$${VARIABLE_NAME}\" = \"x\" ; then
|
||||
export ${VARIABLE_NAME}=${VARIABLE_VALUE}
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# -- cshell
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, verbatim to get correct formatting...
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${VARIABLE_NAME}} ) then
|
||||
setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}
|
||||
endif
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_prepend_path(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# prepend supplied value to the path style environment variable
|
||||
# name (e.g. 'PATH')
|
||||
#
|
||||
function(_g4tc_prepend_path TEMPLATE_NAME SHELL_FAMILY PATH_VARIABLE
|
||||
APPEND_VARIABLE)
|
||||
# -- bourne block
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
# We have to make this section verbatim
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if test \"x\$${PATH_VARIABLE}\" = \"x\" ; then
|
||||
export ${PATH_VARIABLE}=${APPEND_VARIABLE}
|
||||
else
|
||||
export ${PATH_VARIABLE}=${APPEND_VARIABLE}:\${${PATH_VARIABLE}}
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# -- cshell block
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, this is verbatim so final output is formatted correctly
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${PATH_VARIABLE}} ) then
|
||||
setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}
|
||||
else
|
||||
setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}:\${${PATH_VARIABLE}}
|
||||
endif
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_append_path(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# append supplied value to the path style environment variable
|
||||
# name (e.g. 'PATH')
|
||||
#
|
||||
function(_g4tc_append_path TEMPLATE_NAME SHELL_FAMILY PATH_VARIABLE
|
||||
APPEND_VARIABLE)
|
||||
# -- bourne block
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
# We have to make this section verbatim
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if test \"x\$${PATH_VARIABLE}\" = \"x\" ; then
|
||||
export ${PATH_VARIABLE}=${APPEND_VARIABLE}
|
||||
else
|
||||
export ${PATH_VARIABLE}=\${${PATH_VARIABLE}}:${APPEND_VARIABLE}
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# -- cshell block
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, this is verbatim so final output is formatted correctly
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${PATH_VARIABLE}} ) then
|
||||
setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}
|
||||
else
|
||||
setenv ${PATH_VARIABLE} \${${PATH_VARIABLE}}:${APPEND_VARIABLE}
|
||||
endif
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# MACRO(_g4tc_configure_tc_variables)
|
||||
# Macro to perform the actual setting of the low level toolchain variables
|
||||
# which need to be set in the final shell files.
|
||||
# We do this in a separate macro so that we can wrap it in different ways for
|
||||
# the install and build trees.
|
||||
#
|
||||
macro(_g4tc_configure_tc_variables SHELL_FAMILY SCRIPT_NAME)
|
||||
# - Set up the requested shell
|
||||
_g4tc_shell_setup(${SHELL_FAMILY})
|
||||
|
||||
# - Locate self
|
||||
_g4tc_selflocate(GEANT4_TC_LOCATE_SELF_COMMAND ${SHELL_FAMILY} ${SCRIPT_NAME} geant4make_root)
|
||||
|
||||
|
||||
# - Standard Setup and Paths
|
||||
_g4tc_setenv_command(GEANT4_TC_G4SYSTEM ${SHELL_FAMILY} G4SYSTEM ${G4SYSTEM})
|
||||
_g4tc_setenv_command(GEANT4_TC_G4INSTALL ${SHELL_FAMILY} G4INSTALL ${G4INSTALL})
|
||||
_g4tc_setenv_command(GEANT4_TC_G4INCLUDE ${SHELL_FAMILY} G4INCLUDE ${G4INCLUDE})
|
||||
|
||||
_g4tc_prepend_path(GEANT4_TC_G4BIN_PATH_SETUP ${SHELL_FAMILY} PATH ${G4BIN_DIR})
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB ${SHELL_FAMILY} G4LIB ${G4LIB})
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
_g4tc_prepend_path(GEANT4_TC_G4LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH ${G4LIB_DIR})
|
||||
endif()
|
||||
|
||||
_g4tc_setenv_ifnotset_command(GEANT4_TC_G4WORKDIR_SETUP ${SHELL_FAMILY} G4WORKDIR ${G4WORKDIR_DEFAULT})
|
||||
_g4tc_prepend_path(GEANT4_TC_G4WORKDIR_PATH_SETUP ${SHELL_FAMILY} PATH
|
||||
\${G4WORKDIR}/bin/\${G4SYSTEM})
|
||||
|
||||
# - Geant4 Library build setup
|
||||
# We prefer shared libs if these are built, otherwise fall back to static
|
||||
# On Win32, we also want DLLs?
|
||||
if(BUILD_SHARED_LIBS)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_BUILD_SHARED ${SHELL_FAMILY} G4LIB_BUILD_SHARED 1)
|
||||
if(WIN32)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_DLL ${SHELL_FAMILY} G4LIB_USE_DLL 1)
|
||||
endif()
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_BUILD_STATIC ${SHELL_FAMILY} G4LIB_BUILD_STATIC 1)
|
||||
endif()
|
||||
|
||||
# - Multithreading
|
||||
if(GEANT4_BUILD_MULTITHREADED)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4MULTITHREADED ${SHELL_FAMILY} G4MULTITHREADED 1)
|
||||
endif()
|
||||
|
||||
# - Resource file paths
|
||||
set(GEANT4_TC_DATASETS )
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
_g4tc_setenv_command(_dssetenvcmd ${SHELL_FAMILY} ${${_ds}_ENVVAR} ${${_ds}_PATH})
|
||||
set(GEANT4_TC_DATASETS "${GEANT4_TC_DATASETS}${_dssetenvcmd}\n")
|
||||
endforeach()
|
||||
|
||||
set(GEANT4_TC_TOOLS_FONT_PATH "# FREETYPE SUPPORT NOT AVAILABLE")
|
||||
if(GEANT4_USE_FREETYPE)
|
||||
_g4tc_prepend_path(GEANT4_TC_TOOLS_FONT_PATH
|
||||
${SHELL_FAMILY}
|
||||
TOOLS_FONT_PATH
|
||||
"${TOOLS_FONT_PATH}"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# - CLHEP...
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
# Have to use detected CLHEP paths to set base dir and others
|
||||
get_filename_component(_CLHEP_INCLUDE_DIR "${CLHEP_INCLUDE_DIR}" REALPATH)
|
||||
get_filename_component(_CLHEP_BASE_DIR "${_CLHEP_INCLUDE_DIR}" DIRECTORY)
|
||||
|
||||
# Handle granular vs singular cases
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::Vector LOCATION)
|
||||
else()
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
|
||||
endif()
|
||||
|
||||
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
|
||||
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
|
||||
|
||||
set(GEANT4_TC_G4LIB_USE_CLHEP "# USING SYSTEM CLHEP")
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_BASE_DIR ${SHELL_FAMILY} CLHEP_BASE_DIR "${_CLHEP_BASE_DIR}")
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_INCLUDE_DIR ${SHELL_FAMILY} CLHEP_INCLUDE_DIR "${_CLHEP_INCLUDE_DIR}")
|
||||
|
||||
# Only need to handle CLHEP_LIB for granular case
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES )
|
||||
foreach(_clhep_lib ${CLHEP_LIBRARIES})
|
||||
get_target_property(_CLHEP_LIB_NAME ${_clhep_lib} LOCATION)
|
||||
get_filename_component(_curlib "${_CLHEP_LIB_NAME}" NAME)
|
||||
string(REGEX REPLACE "^lib(.*)\\.(so|a|dylib|lib|dll)$" "\\1" _curlib "${_curlib}")
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES} -l${_curlib}")
|
||||
endforeach()
|
||||
|
||||
# Strip first "-l" as that's prepended by Geant4Make
|
||||
string(REGEX REPLACE "^ *\\-l" "" G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES}")
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_LIB ${SHELL_FAMILY} CLHEP_LIB "\"${G4_SYSTEM_CLHEP_LIBRARIES}\"")
|
||||
endif()
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_LIB_DIR ${SHELL_FAMILY} CLHEP_LIB_DIR ${_CLHEP_LIB_DIR})
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
_g4tc_prepend_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH \${CLHEP_LIB_DIR})
|
||||
endif()
|
||||
|
||||
else()
|
||||
# We have to configure things to point to the internal CLHEP...
|
||||
# Probably sufficient to do nothing...
|
||||
set(GEANT4_TC_G4LIB_USE_CLHEP "# USING INTERNAL CLHEP")
|
||||
endif()
|
||||
|
||||
# - EXPAT
|
||||
if(GEANT4_USE_SYSTEM_EXPAT)
|
||||
set(GEANT4_TC_G4LIB_USE_EXPAT "# USING SYSTEM EXPAT")
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_EXPAT ${SHELL_FAMILY} G4LIB_USE_EXPAT 1)
|
||||
endif()
|
||||
|
||||
# - ZLIB...
|
||||
if(GEANT4_USE_SYSTEM_ZLIB)
|
||||
set(GEANT4_TC_G4LIB_USE_ZLIB "# USING SYSTEM ZLIB")
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_ZLIB ${SHELL_FAMILY} G4LIB_USE_ZLIB 1)
|
||||
endif()
|
||||
|
||||
# - GDML...
|
||||
if(GEANT4_USE_GDML)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_GDML ${SHELL_FAMILY} G4LIB_USE_GDML 1)
|
||||
# Backward compatibility requires XERCESCROOT to be set
|
||||
# As this is a 'rootdir' determine it from the XERCESC_INCLUDE_DIR
|
||||
# variable...
|
||||
get_filename_component(_xercesc_root ${XERCESC_INCLUDE_DIR} PATH)
|
||||
_g4tc_setenv_command(GEANT4_TC_GDML_PATH_SETUP ${SHELL_FAMILY} XERCESCROOT ${_xercesc_root})
|
||||
else()
|
||||
set(GEANT4_TC_G4LIB_USE_GDML "# NOT BUILT WITH GDML SUPPORT")
|
||||
endif()
|
||||
|
||||
# - G3TOG4...
|
||||
if(GEANT4_USE_G3TOG4)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_G3TOG4 ${SHELL_FAMILY} G4LIB_USE_G3TOG4 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4LIB_USE_G3TOG4 "# NOT BUILT WITH G3TOG4 SUPPORT")
|
||||
endif()
|
||||
|
||||
# - USolids/VecGeom
|
||||
if(GEANT4_USE_USOLIDS)
|
||||
# Derive base dir from include path, NB, not 100% robust as Geant4GNUmake makes
|
||||
# significant assumptions about how USolids was installed
|
||||
get_filename_component(_USOLIDS_INCLUDE_DIR "${USOLIDS_INCLUDE_DIRS}" REALPATH)
|
||||
get_filename_component(_USOLIDS_BASE_DIR "${_USOLIDS_INCLUDE_DIR}" DIRECTORY)
|
||||
_g4tc_setenv_command(GEANT4_TC_USOLIDS_BASE_DIR ${SHELL_FAMILY} USOLIDS_BASE_DIR "${_USOLIDS_BASE_DIR}")
|
||||
|
||||
if(GEANT4_USE_ALL_USOLIDS)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_USOLIDS ${SHELL_FAMILY} G4GEOM_USE_USOLIDS 1)
|
||||
set(GEANT4_TC_G4GEOM_USE_PARTIAL_USOLIDS "# FULL USOLIDS REPLACEMENT")
|
||||
else()
|
||||
set(GEANT4_TC_G4GEOM_USE_USOLIDS "# PARTIAL USOLIDS REPLACEMENT")
|
||||
_g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_PARTIAL_USOLIDS ${SHELL_FAMILY} G4GEOM_USE_PARTIAL_USOLIDS 1)
|
||||
foreach(__g4_usolid_shape ${GEANT4_USE_PARTIAL_USOLIDS_SHAPE_LIST})
|
||||
_g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_U${__g4_usolid_shape} ${SHELL_FAMILY} G4GEOM_USE_U${__g4_usolid_shape} 1)
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
set(GEANT4_TC_USOLIDS_BASE_DIR "# NOT BUILT WITH USOLIDS SUPPORT")
|
||||
endif()
|
||||
|
||||
# - USER INTERFACE AND VISUALIZATION MODULES...
|
||||
# - Terminals
|
||||
if(NOT WIN32)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_TCSH ${SHELL_FAMILY} G4UI_USE_TCSH 1)
|
||||
set(GEANT4_TC_G4UI_USE_WIN32 "# WIN32 TERMINAL UI NOT AVAILABLE ON ${CMAKE_SYSTEM_NAME}")
|
||||
else()
|
||||
set(GEANT4_TC_G4UI_USE_TCSH "# TCSH TERMINAL UI NOT AVAILABLE ON ${CMAKE_SYSTEM_NAME}")
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_WIN32 ${SHELL_FAMILY} G4UI_USE_WIN32 1)
|
||||
endif()
|
||||
|
||||
# - Qt UI AND VIS
|
||||
if(GEANT4_USE_QT)
|
||||
_g4tc_setenv_command(GEANT4_TC_QTHOME ${SHELL_FAMILY} QTHOME ${G4QTHOME})
|
||||
_g4tc_setenv_command(GEANT4_TC_QTLIBPATH ${SHELL_FAMILY} QTLIBPATH ${G4QTLIBPATH})
|
||||
if(QT4_FOUND)
|
||||
set(GEANT4_TC_QTLIBS "#Geant4Make automatically handles QTLIBS for Qt4")
|
||||
set(GEANT4_TC_GLQTLIBS "#Geant4Make automatically handles GLQTLIBS for Qt4")
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_QTLIBS ${SHELL_FAMILY} QTLIBS "\"-L${G4QTLIBPATH} ${G4QTLIBLIST}\"")
|
||||
_g4tc_setenv_command(GEANT4_TC_GLQTLIBS ${SHELL_FAMILY} GLQTLIBS "\"-L${G4QTLIBPATH} ${G4GLQTLIBLIST}\"")
|
||||
endif()
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_QT ${SHELL_FAMILY} G4UI_USE_QT 1)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLQT ${SHELL_FAMILY} G4VIS_USE_OPENGLQT 1)
|
||||
|
||||
# Dynamic loader path
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
_g4tc_prepend_path(GEANT4_TC_QT_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH \${QTLIBPATH})
|
||||
endif()
|
||||
else()
|
||||
set(GEANT4_TC_G4UI_USE_QT "# NOT BUILT WITH QT INTERFACE")
|
||||
endif()
|
||||
|
||||
# - XM UI AND VIS
|
||||
if(GEANT4_USE_XM)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_XM ${SHELL_FAMILY} G4UI_USE_XM 1)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLXM ${SHELL_FAMILY} G4VIS_USE_OPENGLXM 1)
|
||||
|
||||
# Might need library setup, but for now recommend system install....
|
||||
else()
|
||||
set(GEANT4_TC_G4UI_USE_XM "# NOT BUILT WITH XM INTERFACE")
|
||||
endif()
|
||||
|
||||
# - Network DAWN
|
||||
if(GEANT4_USE_NETWORKDAWN)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_DAWN ${SHELL_FAMILY} G4VIS_USE_DAWN 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_DAWN "# NOT BUILT WITH NETWORK DAWN SUPPORT")
|
||||
endif()
|
||||
|
||||
# - Network VRML
|
||||
if(GEANT4_USE_NETWORKVRML)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_VRML ${SHELL_FAMILY} G4VIS_USE_VRML 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_VRML "# NOT BUILT WITH NETWORK VRML SUPPORT")
|
||||
endif()
|
||||
|
||||
# - OpenInventor
|
||||
if(GEANT4_USE_INVENTOR)
|
||||
if(UNIX)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENINVENTOR ${SHELL_FAMILY} G4VIS_USE_OIX 1)
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENINVENTOR ${SHELL_FAMILY} G4VIS_USE_OIWIN32 1)
|
||||
endif()
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_OPENINVENTOR "# NOT BUILT WITH INVENTOR SUPPORT")
|
||||
endif()
|
||||
|
||||
|
||||
# - X11 OpenGL
|
||||
if(GEANT4_USE_OPENGL_X11)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLX ${SHELL_FAMILY} G4VIS_USE_OPENGLX 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_OPENGLX "# NOT BUILT WITH OPENGL(X11) SUPPORT")
|
||||
endif()
|
||||
|
||||
# - WIN32 OpenGL
|
||||
if(GEANT4_USE_OPENGL_WIN32)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENWIN32 ${SHELL_FAMILY} G4VIS_USE_OPENWIN32 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_OPENGLWIN32 "# NOT BUILT WITH OPENGL(WIN32) SUPPORT")
|
||||
endif()
|
||||
|
||||
# - X11 RayTracer
|
||||
if(GEANT4_USE_RAYTRACER_X11)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_RAYTRACERX ${SHELL_FAMILY} G4VIS_USE_RAYTRACERX 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_RAYTRACERX "# NOT BUILT WITH RAYTRACER(X11) SUPPORT")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_configure_build_tree_scripts()
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# build tree
|
||||
#
|
||||
macro(_g4tc_configure_build_tree_scripts SCRIPT_NAME)
|
||||
# Need to process for bourne and cshell families
|
||||
foreach(_shell bourne;cshell)
|
||||
# Generate the variables
|
||||
_g4tc_configure_tc_variables(${_shell} ${SCRIPT_NAME})
|
||||
|
||||
# Configure the file - goes straight into the binary dir
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4make-skeleton.in
|
||||
${PROJECT_BINARY_DIR}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
@ONLY
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_configure_install_tree_script()
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# install tree
|
||||
#
|
||||
macro(_g4tc_configure_install_tree_scripts CONFIGURE_DESTINATION SCRIPT_NAME INSTALL_DESTINATION)
|
||||
# Need to process for bourne and cshell families
|
||||
foreach(_shell bourne;cshell)
|
||||
# Generate the variables
|
||||
_g4tc_configure_tc_variables(${_shell} ${SCRIPT_NAME})
|
||||
|
||||
# Configure the file
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4make-skeleton.in
|
||||
${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install it to the required location
|
||||
install(FILES
|
||||
${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
DESTINATION ${INSTALL_DESTINATION}
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Development
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Implementation section
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure shell scripts for BUILD TREE
|
||||
# This means we have to point to libraries in the build tree, but
|
||||
# includes and resource files will be in the source tree
|
||||
# This script never needs to be relocatable, so we don't need to use the
|
||||
# self location functionality.
|
||||
# N.B. IT WILL NOT WORK when building with VS/Xcode or any multiconfig
|
||||
# buildtool because we cannot reconcile the output paths these use with
|
||||
# those expected by the old toolchain...
|
||||
#
|
||||
set(G4SYSTEM "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
set(G4INSTALL ${PROJECT_SOURCE_DIR})
|
||||
set(G4INCLUDE ${PROJECT_SOURCE_DIR}/this_is_a_deliberate_dummy_path)
|
||||
set(G4BIN_DIR ${PROJECT_BINARY_DIR})
|
||||
set(G4LIB ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(G4LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
|
||||
|
||||
# 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} BUILD_DIR ${_ds}_PATH)
|
||||
endforeach()
|
||||
|
||||
# - Fonts
|
||||
set(TOOLS_FONT_PATH "${PROJECT_SOURCE_DIR}/source/analysis/fonts")
|
||||
|
||||
# - Configure the shell scripts for the BUILD TREE
|
||||
_g4tc_configure_build_tree_scripts(geant4make)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure shell scripts for INSTALL TREE
|
||||
# This means we have to point things to their final location when
|
||||
# installed. These paths are all determined by the CMAKE_INSTALL_FULL
|
||||
# directories and others.
|
||||
# If we are relocatable, then the structure we will have is
|
||||
# +- CMAKE_INSTALL_PREFIX
|
||||
# +- LIBDIR/Geant4-VERSION (G4LIB)
|
||||
# +- INCLUDEDIR/Geant4 (G4INCLUDE)
|
||||
# +- DATAROOTDIR/Geant4-VERSION/
|
||||
# +- geant4make (THIS IS G4INSTALL!)
|
||||
# +- geant4make.(c)sh
|
||||
# +- config/
|
||||
|
||||
# - Construct universal backward compatible INSTALL TREE PATHS.
|
||||
set(G4SYSTEM "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
set(G4INSTALL "\"\$geant4make_root\"")
|
||||
|
||||
# - Now need relative paths between 'G4INSTALL' and include/bin/lib dirs
|
||||
# - Include dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_INCLUDEDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${CMAKE_INSTALL_FULL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
)
|
||||
set(G4INCLUDE "\"`cd \$geant4make_root/${G4MAKE_TO_INCLUDEDIR} > /dev/null \; pwd`\"")
|
||||
|
||||
# - Bin dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_BINDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${CMAKE_INSTALL_FULL_BINDIR}
|
||||
)
|
||||
set(G4BIN_DIR "\"`cd \$geant4make_root/${G4MAKE_TO_BINDIR} > /dev/null \; pwd`\"")
|
||||
|
||||
# - Lib dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_LIBDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${CMAKE_INSTALL_FULL_LIBDIR}
|
||||
)
|
||||
set(G4LIB "\"`cd \$geant4make_root/${G4MAKE_TO_LIBDIR}/Geant4-${Geant4_VERSION} > /dev/null \; pwd`\"")
|
||||
set(G4LIB_DIR "\"`cd \$geant4make_root/${G4MAKE_TO_LIBDIR} > /dev/null \; pwd`\"")
|
||||
|
||||
set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
|
||||
|
||||
# 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)
|
||||
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_DATADIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${${_ds}_PATH}
|
||||
)
|
||||
set(${_ds}_PATH "\"`cd \$geant4make_root/${G4MAKE_TO_DATADIR} > /dev/null \; pwd`\"")
|
||||
endforeach()
|
||||
|
||||
# - Fonts
|
||||
set(TOOLS_FONT_PATH "\"`cd \$geant4make_root/../fonts > /dev/null ; pwd`\"")
|
||||
|
||||
# - Configure the shell scripts for the INSTALL TREE
|
||||
_g4tc_configure_install_tree_scripts(
|
||||
${CMAKE_BINARY_DIR}/InstallTreeFiles
|
||||
geant4make
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
)
|
||||
|
||||
|
||||
# - For install tree, we also need to install the config directory
|
||||
# which contains all the old toolchain scripts, and to create a
|
||||
# softlink to the G4SYSTEM directory.
|
||||
#
|
||||
install(DIRECTORY config
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
COMPONENT Development
|
||||
FILES_MATCHING PATTERN "*.gmk"
|
||||
PATTERN "CVS" EXCLUDE
|
||||
PATTERN ".svn" EXCLUDE
|
||||
PATTERN "scripts/" EXCLUDE
|
||||
)
|
||||
|
||||
# Compatibility softlink to library directory, we do this on all
|
||||
# platforms, but it does nothing on Windows (well, at least the
|
||||
# attempted symlink creation does not)
|
||||
# Take care to quote the path names to avoid issues with spaces
|
||||
install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E make_directory \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/Geant4-${Geant4_VERSION}\")")
|
||||
|
||||
install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink .. ${GEANT4_SYSTEM}-${GEANT4_COMPILER} WORKING_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/Geant4-${Geant4_VERSION}\")")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# TEMPORARY
|
||||
# Configure environment setup script for install of Geant4
|
||||
# Temporarily here to keep all shell setup in one place.
|
||||
# Later, should be refactored into its own module, with module containing
|
||||
# all the shell tools above.
|
||||
#
|
||||
# - Script base name (without extension
|
||||
set(_scriptbasename geant4)
|
||||
|
||||
# - Relative path between bindir (where script is) and library directory
|
||||
file(RELATIVE_PATH
|
||||
G4ENV_BINDIR_TO_LIBDIR
|
||||
${CMAKE_INSTALL_FULL_BINDIR}
|
||||
${CMAKE_INSTALL_FULL_LIBDIR}
|
||||
)
|
||||
|
||||
# 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)
|
||||
|
||||
file(RELATIVE_PATH
|
||||
G4ENV_BINDIR_TO_DATADIR
|
||||
${CMAKE_INSTALL_FULL_BINDIR}
|
||||
${${_ds}_PATH}
|
||||
)
|
||||
set(${_ds}_PATH "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATADIR} > /dev/null \; pwd`\"")
|
||||
endforeach()
|
||||
|
||||
# - Fonts
|
||||
file(RELATIVE_PATH
|
||||
G4ENV_BINDIR_TO_DATAROOTDIR
|
||||
"${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
"${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}"
|
||||
)
|
||||
set(TOOLS_FONT_PATH "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATAROOTDIR}/fonts > /dev/null ; pwd`\"")
|
||||
|
||||
|
||||
# - Configure for each shell
|
||||
foreach(_shell bourne;cshell)
|
||||
# Setup the shell
|
||||
_g4tc_shell_setup(${_shell})
|
||||
|
||||
# Set script full name
|
||||
set(_scriptfullname ${_scriptbasename}${GEANT4_TC_SHELL_EXTENSION})
|
||||
|
||||
# Set locate self command
|
||||
_g4tc_selflocate(GEANT4_ENV_SELFLOCATE_COMMAND
|
||||
${_shell}
|
||||
${_scriptbasename}
|
||||
geant4_envbindir
|
||||
)
|
||||
|
||||
# Set path, which should be where the script itself is installed
|
||||
_g4tc_prepend_path(GEANT4_ENV_BINPATH_SETUP
|
||||
${_shell}
|
||||
PATH
|
||||
"\"\$geant4_envbindir\""
|
||||
)
|
||||
|
||||
# Set library path, based on relative paths between bindir and libdir
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
_g4tc_prepend_path(GEANT4_ENV_LIBPATH_SETUP
|
||||
${_shell}
|
||||
LD_LIBRARY_PATH
|
||||
"\"`cd $geant4_envbindir/${G4ENV_BINDIR_TO_LIBDIR} > /dev/null ; pwd`\""
|
||||
)
|
||||
endif()
|
||||
|
||||
# Third party lib paths
|
||||
# - CLHEP, if system
|
||||
set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "# - Builtin CLHEP used")
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
# Handle granular vs singular cases
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::Vector LOCATION)
|
||||
else()
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
|
||||
endif()
|
||||
|
||||
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")
|
||||
_g4tc_append_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP
|
||||
${_shell}
|
||||
LD_LIBRARY_PATH
|
||||
"${_CLHEP_LIB_DIR}"
|
||||
)
|
||||
else()
|
||||
set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "# System CLHEP in use, no configuration required")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - XercesC
|
||||
set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "# 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 "Linux")
|
||||
_g4tc_append_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP
|
||||
${_shell}
|
||||
LD_LIBRARY_PATH
|
||||
"${_XERCESC_LIB_DIR}"
|
||||
)
|
||||
else()
|
||||
set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "# GDML Supported, no configuration of Xerces-C required")
|
||||
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")
|
||||
endforeach()
|
||||
|
||||
# - Set Font Path
|
||||
set(GEANT4_ENV_TOOLS_FONT_PATH "# 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 the file
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-env-skeleton.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install it to the required location
|
||||
install(FILES
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Runtime
|
||||
)
|
||||
endforeach()
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
#.rst:
|
||||
# G4ConfigurePkgConfigHelpers
|
||||
# ---------------------------
|
||||
#
|
||||
# This module configures and installs pkg-config scripts and the
|
||||
# geant4-config program to help clients compile and link against
|
||||
# the Geant4 libraries.
|
||||
#
|
||||
# The geant4-config script provides an sh based interface to provide
|
||||
# information on the Geant4 installation, including installation prefix,
|
||||
# version number, compiler and linker flags.
|
||||
#
|
||||
# The script is generated from a template file and then installed to the
|
||||
# known bindir as an executable.
|
||||
#
|
||||
# Paths are always hardcoded in the build tree version as this is never
|
||||
# intended to be relocatable.
|
||||
# The Install Tree script uses self-location based on that in
|
||||
# {root,clhep}-config is the install itself is relocatable, otherwise
|
||||
# absolute paths are encoded.
|
||||
#
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function get_system_include_dirs
|
||||
# return list of directories our C++ compiler searches
|
||||
# by default.
|
||||
#
|
||||
# The idea comes from CMake's inbuilt technique to do this
|
||||
# for the Eclipse and CodeBlocks generators, but we implement
|
||||
# our own function because the CMake functionality is internal
|
||||
# so we can't rely on it.
|
||||
function(get_system_include_dirs _dirs)
|
||||
# Only for GCC, Clang and Intel
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel)
|
||||
# Proceed
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/g4dummy" "\n")
|
||||
|
||||
# Save locale, them to "C" english locale so we can parse in English
|
||||
set(_orig_lc_all $ENV{LC_ALL})
|
||||
set(_orig_lc_messages $ENV{LC_MESSAGES})
|
||||
set(_orig_lang $ENV{LANG})
|
||||
|
||||
set(ENV{LC_ALL} C)
|
||||
set(ENV{LC_MESSAGES} C)
|
||||
set(ENV{LANG} C)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v -E -x c++ -dD g4dummy
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
|
||||
ERROR_VARIABLE _cxxOutput
|
||||
OUTPUT_VARIABLE _cxxStdout
|
||||
)
|
||||
|
||||
file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/g4dummy")
|
||||
|
||||
# Parse and extract search dirs
|
||||
set(_resultIncludeDirs )
|
||||
if( "${_cxxOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" )
|
||||
string(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}")
|
||||
foreach(nextLine ${_includeLines})
|
||||
string(REGEX REPLACE "\\(framework directory\\)" "" nextLineNoFramework "${nextLine}")
|
||||
string(STRIP "${nextLineNoFramework}" _includePath)
|
||||
list(APPEND _resultIncludeDirs "${_includePath}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Restore original locale
|
||||
set(ENV{LC_ALL} ${_orig_lc_all})
|
||||
set(ENV{LC_MESSAGES} ${_orig_lc_messages})
|
||||
set(ENV{LANG} ${_orig_lang})
|
||||
|
||||
set(${_dirs} ${_resultIncludeDirs} PARENT_SCOPE)
|
||||
else()
|
||||
set(${_dirs} "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Only create script if we have a global library build...
|
||||
#
|
||||
if(NOT GEANT4_BUILD_GRANULAR_LIBS AND UNIX)
|
||||
# Get implicit search paths
|
||||
get_system_include_dirs(_cxx_compiler_dirs)
|
||||
|
||||
# Setup variables needed for expansion in configuration file
|
||||
# - Static libs
|
||||
if(BUILD_STATIC_LIBS)
|
||||
set(G4_BUILTWITH_STATICLIBS "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_STATICLIBS "no")
|
||||
endif()
|
||||
|
||||
# - Multithreading
|
||||
if(GEANT4_BUILD_MULTITHREADED)
|
||||
set(G4_BUILTWITH_MULTITHREADING "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_MULTITHREADING "no")
|
||||
endif()
|
||||
|
||||
# - CLHEP
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
set(G4_BUILTWITH_CLHEP "no")
|
||||
#inc path
|
||||
get_filename_component(G4_SYSTEM_CLHEP_INCLUDE_DIR "${CLHEP_INCLUDE_DIR}" ABSOLUTE)
|
||||
|
||||
#libpath
|
||||
list(GET CLHEP_LIBRARIES 0 _zeroth_clhep_lib)
|
||||
get_target_property(_system_clhep_libdir "${_zeroth_clhep_lib}" LOCATION)
|
||||
get_filename_component(_system_clhep_libdir "${_system_clhep_libdir}" REALPATH)
|
||||
get_filename_component(_system_clhep_libdir "${_system_clhep_libdir}" DIRECTORY)
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES "-L${_system_clhep_libdir}")
|
||||
|
||||
foreach(_clhep_lib ${CLHEP_LIBRARIES})
|
||||
get_target_property(_curlib "${_clhep_lib}" LOCATION)
|
||||
get_filename_component(_curlib "${_curlib}" NAME)
|
||||
string(REGEX REPLACE "^lib(.*)\\.(so|a|dylib|lib|dll)$" "\\1" _curlib "${_curlib}")
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES} -l${_curlib}")
|
||||
endforeach()
|
||||
else()
|
||||
set(G4_BUILTWITH_CLHEP "yes")
|
||||
endif()
|
||||
|
||||
# - EXPAT
|
||||
if(GEANT4_USE_SYSTEM_EXPAT)
|
||||
set(G4_BUILTWITH_EXPAT "no")
|
||||
else()
|
||||
set(G4_BUILTWITH_EXPAT "yes")
|
||||
endif()
|
||||
|
||||
# - ZLIB
|
||||
if(GEANT4_USE_SYSTEM_ZLIB)
|
||||
set(G4_BUILTWITH_ZLIB "no")
|
||||
else()
|
||||
set(G4_BUILTWITH_ZLIB "yes")
|
||||
endif()
|
||||
|
||||
# - GDML
|
||||
if(GEANT4_USE_GDML)
|
||||
set(G4_BUILTWITH_GDML "yes")
|
||||
set(G4_XERCESC_INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS})
|
||||
list(REMOVE_DUPLICATES G4_XERCESC_INCLUDE_DIRS)
|
||||
list(REMOVE_ITEM G4_XERCESC_INCLUDE_DIRS ${_cxx_compiler_dirs})
|
||||
|
||||
set(G4_XERCESC_CFLAGS )
|
||||
foreach(_dir ${G4_XERCESC_INCLUDE_DIRS})
|
||||
set(G4_XERCESC_CFLAGS "${G4_XERCESC_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
else()
|
||||
set(G4_BUILTWITH_GDML "no")
|
||||
endif()
|
||||
|
||||
# - G3ToG4
|
||||
if(GEANT4_USE_G3TOG4)
|
||||
set(G4_BUILTWITH_G3TOG4 "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_G3TOG4 "no")
|
||||
endif()
|
||||
|
||||
# - USolids
|
||||
if(GEANT4_USE_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
|
||||
set(G4_BUILTWITH_USOLIDS "yes")
|
||||
set(G4_USOLIDS_INCLUDE_DIRS "${USOLIDS_INCLUDE_DIRS} ${VECGEOM_EXTERNAL_INCLUDES}")
|
||||
list(REMOVE_DUPLICATES G4_USOLIDS_INCLUDE_DIRS)
|
||||
list(REMOVE_ITEM G4_USOLIDS_INCLUDE_DIRS ${_cxx_compiler_dirs})
|
||||
|
||||
string(REPLACE ";" " " G4_USOLIDS_CFLAGS "${GEANT4_USOLIDS_COMPILE_DEFINITIONS}")
|
||||
foreach(_dir ${G4_USOLIDS_INCLUDE_DIRS})
|
||||
set(G4_USOLIDS_CFLAGS "${G4_USOLIDS_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
else()
|
||||
set(G4_BUILTWITH_USOLIDS "no")
|
||||
endif()
|
||||
|
||||
# - Freetype
|
||||
if(GEANT4_USE_FREETYPE)
|
||||
set(G4_BUILTWITH_FREETYPE "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_FREETYPE "no")
|
||||
endif()
|
||||
|
||||
# - Qt
|
||||
if(GEANT4_USE_QT)
|
||||
set(G4_BUILTWITH_QT "yes")
|
||||
if(QT4_FOUND)
|
||||
set(G4_QT_INCLUDE_DIRS ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR})
|
||||
else()
|
||||
set(G4_QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES G4_QT_INCLUDE_DIRS)
|
||||
list(REMOVE_ITEM G4_QT_INCLUDE_DIRS ${_cxx_compiler_dirs})
|
||||
|
||||
set(G4_QT_CFLAGS )
|
||||
foreach(_dir ${G4_QT_INCLUDE_DIRS})
|
||||
set(G4_QT_CFLAGS "${G4_QT_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
set(G4_BUILTWITH_QT "no")
|
||||
endif()
|
||||
|
||||
# - Wt
|
||||
if(GEANT4_USE_WT)
|
||||
set(G4_BUILTWITH_WT "yes")
|
||||
set(G4_WT_INCLUDE_DIRS ${Wt_INCLUDE_DIR} ${Boost_INCLUDE_DIR} )
|
||||
|
||||
set(G4_WT_CFLAGS )
|
||||
foreach(_dir ${G4_WT_INCLUDE_DIRS})
|
||||
set(G4_WT_CFLAGS "${G4_WT_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
set(G4_BUILTWITH_WT "no")
|
||||
endif()
|
||||
|
||||
# - Motif
|
||||
if(GEANT4_USE_XM)
|
||||
set(G4_BUILTWITH_MOTIF "yes")
|
||||
set(G4_CONFIG_NEEDS_X11 TRUE)
|
||||
else()
|
||||
set(G4_BUILTWITH_MOTIF "no")
|
||||
endif()
|
||||
|
||||
# - RayTracerX
|
||||
if(GEANT4_USE_RAYTRACER_X11)
|
||||
set(G4_BUILTWITH_RAYTRACERX11 "yes")
|
||||
set(G4_CONFIG_NEEDS_X11 TRUE)
|
||||
else()
|
||||
set(G4_BUILTWITH_RAYTRACERX11 "no")
|
||||
endif()
|
||||
|
||||
# - OpenGL X11
|
||||
if(GEANT4_USE_OPENGL_X11)
|
||||
set(G4_BUILTWITH_OPENGLX11 "yes")
|
||||
set(G4_CONFIG_NEEDS_X11 TRUE)
|
||||
else()
|
||||
set(G4_BUILTWITH_OPENGLX11 "no")
|
||||
endif()
|
||||
|
||||
# - OpenInventor
|
||||
if(GEANT4_USE_INVENTOR)
|
||||
set(G4_BUILTWITH_INVENTOR "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_INVENTOR "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)
|
||||
set(_raw_x11_includes ${X11_INCLUDE_DIR})
|
||||
list(REMOVE_DUPLICATES _raw_x11_includes)
|
||||
list(REMOVE_ITEM _raw_x11_includes ${_cxx_compiler_dirs})
|
||||
set(G4_X11_CFLAGS )
|
||||
foreach(_p ${_raw_x11_includes})
|
||||
set(G4_X11_CFLAGS "-I${_p} ${G4_X11_CFLAGS}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Configure the script
|
||||
# - BUILD TREE
|
||||
# Ouch, the include path will be LONG, but at least we always have
|
||||
# absolute paths...
|
||||
set(GEANT4_CONFIG_SELF_LOCATION "# BUILD TREE IS NON-RELOCATABLE")
|
||||
set(GEANT4_CONFIG_INSTALL_PREFIX "${PROJECT_BINARY_DIR}")
|
||||
set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
|
||||
# NB: this only works for *single* mode generators. With multimode
|
||||
# generators, which mode to use is not clear...
|
||||
set(GEANT4_CONFIG_LIBDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
|
||||
get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
|
||||
GEANT4_BUILDTREE_INCLUDE_DIRS)
|
||||
|
||||
foreach(_dir ${__geant4_buildtree_include_dirs})
|
||||
set(GEANT4_CONFIG_INCLUDE_DIRS "${GEANT4_CONFIG_INCLUDE_DIRS} \\
|
||||
${_dir}")
|
||||
endforeach()
|
||||
|
||||
# - Data
|
||||
geant4_export_datasets(BUILD GEANT4_CONFIG_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Configure the build tree script
|
||||
# If we're on CMake 2.8 and above, we try to use file(COPY) to create an
|
||||
# executable script
|
||||
# Not sure if version check is o.k., but I'll be shocked if we ever see
|
||||
# a CMake 2.7 in the wild...
|
||||
if(${CMAKE_VERSION} VERSION_GREATER 2.7)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-config.in
|
||||
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
|
||||
@ONLY
|
||||
)
|
||||
|
||||
file(COPY
|
||||
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
|
||||
DESTINATION ${PROJECT_BINARY_DIR}
|
||||
FILE_PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
else()
|
||||
# Changing permissions is awkward, so just configure and document
|
||||
# that you have to do 'sh geant4-config' in this case.
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-config.in
|
||||
${PROJECT_BINARY_DIR}/geant4-config
|
||||
@ONLY
|
||||
)
|
||||
endif()
|
||||
|
||||
# - Install Tree
|
||||
# Much easier :-)
|
||||
# Non-Relocatable case...
|
||||
if(CMAKE_INSTALL_IS_NONRELOCATABLE)
|
||||
# Hardcoded paths
|
||||
set(GEANT4_CONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
|
||||
set(GEANT4_CONFIG_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
set(GEANT4_CONFIG_INCLUDE_DIRS "${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4")
|
||||
else()
|
||||
# Calculate base of self contained install based on relative path from
|
||||
# CMAKE_INSTALL_FULL_BINDIR to CMAKE_INSTALL_PREFIX.
|
||||
file(RELATIVE_PATH _bin_to_prefix ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_PREFIX})
|
||||
# Strip any trailing path separators just for neatness.
|
||||
string(REGEX REPLACE "[/\\]$" "" _bin_to_prefix "${_bin_to_prefix}")
|
||||
|
||||
set(GEANT4_CONFIG_INSTALL_PREFIX "$scriptloc/${_bin_to_prefix}")
|
||||
set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
|
||||
set(GEANT4_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(GEANT4_CONFIG_INCLUDE_DIRS "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/Geant4")
|
||||
endif()
|
||||
|
||||
# - Data
|
||||
geant4_export_datasets(INSTALL GEANT4_CONFIG_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Configure the install tree script
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-config.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install it
|
||||
install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Development
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#.rst:
|
||||
# G4DeveloperAPI
|
||||
# --------------
|
||||
#
|
||||
# .. code-block::cmake
|
||||
#
|
||||
# include(G4DeveloperAPI)
|
||||
#
|
||||
# CMake functions and macros for declaring and working with build
|
||||
# products of Geant4.
|
||||
#
|
||||
# WIP: At present, this simply forwards to the old implementation
|
||||
# Eventually will allow switch between the old and the new,
|
||||
# then just the new once transition complete.
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
if(NOT __G4DEVELOPERAPI_INCLUDED)
|
||||
set(__G4DEVELOPERAPI_INCLUDED TRUE)
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(G4DeveloperAPI_OLD)
|
||||
@@ -0,0 +1,513 @@
|
||||
#.rst:
|
||||
# G4DeveloperAPI_OLD
|
||||
# ------------------
|
||||
#
|
||||
# Old style API for declaring Geant4 source code modules and
|
||||
# compiling, linking and installing binary libraries composed
|
||||
# from one or more source code modules.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# License and Disclaimer
|
||||
#
|
||||
# The Geant4 software is copyright of the Copyright Holders of
|
||||
# the Geant4 Collaboration. It is provided under the terms and
|
||||
# conditions of the Geant4 Software License, included in the file
|
||||
# LICENSE and available at http://cern.ch/geant4/license . These
|
||||
# include a list of copyright holders.
|
||||
#
|
||||
# Neither the authors of this software system, nor their employing
|
||||
# institutes,nor the agencies providing financial support for this
|
||||
# work make any representation or warranty, express or implied,
|
||||
# regarding this software system or assume any liability for its
|
||||
# use. Please see the license in the file LICENSE and URL above
|
||||
# for the full disclaimer and the limitation of liability.
|
||||
#
|
||||
# This code implementation is the result of the scientific and
|
||||
# technical work of the GEANT4 collaboration.
|
||||
# By using, copying, modifying or distributing the software (or
|
||||
# any work based on the software) you agree to acknowledge its
|
||||
# use in resulting scientific publications, and indicate your
|
||||
# acceptance of all terms of the Geant4 Software license.
|
||||
#
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
|
||||
# - Include guard
|
||||
if(NOT __G4DEVELOPERAPI_OLD_INCLUDED)
|
||||
set(__G4DEVELOPERAPI_OLD_INCLUDED 1)
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
# - Needed CMake modules
|
||||
include(CMakeParseArguments)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Source Code Module Declaration Functions
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# Geant4's source code is organised into categories composed of one or
|
||||
# more "modules" of source code. Each module has the following layout
|
||||
# of headers and sources:
|
||||
#
|
||||
# - include/
|
||||
# - Public headers
|
||||
# - src/
|
||||
# - Implementations
|
||||
#
|
||||
# The functions here declare a module ready for it to be integrated
|
||||
# by the library build functions described below.
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro geant4_define_module(NAME <name>
|
||||
# HEADERS <header1> <header2> ... <headerN>
|
||||
# SOURCES <source1> <source2> ... <sourceN>
|
||||
# GRANULAR_DEPENDENCIES <dep1> ... <depN>
|
||||
# GLOBAL_DEPENDENCIES <dep1> ... <depN>
|
||||
# LINK_LIBRARIES <lib1> ... <lib2>)
|
||||
# Define a Geant4 Module's sources and what internal and external
|
||||
# libraries it links to.
|
||||
#
|
||||
# GEANT4_DEFINE_MODULE will take the name of the module, a list of header
|
||||
# files, a list of source files and dependencies:
|
||||
#
|
||||
# GEANT4_DEFINE_MODULE(NAME name
|
||||
# HEADERS hdr1 hdr2 ...
|
||||
# SOURCES src1 src2 ...
|
||||
# GRANULAR_DEPENDENCIES dep1 dep2 ...
|
||||
# GLOBAL_DEPENDENCIES dep1 dep2 ...
|
||||
# LINK_LIBRARIES lib1 lib2 ...)
|
||||
#
|
||||
# It assumes that it will be called from a CMake located in the module
|
||||
# root directory (i.e. the directory containing the include and src
|
||||
# subdirectories). It uses this location to define absolute paths to the
|
||||
# headers and sources, and will ignore any absolute paths passed in HEADERS
|
||||
# or SOURCES so that generated files can be passed in.
|
||||
#
|
||||
# The macro defines the variables
|
||||
#
|
||||
# G4MODULENAME = name
|
||||
# ${G4MODULENAME}_HEADERS = List of absolute paths to files given in HEADERS
|
||||
# ${G4MODULENAME}_SOURCES = List of absolute paths to files given in SOURCES
|
||||
# ${G4MODULENAME}_GRANULAR_DEPS = List of granular libraries on which this
|
||||
# module depends
|
||||
# ${G4MODULENAME}_GLOBAL_DEPS = List of global libraries on which this module
|
||||
# depends
|
||||
# ${G4MODULENAME}_LINK_LIBRARIES = List of external libraries to be linked to
|
||||
# this module
|
||||
#
|
||||
# It will also add the module include directory to the list of directories
|
||||
# using include_directories
|
||||
#
|
||||
macro(geant4_define_module)
|
||||
cmake_parse_arguments(G4DEFMOD
|
||||
""
|
||||
"NAME"
|
||||
"HEADERS;SOURCES;GRANULAR_DEPENDENCIES;GLOBAL_DEPENDENCIES;LINK_LIBRARIES"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
set(G4MODULENAME ${G4DEFMOD_NAME})
|
||||
|
||||
get_filename_component(${G4MODULENAME}_BASEDIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
set(${G4MODULENAME}_SRCDIR ${${G4MODULENAME}_BASEDIR}/src)
|
||||
set(${G4MODULENAME}_INCDIR ${${G4MODULENAME}_BASEDIR}/include)
|
||||
|
||||
# We now create absolute paths to the headers and sources,
|
||||
# ignoring any already absolute paths
|
||||
foreach(_HDR ${G4DEFMOD_HEADERS})
|
||||
if(IS_ABSOLUTE ${_HDR})
|
||||
list(APPEND ${G4MODULENAME}_HEADERS ${_HDR})
|
||||
else()
|
||||
list(APPEND ${G4MODULENAME}_HEADERS ${${G4MODULENAME}_INCDIR}/${_HDR})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(_SRC ${G4DEFMOD_SOURCES})
|
||||
if(IS_ABSOLUTE ${_SRC})
|
||||
list(APPEND ${G4MODULENAME}_SOURCES ${_SRC})
|
||||
else()
|
||||
list(APPEND ${G4MODULENAME}_SOURCES ${${G4MODULENAME}_SRCDIR}/${_SRC})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(_LIB ${G4DEFMOD_GRANULAR_DEPENDENCIES})
|
||||
list(APPEND ${G4MODULENAME}_GRANULAR_DEPENDENCIES ${_LIB})
|
||||
endforeach()
|
||||
|
||||
foreach(_LIB ${G4DEFMOD_GLOBAL_DEPENDENCIES})
|
||||
list(APPEND ${G4MODULENAME}_GLOBAL_DEPENDENCIES ${_LIB})
|
||||
endforeach()
|
||||
|
||||
foreach(_LIB ${G4DEFMOD_LINK_LIBRARIES})
|
||||
list(APPEND ${G4MODULENAME}_LINK_LIBRARIES ${_LIB})
|
||||
endforeach()
|
||||
|
||||
include_directories(${${G4MODULENAME}_INCDIR})
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro geant4_add_compile_definitions(SOURCES <source1> ... <sourceN>
|
||||
# COMPILE_DEFINITIONS <def1> ... <defN>
|
||||
# )
|
||||
# Add extra compile definitions to a specific list of sources
|
||||
# in the current module. Macroized to handle the need to specify absolute paths.
|
||||
# and *must* be called at the same level as geant4_define_module
|
||||
#
|
||||
macro(geant4_add_compile_definitions)
|
||||
cmake_parse_arguments(G4ADDDEF
|
||||
""
|
||||
""
|
||||
"SOURCES;COMPILE_DEFINITIONS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# We assume that the sources have been added at the level of a
|
||||
# a sources.cmake, so are inside the src subdir of the sources.cmake
|
||||
get_filename_component(_ACD_BASE_PATH ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
# Now for each file, add the definitions
|
||||
foreach(_acd_source ${G4ADDDEF_SOURCES})
|
||||
# Extract any existing compile definitions
|
||||
get_source_file_property(
|
||||
_acd_existing_properties
|
||||
${_ACD_BASE_PATH}/src/${_acd_source}
|
||||
COMPILE_DEFINITIONS)
|
||||
|
||||
if(_acd_existing_properties)
|
||||
set(_acd_new_defs ${_acd_existing_properties}
|
||||
${G4ADDDEF_COMPILE_DEFINITIONS})
|
||||
else()
|
||||
set(_acd_new_defs ${G4ADDDEF_COMPILE_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
# quote compile defs because this must epand to space separated list
|
||||
set_source_files_properties(${_ACD_BASE_PATH}/src/${_acd_source}
|
||||
PROPERTIES COMPILE_DEFINITIONS "${_acd_new_defs}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#.rst:
|
||||
# Library Declaration, Build and Install API
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# - Define useful macros for building and installing Geant4 library targets
|
||||
#
|
||||
# This file defines the following macros for Geant4 developers needing to
|
||||
# add shared and static library targets.
|
||||
#
|
||||
# GEANT4_LIBRARY_TARGET - define standard Geant4 library targets
|
||||
#
|
||||
# The macro will take the name of the library and its sources, defining
|
||||
# static and shared targets depending on the value of BUILD_SHARED_LIBS and
|
||||
# BUILD_STATIC_LIBS. Install targets are also created.
|
||||
#
|
||||
# A custom compile definition "GEANT4_DEVELOPER_<CONFIG>" is set on
|
||||
# each target using the target property COMPILE_DEFINITIONS_<CONFIG>
|
||||
# target property
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_compile_definitions_config(<target>)
|
||||
# Set a custom compile definition for a Geant4 target on a
|
||||
# per configuration basis:
|
||||
# For mode <CONFIG>, define GEANT4_DEVELOPER_<CONFIG>
|
||||
#
|
||||
function(geant4_compile_definitions_config _target)
|
||||
if(NOT TARGET ${_target})
|
||||
message(FATAL_ERROR "geant4_compile_definitions_config passed target '${_target}' which is not a valid CMake target")
|
||||
endif()
|
||||
|
||||
# CMake 3 prefers $<CONFIG> in generator expressions
|
||||
set(__default_config_generator "\$<CONFIG>")
|
||||
|
||||
set_property(TARGET ${_target}
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
GEANT4_DEVELOPER_${__default_config_generator}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_LIBRARY_TARGET
|
||||
# General build and install of a Geant4 library target
|
||||
#
|
||||
macro(geant4_library_target)
|
||||
cmake_parse_arguments(G4LIBTARGET
|
||||
""
|
||||
"NAME" "SOURCES;GEANT4_LINK_LIBRARIES;LINK_LIBRARIES"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# Add the shared library target and link its dependencies
|
||||
# WIN32 first
|
||||
if(WIN32)
|
||||
# We have to generate the def export file from an archive library.
|
||||
# This is a temporary separate from a real archive library, and
|
||||
# even though it's static, we need to mark that it will have
|
||||
# DLL symbols via the G4LIB_BUILD_DLL macro
|
||||
add_library(_${G4LIBTARGET_NAME}-archive STATIC EXCLUDE_FROM_ALL ${G4LIBTARGET_SOURCES})
|
||||
set(_archive _${G4LIBTARGET_NAME}-archive)
|
||||
target_compile_features(${_archive} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
target_compile_definitions(${_archive} PUBLIC -DG4LIB_BUILD_DLL)
|
||||
|
||||
# - Add the config specific compile definitions
|
||||
geant4_compile_definitions_config(${_archive})
|
||||
|
||||
# - Create the .def file for this library
|
||||
# Use generator expressions to get path to per-mode lib and
|
||||
# older CMAKE_CFG_INTDIR variable to set name of per-mode def
|
||||
# file (Needed as generator expressions cannot be used in argument
|
||||
# to OUTPUT...
|
||||
add_custom_command(OUTPUT _${G4LIBTARGET_NAME}-${CMAKE_CFG_INTDIR}.def
|
||||
COMMAND genwindef -o _${G4LIBTARGET_NAME}-${CMAKE_CFG_INTDIR}.def -l ${G4LIBTARGET_NAME} $<TARGET_FILE:${_archive}>
|
||||
DEPENDS ${_archive} genwindef)
|
||||
|
||||
# - Now we can build the DLL
|
||||
# We create it from a dummy empty C++ file plus the def file.
|
||||
# Also set the public compile definition on it so that clients
|
||||
# will set correct macro automatically.
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/_${G4LIBTARGET_NAME}.cpp
|
||||
"// empty _${G4LIBTARGET_NAME}.cpp\n")
|
||||
|
||||
add_library(${G4LIBTARGET_NAME} SHARED _${G4LIBTARGET_NAME}.cpp
|
||||
_${G4LIBTARGET_NAME}-${CMAKE_CFG_INTDIR}.def)
|
||||
target_compile_definitions(${G4LIBTARGET_NAME} PUBLIC -DG4LIB_BUILD_DLL)
|
||||
target_compile_features(${G4LIBTARGET_NAME} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
|
||||
# - Link the DLL.
|
||||
# We link it to the archive, and the supplied libraries,
|
||||
# but then remove the archive from the LINK_INTERFACE.
|
||||
target_link_libraries(${G4LIBTARGET_NAME}
|
||||
${_archive}
|
||||
${G4LIBTARGET_GEANT4_LINK_LIBRARIES}
|
||||
${G4LIBTARGET_LINK_LIBRARIES})
|
||||
|
||||
set_target_properties(${G4LIBTARGET_NAME}
|
||||
PROPERTIES INTERFACE_LINK_LIBRARIES "${G4LIBTARGET_GEANT4_LINK_LIBRARIES};${G4LIBTARGET_LINK_LIBRARIES}")
|
||||
|
||||
else()
|
||||
# - We build a Shared library in the usual fashion...
|
||||
add_library(${G4LIBTARGET_NAME} SHARED ${G4LIBTARGET_SOURCES})
|
||||
geant4_compile_definitions_config(${G4LIBTARGET_NAME})
|
||||
target_compile_features(${G4LIBTARGET_NAME} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
target_link_libraries(${G4LIBTARGET_NAME}
|
||||
${G4LIBTARGET_GEANT4_LINK_LIBRARIES}
|
||||
${G4LIBTARGET_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# This property is set to prevent concurrent builds of static and
|
||||
# shared libs removing each others files.
|
||||
set_target_properties(${G4LIBTARGET_NAME}
|
||||
PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
# Always use '@rpath' in install names of libraries. This is the
|
||||
# most flexible mechanism for
|
||||
set_target_properties(${G4LIBTARGET_NAME}
|
||||
PROPERTIES MACOSX_RPATH 1
|
||||
)
|
||||
|
||||
# Install the library - note the use of RUNTIME, LIBRARY and ARCHIVE
|
||||
# this helps with later DLL builds.
|
||||
# Export to standard depends file for later install
|
||||
# NEEDS WORK TO REMOVE HARDCODED LIB/BIN DIR
|
||||
install(TARGETS ${G4LIBTARGET_NAME}
|
||||
EXPORT Geant4LibraryDepends
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
|
||||
|
||||
# Append the library target to a global property so that build tree
|
||||
# export of library dependencies can pick up all targets
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_EXPORTED_TARGETS ${G4LIBTARGET_NAME})
|
||||
endif()
|
||||
|
||||
#
|
||||
# As above, but for static rather than shared library
|
||||
if(BUILD_STATIC_LIBS)
|
||||
# We have to distinguish the static from shared lib, so use -static in
|
||||
# name. Link its dependencies, and ensure we actually link to the
|
||||
# -static targets (We should strictly do this for the external
|
||||
# libraries as well if we want a pure static build).
|
||||
add_library(${G4LIBTARGET_NAME}-static STATIC ${G4LIBTARGET_SOURCES})
|
||||
geant4_compile_definitions_config(${G4LIBTARGET_NAME}-static)
|
||||
target_compile_features(${G4LIBTARGET_NAME}-static PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
|
||||
set(G4LIBTARGET_GEANT4_LINK_LIBRARIES_STATIC )
|
||||
foreach(_tgt ${G4LIBTARGET_GEANT4_LINK_LIBRARIES})
|
||||
list(APPEND G4LIBTARGET_GEANT4_LINK_LIBRARIES_STATIC ${_tgt}-static)
|
||||
endforeach()
|
||||
|
||||
# If we are building both types of library and builtin clhep etc,
|
||||
# we want to link shared->shared and static->static.
|
||||
# Because externals like clhep appear in G4LIBTARGET_LINK_LIBRARIES,
|
||||
# filter this list to replace shared builtins with their static variant
|
||||
string(REGEX REPLACE
|
||||
"(G4clhep|G4expat|G4zlib|G4geomUSolids)(;|$)" "\\1-static\\2"
|
||||
G4LIBTARGET_LINK_LIBRARIES_STATIC
|
||||
"${G4LIBTARGET_LINK_LIBRARIES}"
|
||||
)
|
||||
|
||||
target_link_libraries(${G4LIBTARGET_NAME}-static
|
||||
${G4LIBTARGET_GEANT4_LINK_LIBRARIES_STATIC}
|
||||
${G4LIBTARGET_LINK_LIBRARIES_STATIC})
|
||||
|
||||
# But we can rename the output library to the correct name
|
||||
# On WIN32 we *retain* the -static postfix because otherwise
|
||||
# we'll conflict with the .lib from the DLL build...
|
||||
# We could also install differently...
|
||||
if(NOT WIN32)
|
||||
set_target_properties(${G4LIBTARGET_NAME}-static
|
||||
PROPERTIES OUTPUT_NAME ${G4LIBTARGET_NAME})
|
||||
endif()
|
||||
|
||||
set_target_properties(${G4LIBTARGET_NAME}-static
|
||||
PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
install(TARGETS ${G4LIBTARGET_NAME}-static
|
||||
EXPORT Geant4LibraryDepends
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
|
||||
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_EXPORTED_TARGETS ${G4LIBTARGET_NAME}-static)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_HEADER_MODULE_TARGET
|
||||
# Build and install for a header only Geant4 module.
|
||||
#
|
||||
macro(geant4_header_module_target)
|
||||
CMAKE_PARSE_ARGUMENTS(G4HEADERMOD
|
||||
""
|
||||
"COMPONENT"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# Only has one component, and we just have to pick out the headers
|
||||
include(${G4HEADERMOD_COMPONENT})
|
||||
|
||||
# Header install?
|
||||
install(FILES ${${G4MODULENAME}_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development)
|
||||
|
||||
# Store the include path of the component so that the build tree
|
||||
# config file can pick up all needed header paths
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS ${${G4MODULENAME}_INCDIR})
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_GRANULAR_LIBRARY_TARGET
|
||||
# Build and install for a Geant4 module (granular) library
|
||||
#
|
||||
macro(geant4_granular_library_target)
|
||||
cmake_parse_arguments(G4GRANLIB
|
||||
""
|
||||
"COMPONENT"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# Granular lib only has one component, but we must pick out
|
||||
# the granular dependencies
|
||||
include(${G4GRANLIB_COMPONENT})
|
||||
|
||||
# Add the library target, using variables set by the inclusion of
|
||||
# the component file
|
||||
geant4_library_target(NAME ${G4MODULENAME}
|
||||
SOURCES ${${G4MODULENAME}_SOURCES} ${${G4MODULENAME}_HEADERS}
|
||||
GEANT4_LINK_LIBRARIES ${${G4MODULENAME}_GRANULAR_DEPENDENCIES}
|
||||
LINK_LIBRARIES ${${G4MODULENAME}_LINK_LIBRARIES})
|
||||
|
||||
# Header install?
|
||||
install(FILES ${${G4MODULENAME}_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development)
|
||||
|
||||
# Store the include path of the component so that the build tree
|
||||
# config file can pick up all needed header paths
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS ${${G4MODULENAME}_INCDIR})
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_GLOBAL_LIBRARY_TARGET
|
||||
# Build and install of a Geant4 category (global) library
|
||||
#
|
||||
macro(geant4_global_library_target)
|
||||
cmake_parse_arguments(G4GLOBLIB
|
||||
""
|
||||
"NAME"
|
||||
"COMPONENTS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# We loop over the component sources one at a time,
|
||||
# appending properties as we go.
|
||||
foreach(_comp ${G4GLOBLIB_COMPONENTS})
|
||||
include(${_comp})
|
||||
# In case we have a global lib with one component, ensure name gets set
|
||||
if(NOT G4GLOBLIB_NAME)
|
||||
set(G4GLOBLIB_NAME ${G4MODULENAME})
|
||||
endif()
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_GLOBAL_SOURCES ${${G4MODULENAME}_SOURCES})
|
||||
list(APPEND ${G4GLOBLIB_NAME}_GLOBAL_HEADERS ${${G4MODULENAME}_HEADERS})
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES
|
||||
${${G4MODULENAME}_GLOBAL_DEPENDENCIES})
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_LINK_LIBRARIES
|
||||
${${G4MODULENAME}_LINK_LIBRARIES})
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_BUILDTREE_INCLUDES ${${G4MODULENAME}_INCDIR})
|
||||
endforeach()
|
||||
|
||||
# Reset include dirs, setting from module direct dirs only
|
||||
# But need to pass this forward to the library target so that
|
||||
# it can use this list in target_include_directories...
|
||||
#set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "")
|
||||
#include_directories(${${G4GLOBLIB_NAME}_BUILDTREE_INCLUDES})
|
||||
|
||||
# Filter out duplicates/self in GLOBAL_DEPENDENCIES and LINK_LIBRARIES
|
||||
if(${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES)
|
||||
list(REMOVE_DUPLICATES ${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES)
|
||||
list(REMOVE_ITEM ${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES ${G4GLOBLIB_NAME})
|
||||
endif()
|
||||
if(${G4GLOBLIB_NAME}_LINK_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES ${G4GLOBLIB_NAME}_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
# Now add the library target
|
||||
geant4_library_target(NAME ${G4GLOBLIB_NAME}
|
||||
SOURCES
|
||||
${${G4GLOBLIB_NAME}_GLOBAL_SOURCES}
|
||||
${${G4GLOBLIB_NAME}_GLOBAL_HEADERS}
|
||||
GEANT4_LINK_LIBRARIES
|
||||
${${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES}
|
||||
LINK_LIBRARIES
|
||||
${${G4GLOBLIB_NAME}_LINK_LIBRARIES})
|
||||
|
||||
# Header install?
|
||||
install(FILES ${${G4GLOBLIB_NAME}_GLOBAL_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development)
|
||||
|
||||
# Store the include path of the component so that the build tree
|
||||
# config file can pick up all needed header paths
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS ${${G4GLOBLIB_NAME}_BUILDTREE_INCLUDES})
|
||||
endmacro()
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# - Basic setup for testing Geant4 using CMake/CTest
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
# Integration and unit tests
|
||||
# - "ENABLE_TESTING" means all tests under tests/
|
||||
option(GEANT4_ENABLE_TESTING "Enable and define all the tests of the project" OFF)
|
||||
GEANT4_ADD_FEATURE(GEANT4_ENABLE_TESTING "Enable and define all the tests of the project")
|
||||
mark_as_advanced(GEANT4_ENABLE_TESTING)
|
||||
|
||||
# - "BUILD_TESTS" means all 'tests' in individual categories.
|
||||
option(GEANT4_BUILD_TESTS "Build all the tests of the project" OFF)
|
||||
GEANT4_ADD_FEATURE(GEANT4_BUILD_TESTS "Build all the tests of the project")
|
||||
mark_as_advanced(GEANT4_BUILD_TESTS)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure CTest and relevant Geant4 settings, if required
|
||||
|
||||
@@ -18,21 +18,21 @@ geant4_add_dataset(
|
||||
# - Low energy electromagnetics
|
||||
geant4_add_dataset(
|
||||
NAME G4EMLOW
|
||||
VERSION 6.50
|
||||
VERSION 6.54
|
||||
FILENAME G4EMLOW
|
||||
EXTENSION tar.gz
|
||||
ENVVAR G4LEDATA
|
||||
MD5SUM 2a0dbeb2dd57158919c149f33675cce5
|
||||
MD5SUM 9d9b5207861fbed0aebddb7f89384151
|
||||
)
|
||||
|
||||
# - Photon evaporation
|
||||
geant4_add_dataset(
|
||||
NAME PhotonEvaporation
|
||||
VERSION 4.3.2
|
||||
VERSION 5.0
|
||||
FILENAME G4PhotonEvaporation
|
||||
EXTENSION tar.gz
|
||||
ENVVAR G4LEVELGAMMADATA
|
||||
MD5SUM 027a07cc3259388fd5499aae930a7832
|
||||
MD5SUM d796cc6d8c65d010f8f0e1641408b89d
|
||||
)
|
||||
|
||||
# - Radioisotopes
|
||||
@@ -68,11 +68,11 @@ geant4_add_dataset(
|
||||
# - Optical Surfaces
|
||||
geant4_add_dataset(
|
||||
NAME RealSurface
|
||||
VERSION 1.0
|
||||
FILENAME RealSurface
|
||||
VERSION 2.1
|
||||
FILENAME G4RealSurface
|
||||
EXTENSION tar.gz
|
||||
ENVVAR G4REALSURFACEDATA
|
||||
MD5SUM 0dde95e00fcd3bcd745804f870bb6884
|
||||
MD5SUM f1c72b31d45905f011e2ec4ea96612f4
|
||||
)
|
||||
|
||||
# - SAID
|
||||
|
||||
@@ -1,164 +1,12 @@
|
||||
# - Macros for organizing and specializing code in Geant4 modules
|
||||
#
|
||||
# This file defines the following macros for Geant4 developers needing to
|
||||
# define the sources, headers and library dependencies for a standard
|
||||
# Geant4 granular library module, plus utlities for specializing source
|
||||
# file properties
|
||||
#
|
||||
# GEANT4_DEFINE_MODULE - define a standard Geant4 Granular Library
|
||||
# Module
|
||||
#
|
||||
# ======================
|
||||
# A Geant4 Module is defined as a directory containing subdirectories
|
||||
#
|
||||
# include - holds all header files for the module
|
||||
# src - holds all source files for the module
|
||||
#
|
||||
# GEANT4_DEFINE_MODULE will take the name of the module, a list of header
|
||||
# files, a list of source files and dependencies:
|
||||
#
|
||||
# GEANT4_DEFINE_MODULE(NAME name
|
||||
# HEADERS hdr1 hdr2 ...
|
||||
# SOURCES src1 src2 ...
|
||||
# GRANULAR_DEPENDENCIES dep1 dep2 ...
|
||||
# GLOBAL_DEPENDENCIES dep1 dep2 ...
|
||||
# LINK_LIBRARIES lib1 lib2 ...)
|
||||
#
|
||||
# It assumes that it will be called from a CMake located in the module
|
||||
# root directory (i.e. the directory containing the include and src
|
||||
# subdirectories). It uses this location to define absolute paths to the
|
||||
# headers and sources, and will ignore any absolute paths passed in HEADERS
|
||||
# or SOURCES so that generated files can be passed in.
|
||||
#
|
||||
# The macro defines the variables
|
||||
#
|
||||
# G4MODULENAME = name
|
||||
# ${G4MODULENAME}_HEADERS = List of absolute paths to files given in HEADERS
|
||||
# ${G4MODULENAME}_SOURCES = List of absolute paths to files given in SOURCES
|
||||
# ${G4MODULENAME}_GRANULAR_DEPS = List of granular libraries on which this
|
||||
# module depends
|
||||
# ${G4MODULENAME}_GLOBAL_DEPS = List of global libraries on which this module
|
||||
# depends
|
||||
# ${G4MODULENAME}_LINK_LIBRARIES = List of external libraries to be linked to
|
||||
# this module
|
||||
#
|
||||
# It will also add the module include directory to the list of directories
|
||||
# using include_directories
|
||||
#
|
||||
#
|
||||
# GEANT4_ADD_COMPILE_DEFINITIONS - add compile defintions to a list of files
|
||||
# ================================
|
||||
# GEANT4_ADD_COMPILE_DEFINITIONS(SOURCES src1 src2 ...
|
||||
# COMPILE_DEFINITIONS def1 def 2)
|
||||
#
|
||||
# Here, SOURCES is the list of source files to which compile definitions
|
||||
# will be added. COMPILE_DEFINITIONS gives the list of definitions that
|
||||
# should be added. These definitions will be appended to any existing
|
||||
# definitions given to the sources.
|
||||
#
|
||||
|
||||
# - DEPRECATED: Functionality merged into G4DeveloperAPI/_OLD
|
||||
# Retained as many modules still include it
|
||||
# Simply forward to new module
|
||||
# - Include guard
|
||||
if(__geant4macrodefinemodule_isloaded)
|
||||
if(__GEANT4MACRODEFINEMODULE_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__geant4macrodefinemodule_isloaded YES)
|
||||
set(__GEANT4MACRODEFINEMODULE_INCLUDED YES)
|
||||
|
||||
include(CMakeMacroParseArguments)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro geant4_define_module(NAME <name>
|
||||
# HEADERS <header1> <header2> ... <headerN>
|
||||
# SOURCES <source1> <source2> ... <sourceN>
|
||||
# GRANULAR_DEPENDENCIES <dep1> ... <depN>
|
||||
# GLOBAL_DEPENDENCIES <dep1> ... <depN>
|
||||
# LINK_LIBRARIES <lib1> ... <lib2>)
|
||||
# Define a Geant4 Module's sources and what internal and external
|
||||
# libraries it links to.
|
||||
#
|
||||
macro(geant4_define_module)
|
||||
cmake_parse_arguments(G4DEFMOD
|
||||
""
|
||||
"NAME"
|
||||
"HEADERS;SOURCES;GRANULAR_DEPENDENCIES;GLOBAL_DEPENDENCIES;LINK_LIBRARIES"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
set(G4MODULENAME ${G4DEFMOD_NAME})
|
||||
|
||||
get_filename_component(${G4MODULENAME}_BASEDIR ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
set(${G4MODULENAME}_SRCDIR ${${G4MODULENAME}_BASEDIR}/src)
|
||||
set(${G4MODULENAME}_INCDIR ${${G4MODULENAME}_BASEDIR}/include)
|
||||
|
||||
# We now create absolute paths to the headers and sources,
|
||||
# ignoring any already absolute paths
|
||||
foreach(_HDR ${G4DEFMOD_HEADERS})
|
||||
if(IS_ABSOLUTE ${_HDR})
|
||||
list(APPEND ${G4MODULENAME}_HEADERS ${_HDR})
|
||||
else()
|
||||
list(APPEND ${G4MODULENAME}_HEADERS ${${G4MODULENAME}_INCDIR}/${_HDR})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(_SRC ${G4DEFMOD_SOURCES})
|
||||
if(IS_ABSOLUTE ${_SRC})
|
||||
list(APPEND ${G4MODULENAME}_SOURCES ${_SRC})
|
||||
else()
|
||||
list(APPEND ${G4MODULENAME}_SOURCES ${${G4MODULENAME}_SRCDIR}/${_SRC})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(_LIB ${G4DEFMOD_GRANULAR_DEPENDENCIES})
|
||||
list(APPEND ${G4MODULENAME}_GRANULAR_DEPENDENCIES ${_LIB})
|
||||
endforeach()
|
||||
|
||||
foreach(_LIB ${G4DEFMOD_GLOBAL_DEPENDENCIES})
|
||||
list(APPEND ${G4MODULENAME}_GLOBAL_DEPENDENCIES ${_LIB})
|
||||
endforeach()
|
||||
|
||||
foreach(_LIB ${G4DEFMOD_LINK_LIBRARIES})
|
||||
list(APPEND ${G4MODULENAME}_LINK_LIBRARIES ${_LIB})
|
||||
endforeach()
|
||||
|
||||
include_directories(${${G4MODULENAME}_INCDIR})
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro geant4_add_compile_definitions(SOURCES <source1> ... <sourceN>
|
||||
# COMPILE_DEFINITIONS <def1> ... <defN>
|
||||
# )
|
||||
# Add extra compile definitions to a specific list of sources.
|
||||
# Macroized to handle the need to specify absolute paths.
|
||||
#
|
||||
macro(geant4_add_compile_definitions)
|
||||
cmake_parse_arguments(G4ADDDEF
|
||||
""
|
||||
""
|
||||
"SOURCES;COMPILE_DEFINITIONS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# We assume that the sources have been added at the level of a
|
||||
# a sources.cmake, so are inside the src subdir of the sources.cmake
|
||||
get_filename_component(_ACD_BASE_PATH ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
# Now for each file, add the definitions
|
||||
foreach(_acd_source ${G4ADDDEF_SOURCES})
|
||||
# Extract any existing compile definitions
|
||||
get_source_file_property(
|
||||
_acd_existing_properties
|
||||
${_ACD_BASE_PATH}/src/${_acd_source}
|
||||
COMPILE_DEFINITIONS)
|
||||
|
||||
if(_acd_existing_properties)
|
||||
set(_acd_new_defs ${_acd_existing_properties}
|
||||
${G4ADDDEF_COMPILE_DEFINITIONS})
|
||||
else()
|
||||
set(_acd_new_defs ${G4ADDDEF_COMPILE_DEFINITIONS})
|
||||
endif()
|
||||
|
||||
# quote compile defs because this must epand to space separated list
|
||||
set_source_files_properties(${_ACD_BASE_PATH}/src/${_acd_source}
|
||||
PROPERTIES COMPILE_DEFINITIONS "${_acd_new_defs}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
include(G4DeveloperAPI)
|
||||
|
||||
|
||||
@@ -1,322 +1,12 @@
|
||||
# - Define useful macros for building and installing Geant4 library targets
|
||||
#
|
||||
# This file defines the following macros for Geant4 developers needing to
|
||||
# add shared and static library targets.
|
||||
#
|
||||
# GEANT4_LIBRARY_TARGET - define standard Geant4 library targets
|
||||
#
|
||||
# The macro will take the name of the library and its sources, defining
|
||||
# static and shared targets depending on the value of BUILD_SHARED_LIBS and
|
||||
# BUILD_STATIC_LIBS. Install targets are also created.
|
||||
#
|
||||
# A custom compile definition "GEANT4_DEVELOPER_<CONFIG>" is set on
|
||||
# each target using the target property COMPILE_DEFINITIONS_<CONFIG>
|
||||
# target property
|
||||
|
||||
if(__GEANT4MACROLIBRARYTARGETS_ISLOADED)
|
||||
# - DEPRECATED: Functionality merged into G4DeveloperAPI/_OLD
|
||||
# Retained as many modules still include it
|
||||
# Simply forward to new module
|
||||
# - Include Guard
|
||||
if(__GEANT4MACROLIBRARYTARGETS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__GEANT4MACROLIBRARYTARGETS_ISLOADED TRUE)
|
||||
|
||||
include(CMakeMacroParseArguments)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_compile_definitions_config(<target>)
|
||||
# Set a custom compile definition for a Geant4 target on a
|
||||
# per configuration basis:
|
||||
# For mode <CONFIG>, define GEANT4_DEVELOPER_<CONFIG>
|
||||
#
|
||||
function(geant4_compile_definitions_config _target)
|
||||
if(NOT TARGET ${_target})
|
||||
message(FATAL_ERROR "geant4_compile_definitions_config passed target '${_target}' which is not a valid CMake target")
|
||||
endif()
|
||||
|
||||
# CMake 3 prefers $<CONFIG> in generator expressions, but 2.8.12 only
|
||||
# supports $<CONFIGURATION>
|
||||
set(__default_config_generator "\$<CONFIG>")
|
||||
if(CMAKE_MAJOR_VERSION LESS 3)
|
||||
set(__default_config_generator "\$<CONFIGURATION>")
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${_target}
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
GEANT4_DEVELOPER_${__default_config_generator}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_LIBRARY_TARGET
|
||||
# General build and install of a Geant4 library target
|
||||
#
|
||||
MACRO(GEANT4_LIBRARY_TARGET)
|
||||
CMAKE_PARSE_ARGUMENTS(G4LIBTARGET
|
||||
""
|
||||
"NAME" "SOURCES;GEANT4_LINK_LIBRARIES;LINK_LIBRARIES"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# Add the shared library target and link its dependencies
|
||||
# WIN32 first
|
||||
if(WIN32)
|
||||
# We have to generate the def export file from an archive library.
|
||||
# This is a temporary separate from a real archive library, and
|
||||
# even though it's static, we need to mark that it will have
|
||||
# DLL symbols via the G4LIB_BUILD_DLL macro
|
||||
add_library(_${G4LIBTARGET_NAME}-archive STATIC EXCLUDE_FROM_ALL ${G4LIBTARGET_SOURCES})
|
||||
set(_archive _${G4LIBTARGET_NAME}-archive)
|
||||
target_compile_features(${_archive} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
target_compile_definitions(${_archive} PUBLIC -DG4LIB_BUILD_DLL)
|
||||
|
||||
# - Add the config specific compile definitions
|
||||
geant4_compile_definitions_config(${_archive})
|
||||
|
||||
# - Create the .def file for this library
|
||||
# Use generator expressions to get path to per-mode lib and
|
||||
# older CMAKE_CFG_INTDIR variable to set name of per-mode def
|
||||
# file (Needed as generator expressions cannot be used in argument
|
||||
# to OUTPUT...
|
||||
add_custom_command(OUTPUT _${G4LIBTARGET_NAME}-${CMAKE_CFG_INTDIR}.def
|
||||
COMMAND genwindef -o _${G4LIBTARGET_NAME}-${CMAKE_CFG_INTDIR}.def -l ${G4LIBTARGET_NAME} $<TARGET_FILE:${_archive}>
|
||||
DEPENDS ${_archive} genwindef)
|
||||
|
||||
# - Now we can build the DLL
|
||||
# We create it from a dummy empty C++ file plus the def file.
|
||||
# Also set the public compile definition on it so that clients
|
||||
# will set correct macro automatically.
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/_${G4LIBTARGET_NAME}.cpp
|
||||
"// empty _${G4LIBTARGET_NAME}.cpp\n")
|
||||
|
||||
add_library(${G4LIBTARGET_NAME} SHARED _${G4LIBTARGET_NAME}.cpp
|
||||
_${G4LIBTARGET_NAME}-${CMAKE_CFG_INTDIR}.def)
|
||||
target_compile_definitions(${G4LIBTARGET_NAME} PUBLIC -DG4LIB_BUILD_DLL)
|
||||
target_compile_features(${G4LIBTARGET_NAME} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
|
||||
# - Link the DLL.
|
||||
# We link it to the archive, and the supplied libraries,
|
||||
# but then remove the archive from the LINK_INTERFACE.
|
||||
target_link_libraries(${G4LIBTARGET_NAME}
|
||||
${_archive}
|
||||
${G4LIBTARGET_GEANT4_LINK_LIBRARIES}
|
||||
${G4LIBTARGET_LINK_LIBRARIES})
|
||||
|
||||
set_target_properties(${G4LIBTARGET_NAME}
|
||||
PROPERTIES INTERFACE_LINK_LIBRARIES "${G4LIBTARGET_GEANT4_LINK_LIBRARIES};${G4LIBTARGET_LINK_LIBRARIES}")
|
||||
|
||||
else()
|
||||
# - We build a Shared library in the usual fashion...
|
||||
add_library(${G4LIBTARGET_NAME} SHARED ${G4LIBTARGET_SOURCES})
|
||||
geant4_compile_definitions_config(${G4LIBTARGET_NAME})
|
||||
target_compile_features(${G4LIBTARGET_NAME} PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
target_link_libraries(${G4LIBTARGET_NAME}
|
||||
${G4LIBTARGET_GEANT4_LINK_LIBRARIES}
|
||||
${G4LIBTARGET_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# This property is set to prevent concurrent builds of static and
|
||||
# shared libs removing each others files.
|
||||
set_target_properties(${G4LIBTARGET_NAME}
|
||||
PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
# Always use '@rpath' in install names of libraries. This is the
|
||||
# most flexible mechanism for
|
||||
set_target_properties(${G4LIBTARGET_NAME}
|
||||
PROPERTIES MACOSX_RPATH 1
|
||||
)
|
||||
|
||||
# Install the library - note the use of RUNTIME, LIBRARY and ARCHIVE
|
||||
# this helps with later DLL builds.
|
||||
# Export to standard depends file for later install
|
||||
# NEEDS WORK TO REMOVE HARDCODED LIB/BIN DIR
|
||||
install(TARGETS ${G4LIBTARGET_NAME}
|
||||
EXPORT Geant4LibraryDepends
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
|
||||
|
||||
# Append the library target to a global property so that build tree
|
||||
# export of library dependencies can pick up all targets
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_EXPORTED_TARGETS ${G4LIBTARGET_NAME})
|
||||
endif()
|
||||
|
||||
#
|
||||
# As above, but for static rather than shared library
|
||||
if(BUILD_STATIC_LIBS)
|
||||
# We have to distinguish the static from shared lib, so use -static in
|
||||
# name. Link its dependencies, and ensure we actually link to the
|
||||
# -static targets (We should strictly do this for the external
|
||||
# libraries as well if we want a pure static build).
|
||||
add_library(${G4LIBTARGET_NAME}-static STATIC ${G4LIBTARGET_SOURCES})
|
||||
geant4_compile_definitions_config(${G4LIBTARGET_NAME}-static)
|
||||
target_compile_features(${G4LIBTARGET_NAME}-static PUBLIC ${GEANT4_TARGET_COMPILE_FEATURES})
|
||||
|
||||
set(G4LIBTARGET_GEANT4_LINK_LIBRARIES_STATIC )
|
||||
foreach(_tgt ${G4LIBTARGET_GEANT4_LINK_LIBRARIES})
|
||||
list(APPEND G4LIBTARGET_GEANT4_LINK_LIBRARIES_STATIC ${_tgt}-static)
|
||||
endforeach()
|
||||
|
||||
# If we are building both types of library and builtin clhep etc,
|
||||
# we want to link shared->shared and static->static.
|
||||
# Because externals like clhep appear in G4LIBTARGET_LINK_LIBRARIES,
|
||||
# filter this list to replace shared builtins with their static variant
|
||||
string(REGEX REPLACE
|
||||
"(G4clhep|G4expat|G4zlib|G4geomUSolids)(;|$)" "\\1-static\\2"
|
||||
G4LIBTARGET_LINK_LIBRARIES_STATIC
|
||||
"${G4LIBTARGET_LINK_LIBRARIES}"
|
||||
)
|
||||
|
||||
target_link_libraries(${G4LIBTARGET_NAME}-static
|
||||
${G4LIBTARGET_GEANT4_LINK_LIBRARIES_STATIC}
|
||||
${G4LIBTARGET_LINK_LIBRARIES_STATIC})
|
||||
|
||||
# But we can rename the output library to the correct name
|
||||
# On WIN32 we *retain* the -static postfix because otherwise
|
||||
# we'll conflict with the .lib from the DLL build...
|
||||
# We could also install differently...
|
||||
if(NOT WIN32)
|
||||
set_target_properties(${G4LIBTARGET_NAME}-static
|
||||
PROPERTIES OUTPUT_NAME ${G4LIBTARGET_NAME})
|
||||
endif()
|
||||
|
||||
set_target_properties(${G4LIBTARGET_NAME}-static
|
||||
PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
install(TARGETS ${G4LIBTARGET_NAME}-static
|
||||
EXPORT Geant4LibraryDepends
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
|
||||
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_EXPORTED_TARGETS ${G4LIBTARGET_NAME}-static)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_HEADER_MODULE_TARGET
|
||||
# Build and install for a header only Geant4 module.
|
||||
#
|
||||
MACRO(GEANT4_HEADER_MODULE_TARGET)
|
||||
CMAKE_PARSE_ARGUMENTS(G4HEADERMOD
|
||||
""
|
||||
"COMPONENT"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# Only has one component, and we just have to pick out the headers
|
||||
include(${G4HEADERMOD_COMPONENT})
|
||||
|
||||
# Header install?
|
||||
install(FILES ${${G4MODULENAME}_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development)
|
||||
|
||||
# Store the include path of the component so that the build tree
|
||||
# config file can pick up all needed header paths
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS ${${G4MODULENAME}_INCDIR})
|
||||
ENDMACRO()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_GRANULAR_LIBRARY_TARGET
|
||||
# Build and install for a Geant4 module (granular) library
|
||||
#
|
||||
MACRO(GEANT4_GRANULAR_LIBRARY_TARGET)
|
||||
CMAKE_PARSE_ARGUMENTS(G4GRANLIB
|
||||
""
|
||||
"COMPONENT"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# Granular lib only has one component, but we must pick out
|
||||
# the granular dependencies
|
||||
include(${G4GRANLIB_COMPONENT})
|
||||
|
||||
# Add the library target, using variables set by the inclusion of
|
||||
# the component file
|
||||
GEANT4_LIBRARY_TARGET(NAME ${G4MODULENAME}
|
||||
SOURCES ${${G4MODULENAME}_SOURCES} ${${G4MODULENAME}_HEADERS}
|
||||
GEANT4_LINK_LIBRARIES ${${G4MODULENAME}_GRANULAR_DEPENDENCIES}
|
||||
LINK_LIBRARIES ${${G4MODULENAME}_LINK_LIBRARIES})
|
||||
|
||||
# Header install?
|
||||
install(FILES ${${G4MODULENAME}_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development)
|
||||
|
||||
# Store the include path of the component so that the build tree
|
||||
# config file can pick up all needed header paths
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS ${${G4MODULENAME}_INCDIR})
|
||||
ENDMACRO()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - GEANT4_GLOBAL_LIBRARY_TARGET
|
||||
# Build and install of a Geant4 category (global) library
|
||||
#
|
||||
MACRO(GEANT4_GLOBAL_LIBRARY_TARGET)
|
||||
CMAKE_PARSE_ARGUMENTS(G4GLOBLIB
|
||||
""
|
||||
"NAME"
|
||||
"COMPONENTS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# We loop over the component sources one at a time,
|
||||
# appending properties as we go.
|
||||
foreach(_comp ${G4GLOBLIB_COMPONENTS})
|
||||
include(${_comp})
|
||||
# In case we have a global lib with one component, ensure name gets set
|
||||
if(NOT G4GLOBLIB_NAME)
|
||||
set(G4GLOBLIB_NAME ${G4MODULENAME})
|
||||
endif()
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_GLOBAL_SOURCES ${${G4MODULENAME}_SOURCES})
|
||||
list(APPEND ${G4GLOBLIB_NAME}_GLOBAL_HEADERS ${${G4MODULENAME}_HEADERS})
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES
|
||||
${${G4MODULENAME}_GLOBAL_DEPENDENCIES})
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_LINK_LIBRARIES
|
||||
${${G4MODULENAME}_LINK_LIBRARIES})
|
||||
|
||||
list(APPEND ${G4GLOBLIB_NAME}_BUILDTREE_INCLUDES ${${G4MODULENAME}_INCDIR})
|
||||
endforeach()
|
||||
|
||||
# Filter out duplicates/self in GLOBAL_DEPENDENCIES and LINK_LIBRARIES
|
||||
if(${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES)
|
||||
list(REMOVE_DUPLICATES ${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES)
|
||||
list(REMOVE_ITEM ${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES ${G4GLOBLIB_NAME})
|
||||
endif()
|
||||
if(${G4GLOBLIB_NAME}_LINK_LIBRARIES)
|
||||
list(REMOVE_DUPLICATES ${G4GLOBLIB_NAME}_LINK_LIBRARIES)
|
||||
endif()
|
||||
|
||||
# Now add the library target
|
||||
GEANT4_LIBRARY_TARGET(NAME ${G4GLOBLIB_NAME}
|
||||
SOURCES
|
||||
${${G4GLOBLIB_NAME}_GLOBAL_SOURCES}
|
||||
${${G4GLOBLIB_NAME}_GLOBAL_HEADERS}
|
||||
GEANT4_LINK_LIBRARIES
|
||||
${${G4GLOBLIB_NAME}_GLOBAL_DEPENDENCIES}
|
||||
LINK_LIBRARIES
|
||||
${${G4GLOBLIB_NAME}_LINK_LIBRARIES})
|
||||
|
||||
# Header install?
|
||||
install(FILES ${${G4GLOBLIB_NAME}_GLOBAL_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
COMPONENT Development)
|
||||
|
||||
# Store the include path of the component so that the build tree
|
||||
# config file can pick up all needed header paths
|
||||
set_property(GLOBAL APPEND
|
||||
PROPERTY GEANT4_BUILDTREE_INCLUDE_DIRS ${${G4GLOBLIB_NAME}_BUILDTREE_INCLUDES})
|
||||
|
||||
ENDMACRO()
|
||||
|
||||
set(__GEANT4MACROLIBRARYTARGETS_INCLUDED TRUE)
|
||||
|
||||
include(G4DeveloperAPI)
|
||||
|
||||
|
||||
@@ -19,29 +19,41 @@
|
||||
# FREETYPE - For analysis module, find external FreeType install
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Find required CLHEP package
|
||||
# We prefer to use our internal CLHEP library, but provide an option
|
||||
# to allow an external CLHEP to be used should the user require this.
|
||||
# We also allow that it can be automatically enabled by providing
|
||||
# the CLHEP_ROOT_DIR option (which FindCLHEP will recognize)
|
||||
# CLHEP
|
||||
# ^^^^^
|
||||
#
|
||||
# As requested by ATLAS, an additional option for preferring use of
|
||||
# CLHEP's granular libs is provided when using a system CLHEP.
|
||||
# By default, Geant4 is built with its own internal copy of the CLHEP
|
||||
# libraries and headers. An external install of CLHEP may be used
|
||||
# instead by setting the `GEANT4_USE_SYSTEM_CLHEP` to `ON`.
|
||||
#
|
||||
# CMake can be pointed to the required external install of CLHEP
|
||||
# by providing the `CLHEP_ROOT_DIR` option. Setting this variable
|
||||
# will automatically enable use of an external CLHEP.
|
||||
#
|
||||
# When using an external install of CLHEP, the default is to link
|
||||
# to the full CLHEP library. An additional advanced option
|
||||
# `GEANT4_USE_SYSTEM_CLHEP_GRANULAR` is available to configure
|
||||
# use of the modular CLHEP libraries.
|
||||
#
|
||||
# KNOWNISSUE : For internal CLHEP, how to deal with static and shared?
|
||||
if(CLHEP_ROOT_DIR)
|
||||
set(_default_use_system_clhep ON)
|
||||
# CLHEP_ROOT_DIR is non-standard for Config mode, so attempt temporary translation
|
||||
# into CMAKE_PREFIX_PATH. Could also add as PATHS to find_package,
|
||||
# but CMAKE_PREFIX_PATH has higher search priority.
|
||||
list(INSERT CMAKE_PREFIX_PATH 0 "${CLHEP_ROOT_DIR}")
|
||||
else()
|
||||
set(_default_use_system_clhep OFF)
|
||||
endif()
|
||||
|
||||
option(GEANT4_USE_SYSTEM_CLHEP "Use system CLHEP library" ${_default_use_system_clhep})
|
||||
cmake_dependent_option(GEANT4_USE_SYSTEM_CLHEP_GRANULAR
|
||||
"Use system CLHEP granular libraries" OFF
|
||||
"GEANT4_USE_SYSTEM_CLHEP" OFF
|
||||
)
|
||||
mark_as_advanced(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
set(__system_clhep_mode " (singular)")
|
||||
# Further advanced option to select granular CLHEP libs
|
||||
option(GEANT4_USE_SYSTEM_CLHEP_GRANULAR "Use system CLHEP granular libraries" OFF)
|
||||
mark_as_advanced(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
set(__g4_clhep_components
|
||||
@@ -53,32 +65,35 @@ if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
set(__system_clhep_mode " (granular)")
|
||||
endif()
|
||||
|
||||
# Find CLHEP using package-mode (i.e. FindCLHEP)
|
||||
# This will set up imported targets for us, but we need
|
||||
# to set CLHEP_LIBRARIES afterwards to use these
|
||||
find_package(CLHEP 2.3.3.0 REQUIRED ${__g4_clhep_components})
|
||||
|
||||
set(CLHEP_LIBRARIES CLHEP::CLHEP)
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
set(CLHEP_LIBRARIES)
|
||||
foreach(_comp ${__g4_clhep_components})
|
||||
list(APPEND CLHEP_LIBRARIES "CLHEP::${_comp}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(GEANT4_USE_SYSTEM_CLHEP TRUE)
|
||||
# Find CLHEP using config-mode (i.e. CLHEPConfig)
|
||||
# Note that the imported targets have different properties
|
||||
# depending on version:
|
||||
# >= 2.3.3.0 Imported targets have INTERFACE_INCLUDE_DIRECTORIES
|
||||
# >= 2.3.1.0 Imported targets are namespaced, all components available
|
||||
# < 2.3.1.0 Only CLHEP/CLHEPS available as imported targets
|
||||
#
|
||||
# By supplying components, CLHEP_LIBRARIES is populated with the
|
||||
# appropriate set of imported targets.
|
||||
find_package(CLHEP 2.3.3.0 REQUIRED ${__g4_clhep_components} CONFIG)
|
||||
else()
|
||||
set(CLHEP_FOUND TRUE)
|
||||
set(GEANT4_USE_BUILTIN_CLHEP TRUE)
|
||||
# TODO: CLHEP_INCLUDE_DIRS still required for windows support
|
||||
# Current way of building DLLs requires build of a temporary
|
||||
# archive lib, and this does not link to dependencies, hence
|
||||
# it does not get their usage requirements.
|
||||
# May be fixable by linking or use of better DLL build mechanism
|
||||
# available in CMake >= 3.4
|
||||
# As other externals will need the same treatment, return
|
||||
# to old CLHEP_INCLUDE_DIRS setting
|
||||
#
|
||||
set(CLHEP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/source/externals/clhep/include")
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(CLHEP_LIBRARIES G4clhep)
|
||||
else()
|
||||
set(CLHEP_LIBRARIES G4clhep-static)
|
||||
endif()
|
||||
|
||||
# All G4*** targets are handled internally to use static or shared
|
||||
# as appropriate, so only need to declare core target name
|
||||
set(CLHEP_LIBRARIES G4clhep)
|
||||
endif()
|
||||
|
||||
GEANT4_ADD_FEATURE(GEANT4_USE_SYSTEM_CLHEP "Using system CLHEP library${__system_clhep_mode}")
|
||||
geant4_add_feature(GEANT4_USE_SYSTEM_CLHEP "Using system CLHEP library${__system_clhep_mode}")
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Find required EXPAT package
|
||||
@@ -241,13 +256,14 @@ if(GEANT4_USE_ALL_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
|
||||
endforeach()
|
||||
GEANT4_ADD_FEATURE(GEANT4_USE_USOLIDS "Replacing Geant4 solids with USolids equivalents for ${GEANT4_USE_PARTIAL_USOLIDS_SHAPE_LIST} (EXPERIMENTAL)")
|
||||
endif()
|
||||
list (APPEND GEANT4_USOLIDS_COMPILE_DEFINITIONS ${VECGEOM_DEFINITIONS})
|
||||
|
||||
# Combined definitions
|
||||
add_definitions(${GEANT4_USOLIDS_COMPILE_DEFINITIONS})
|
||||
|
||||
# Add USolids inc dirs here - can be removed once USolids supports
|
||||
# INTERFACE_INCLUDE_DIRECTORIES
|
||||
include_directories(${USOLIDS_INCLUDE_DIRS})
|
||||
include_directories(${USOLIDS_INCLUDE_DIRS} ${VECGEOM_EXTERNAL_INCLUDES})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user