Import Geant4 10.0.0 source tree
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
# - Set up backward compatible Geant4 GNU make 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
|
||||
# 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
|
||||
# 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'
|
||||
# GEANT4_SYSTEM Old style system name, e.g. 'Linux', 'Darwin'
|
||||
# or 'WIN32'
|
||||
#
|
||||
# GEANT4_COMPILER Old system compiler id, e.g. 'g++', 'VC'.
|
||||
# GEANT4_COMPILER Old system compiler id, e.g. 'g++', 'VC'.
|
||||
#
|
||||
# G4INSTALL Location of 'config' subdirectory which contains
|
||||
# all the GNU make toolchain fragments
|
||||
@@ -25,25 +25,25 @@
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# This will not work on Windows however, and here users are recommended
|
||||
# to use Visual Studio directly, or to use CMake for application
|
||||
# configuration.
|
||||
#
|
||||
@@ -52,7 +52,7 @@
|
||||
# - Functions and Macros to help configuration of shell scripts.
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_shell_setup(<shell>)
|
||||
# Set shell parameters such as program, family and common builtins
|
||||
# Set shell parameters such as program, family and common builtins
|
||||
# for supplied shell (e.g. 'bourne' or 'cshell'
|
||||
#
|
||||
macro(_g4tc_shell_setup SHELL_FAMILY)
|
||||
@@ -73,14 +73,14 @@ endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_selflocate(<output> <shell> <script> <variable name>)
|
||||
# Set output to string containing shell commands needed to
|
||||
# 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}
|
||||
set(${TEMPLATE_NAME}
|
||||
"# Self locate script when sourced
|
||||
if [ -z \"\$BASH_VERSION\" ]; then
|
||||
# Not bash, so rely on sourcing from correct location
|
||||
@@ -103,6 +103,7 @@ fi
|
||||
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
|
||||
@@ -110,10 +111,17 @@ fi
|
||||
#
|
||||
# source path_to_script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
#
|
||||
unset g4sls_sourced_dir
|
||||
unset ${LOCATION_VARIABLE}
|
||||
|
||||
set ARGS=($_)
|
||||
if (\"$ARGS\" != \"\") then
|
||||
set g4sls_sourced_dir=\"`dirname \${ARGS[2]}`\"
|
||||
else
|
||||
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.
|
||||
@@ -132,46 +140,46 @@ else
|
||||
else
|
||||
echo \"ERROR \${1} does not contain a Geant4 installation\"
|
||||
endif
|
||||
else
|
||||
unset g4sls_sourced_dir
|
||||
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 \" \"
|
||||
endif
|
||||
endif
|
||||
|
||||
if (\$?g4sls_sourced_dir) then
|
||||
set ${LOCATION_VARIABLE}=\"`cd \${g4sls_sourced_dir} > /dev/null ; pwd`\"
|
||||
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 "if (\${?g4sls_sourced_dir}) then" PARENT_SCOPE)
|
||||
set(GEANT4_TC_ENDIF_SELFLOCATED "endif" PARENT_SCOPE)
|
||||
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 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}
|
||||
set(${TEMPLATE_NAME}
|
||||
"export ${VARIABLE_NAME}=${VARIABLE_VALUE}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(${TEMPLATE_NAME}
|
||||
set(${TEMPLATE_NAME}
|
||||
"setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -180,7 +188,7 @@ endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_setenv_ifnotset_command(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# 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
|
||||
#
|
||||
@@ -199,7 +207,7 @@ fi
|
||||
# -- cshell
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, verbatim to get correct formatting...
|
||||
set(${TEMPLATE_NAME}
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${VARIABLE_NAME}} ) then
|
||||
setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}
|
||||
@@ -266,6 +274,9 @@ macro(_g4tc_configure_tc_variables SHELL_FAMILY SCRIPT_NAME)
|
||||
_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 "Darwin")
|
||||
@@ -290,6 +301,10 @@ macro(_g4tc_configure_tc_variables SHELL_FAMILY SCRIPT_NAME)
|
||||
_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 )
|
||||
@@ -362,6 +377,16 @@ macro(_g4tc_configure_tc_variables SHELL_FAMILY SCRIPT_NAME)
|
||||
|
||||
# - 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)
|
||||
|
||||
@@ -431,7 +456,7 @@ endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_configure_build_tree_scripts()
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# build tree
|
||||
#
|
||||
macro(_g4tc_configure_build_tree_scripts SCRIPT_NAME)
|
||||
@@ -452,7 +477,7 @@ endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_configure_install_tree_script()
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# install tree
|
||||
#
|
||||
macro(_g4tc_configure_install_tree_scripts CONFIGURE_DESTINATION SCRIPT_NAME INSTALL_DESTINATION)
|
||||
@@ -472,7 +497,7 @@ macro(_g4tc_configure_install_tree_scripts CONFIGURE_DESTINATION SCRIPT_NAME INS
|
||||
install(FILES
|
||||
${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
DESTINATION ${INSTALL_DESTINATION}
|
||||
PERMISSIONS
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
@@ -486,23 +511,25 @@ endmacro()
|
||||
# Implementation section
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure shell scripts for BUILD TREE
|
||||
# This means we have to point to libraries in the build tree, but
|
||||
# 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
|
||||
# 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 ${PROJECT_BINARY_DIR}/outputs/library)
|
||||
set(G4LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
|
||||
|
||||
# - Data
|
||||
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
|
||||
list(REMOVE_ITEM GEANT4_EXPORTED_DATASETS "G4ENSDFSTATE")
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
|
||||
geant4_get_dataset_property(${_ds} BUILD_DIR ${_ds}_PATH)
|
||||
@@ -515,8 +542,8 @@ _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
|
||||
# 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
|
||||
@@ -531,7 +558,7 @@ _g4tc_configure_build_tree_scripts(geant4make)
|
||||
set(G4SYSTEM "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
set(G4INSTALL "\"\$geant4make_root\"")
|
||||
|
||||
# - Now need relative paths between 'G4INSTALL' and include/lib dirs
|
||||
# - Now need relative paths between 'G4INSTALL' and include/bin/lib dirs
|
||||
# - Include dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_INCLUDEDIR
|
||||
@@ -540,6 +567,14 @@ file(RELATIVE_PATH
|
||||
)
|
||||
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
|
||||
@@ -553,6 +588,7 @@ set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
|
||||
|
||||
# - Data
|
||||
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
|
||||
list(REMOVE_ITEM GEANT4_EXPORTED_DATASETS "G4ENSDFSTATE")
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
|
||||
geant4_get_dataset_property(${_ds} INSTALL_DIR ${_ds}_PATH)
|
||||
@@ -573,8 +609,8 @@ _g4tc_configure_install_tree_scripts(
|
||||
)
|
||||
|
||||
|
||||
# - For install tree, we also need to install the config directory
|
||||
# which contains all the old toolchain scripts, and to create a
|
||||
# - 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
|
||||
@@ -614,6 +650,7 @@ file(RELATIVE_PATH
|
||||
|
||||
# - Data
|
||||
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
|
||||
list(REMOVE_ITEM GEANT4_EXPORTED_DATASETS "G4ENSDFSTATE")
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
|
||||
geant4_get_dataset_property(${_ds} INSTALL_DIR ${_ds}_PATH)
|
||||
@@ -636,14 +673,14 @@ foreach(_shell bourne;cshell)
|
||||
set(_scriptfullname ${_scriptbasename}${GEANT4_TC_SHELL_EXTENSION})
|
||||
|
||||
# Set locate self command
|
||||
_g4tc_selflocate(GEANT4_ENV_SELFLOCATE_COMMAND
|
||||
${_shell}
|
||||
${_scriptbasename}
|
||||
_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
|
||||
_g4tc_prepend_path(GEANT4_ENV_BINPATH_SETUP
|
||||
${_shell}
|
||||
PATH
|
||||
"\"\$geant4_envbindir\""
|
||||
@@ -680,7 +717,7 @@ foreach(_shell bourne;cshell)
|
||||
install(FILES
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
PERMISSIONS
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
|
||||
Reference in New Issue
Block a user