Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/cmake/Modules/G4ConfigureGNUMakeHelpers.cmake is written in an unsupported language. File is not indexed.

0001 #.rst:
0002 # G4ConfigureGNUMakeHelpers
0003 # -------------------------
0004 #
0005 # This module configures and installs GNU Makefile fragments which
0006 # clients can include in their Makefiles to utilize Geant4's
0007 # Make-based application building toolchain.
0008 #
0009 # The GNU make based buildsystem for Geant4 provides a toolchain for
0010 # users building simple Geant4 applications. The old style build and
0011 # install of Geant4 provides a customized set of non-standard install
0012 # paths with use of the toolchain dependent on environment variables
0013 # pointing to the install paths.
0014 #
0015 # This script processes information on the CMake install paths, system
0016 # and compiler to determine the following variables for backward
0017 # compatibility:
0018 #
0019 #  GEANT4_SYSTEM      Old style system name, e.g. 'Linux', 'Darwin'
0020 #                     or 'WIN32'
0021 #
0022 #  GEANT4_COMPILER    Old system compiler id, e.g. 'g++', 'VC'.
0023 #
0024 #  G4INSTALL          Location of 'config' subdirectory which contains
0025 #                     all the GNU make toolchain fragments
0026 #
0027 #  G4INCLUDE          Old style path to location of Geant4 headers
0028 #
0029 #  G4LIB              Old style library directory path. Rather than
0030 #                     containing the actual libraries, it is expected to
0031 #                     contain subdirectories named
0032 #                     GEANT4_SYSTEM-GEANT4_COMPILER
0033 #
0034 # These variables are used in a CMake configuration file which is used
0035 # to generate shell scripts (C and Bourne flavour) the user can source
0036 # to set up their environment for use of the old toolchain.
0037 # These replace the old 'env.(c)sh' scripts to allow users to work with
0038 # the new CMake built libraries transparently if their application
0039 # relies on the old style toolchain.
0040 #
0041 # The scripts are generated for both the build and install trees so that
0042 # developers wishing to write test applications do not have to install
0043 # their fresh build of Geant4.
0044 #
0045 # Compatibility with the library path style:
0046 #
0047 #  <prefix>/lib/G4SYSTEM-G4COMPILER
0048 #
0049 # is provided by installing a directory 'geant4-<version>' in the
0050 # <prefix>/lib directory and creating a symbolic link inside here
0051 # pointing up one directory level.
0052 # This will not work on Windows however, and here users are recommended
0053 # to use Visual Studio directly, or to use CMake for application
0054 # configuration.
0055 #
0056 
0057 #-----------------------------------------------------------------
0058 # License and Disclaimer
0059 #
0060 # The  Geant4 software  is  copyright of the Copyright Holders  of
0061 # the Geant4 Collaboration.  It is provided  under  the terms  and
0062 # conditions of the Geant4 Software License,  included in the file
0063 # LICENSE and available at  http://cern.ch/geant4/license .  These
0064 # include a list of copyright holders.
0065 #
0066 # Neither the authors of this software system, nor their employing
0067 # institutes,nor the agencies providing financial support for this
0068 # work  make  any representation or  warranty, express or implied,
0069 # regarding  this  software system or assume any liability for its
0070 # use.  Please see the license in the file  LICENSE  and URL above
0071 # for the full disclaimer and the limitation of liability.
0072 #
0073 # This  code  implementation is the result of  the  scientific and
0074 # technical work of the GEANT4 collaboration.
0075 # By using,  copying,  modifying or  distributing the software (or
0076 # any work based  on the software)  you  agree  to acknowledge its
0077 # use  in  resulting  scientific  publications,  and indicate your
0078 # acceptance of all terms of the Geant4 Software license.
0079 #
0080 #-----------------------------------------------------------------
0081 
0082 #-----------------------------------------------------------------------
0083 # GEANT4GMAKE
0084 # On Unices, we try to make the output directory backward compatible
0085 # with the old style 'SYSTEM-COMPILER' format so that applications may be
0086 # built against the targets in the build tree.
0087 #
0088 # Note that for multi-configuration generators like VS and Xcode, these
0089 # directories will have the configuration type (e.g. Debug) appended to
0090 # them, so are not backward compatible with the old Make toolchain in
0091 # these cases.
0092 #
0093 # Also, we only do this on UNIX because we don't support Geant4GMake on
0094 # Windows and also want to avoid mixing static and dynamic libraries on
0095 # windows until the differences are better understood.
0096 #------------------------------------------------------------------------
0097 # Determine the backward compatible system name
0098 #
0099 if(NOT WIN32)
0100   set(GEANT4_SYSTEM ${CMAKE_SYSTEM_NAME})
0101 else()
0102   set(GEANT4_SYSTEM "WIN32")
0103 endif()
0104 
0105 #------------------------------------------------------------------------
0106 # Determine the backward compatible compiler name
0107 # NB: At present Clang detection only works on CMake > 2.8.1
0108 if(CMAKE_COMPILER_IS_GNUCXX)
0109   set(GEANT4_COMPILER "g++")
0110 elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
0111   set(GEANT4_COMPILER "clang")
0112 
0113   # - Newer g++ on OS X may identify as Clang
0114   if(APPLE AND (CMAKE_CXX_COMPILER MATCHES ".*g\\+\\+"))
0115     set(GEANT4_COMPILER "g++")
0116   endif()
0117 
0118 elseif(MSVC)
0119   set(GEANT4_COMPILER "VC")
0120 elseif(CMAKE_CXX_COMPILER MATCHES "icpc.*|icc.*")
0121   set(GEANT4_COMPILER "icc")
0122 elseif(CMAKE_CXX_COMPILER MATCHES "icpx.*|icx.*")
0123   set(GEANT4_COMPILER "icx")
0124 else()
0125   set(GEANT4_COMPILER "UNSUPPORTED")
0126 endif()
0127 
0128 # - Create libdir/softlink to fool geant4make, but only for single mode case
0129 if(UNIX AND NOT CMAKE_CONFIGURATION_TYPES)
0130   if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
0131     file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
0132     execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink . ${GEANT4_SYSTEM}-${GEANT4_COMPILER}
0133       WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
0134       )
0135   endif()
0136 endif()
0137 
0138 
0139 #-----------------------------------------------------------------------
0140 # - Functions and Macros to help configuration of shell scripts.
0141 #-----------------------------------------------------------------------
0142 # macro _g4tc_shell_setup(<shell>)
0143 #       Set shell parameters such as program, family and common builtins
0144 #       for supplied shell (e.g. 'bourne' or 'cshell'
0145 #
0146 macro(_g4tc_shell_setup SHELL_FAMILY)
0147   if(${SHELL_FAMILY} STREQUAL "bourne")
0148     set(GEANT4_TC_SHELL_PROGRAM "/bin/sh")
0149     set(GEANT4_TC_SHELL_FAMILY "Bourne shell")
0150     set(GEANT4_TC_UNSET_COMMAND "unset")
0151     set(GEANT4_TC_SHELL_EXTENSION ".sh")
0152   elseif(${SHELL_FAMILY} STREQUAL "cshell")
0153     set(GEANT4_TC_SHELL_PROGRAM "/bin/csh")
0154     set(GEANT4_TC_SHELL_FAMILY "C shell")
0155     set(GEANT4_TC_UNSET_COMMAND "unsetenv")
0156     set(GEANT4_TC_SHELL_EXTENSION ".csh")
0157   elseif(${SHELL_FAMILY} STREQUAL "cmd")
0158     #the variable GEANT4_TC_SHELL_PROGRAM is not used in .bat generation
0159     set(GEANT4_TC_SHELL_PROGRAM "cmd.exe")
0160     set(GEANT4_TC_SHELL_FAMILY "Windows cmd.exe")
0161     set(GEANT4_TC_UNSET_COMMAND "set")
0162     set(GEANT4_TC_SHELL_EXTENSION ".bat")
0163   else()
0164     message(FATAL_ERROR "Unsupported shell '${SHELL_FAMILY}'")
0165   endif()
0166 endmacro()
0167 
0168 #-----------------------------------------------------------------------
0169 # function _g4tc_selflocate(<output> <shell> <script> <variable name>)
0170 #          Set output to string containing shell commands needed to
0171 #          locate the directory in which script is located if the
0172 #          script is sourced. This derived location is set as the
0173 #          value of the shell variable name.
0174 #
0175 function(_g4tc_selflocate TEMPLATE_NAME SHELL_FAMILY SCRIPT_NAME LOCATION_VARIABLE)
0176   if(${SHELL_FAMILY} STREQUAL "bourne")
0177     set(${TEMPLATE_NAME}
0178       "# Self locate script when sourced
0179 g4sls_sourced_dir=\$\(dirname \${BASH_SOURCE[0]:-$0}\)
0180 
0181 if [  \"\${g4sls_sourced_dir}\" = \".\" ]; then
0182   if [ ! -f ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ]; then
0183     # Not bash, zsh or sh so rely on sourcing from correct location
0184     echo 'ERROR: ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} could NOT self-locate Geant4 installation'
0185     echo 'This is most likely because you are using ksh, dash  or similar'
0186     echo 'To fix this issue, cd to the directory containing this script'
0187     echo 'and source it in that directory.'
0188     unset g4sls_sourced_dir
0189     return 1
0190   fi
0191 fi
0192 ${LOCATION_VARIABLE}=$\(cd \$g4sls_sourced_dir > /dev/null ; pwd\)
0193       "
0194       PARENT_SCOPE
0195       )
0196     # For bourne shell, set the values of the guard variables
0197     set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
0198     set(GEANT4_TC_ENDIF_SELFLOCATED "
0199 # unset local variables
0200 unset g4sls_sourced_dir
0201 unset ${LOCATION_VARIABLE}
0202 "
0203     PARENT_SCOPE)
0204 
0205   elseif(${SHELL_FAMILY} STREQUAL "cshell")
0206     set(${TEMPLATE_NAME}
0207       "# Self locate script when sourced
0208 # If sourced interactively, we can use $_ as this should be
0209 #
0210 #   source path_to_script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
0211 #
0212 unset g4sls_sourced_dir
0213 unset ${LOCATION_VARIABLE}
0214 
0215 set ARGS=($_)
0216 if (\"$ARGS\" != \"\") then
0217   if (\"$ARGS[2]\" =~ */${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}) then
0218     set g4sls_sourced_dir=\"`dirname \${ARGS[2]}`\"
0219   endif
0220 endif
0221 
0222 if (! \$?g4sls_sourced_dir) then
0223   # Oh great, we were sourced non-interactively. This means that $_
0224   # won't be set, so we need an external source of information on
0225   # where the script is located.
0226   # We obtain this in one of two ways:
0227   #   1) Current directory:
0228   #     cd script_dir ; source ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
0229   #
0230   #   2) Supply the directory as an argument to the script:
0231   #     source script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} script_dir
0232   #
0233   if ( -e ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ) then
0234     set g4sls_sourced_dir=\"`pwd`\"
0235   else if ( \"\$1\" != \"\" )  then
0236     if ( -e \${1}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ) then
0237       set g4sls_sourced_dir=\${1}
0238     else
0239       echo \"ERROR \${1} does not contain a Geant4 installation\"
0240     endif
0241   endif
0242 endif
0243 
0244 if (! \$?g4sls_sourced_dir) then
0245   echo \"ERROR: ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} could NOT self-locate Geant4 installation\"
0246   echo \"because it was sourced (i.e. embedded) in another script.\"
0247   echo \"This is due to limitations of (t)csh but can be worked around by providing\"
0248   echo \"the directory where ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} is located\"
0249   echo \"to it, either via cd-ing to the directory before sourcing:\"
0250   echo \"  cd where_script_is ; source ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}\"
0251   echo \"or by supplying the directory as an argument to the script:\"
0252   echo \"  source where_script_is/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} where_script_is\"
0253   echo \" \"
0254   exit 1
0255 endif
0256 
0257 set ${LOCATION_VARIABLE}=\"`cd \${g4sls_sourced_dir} > /dev/null ; pwd`\"
0258 "
0259       PARENT_SCOPE
0260       )
0261 
0262     # For C-shell, set the values of the guard variables
0263     set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
0264    set(GEANT4_TC_ENDIF_SELFLOCATED "
0265 # unset local variables
0266 unset g4sls_sourced_dir
0267 unset ${LOCATION_VARIABLE}
0268 "
0269     PARENT_SCOPE)
0270 
0271 elseif(${SHELL_FAMILY} STREQUAL "cmd")
0272     set(${TEMPLATE_NAME}
0273 "set ${LOCATION_VARIABLE}=
0274 
0275 rem Self locate script when sourced
0276 for /F %%i in (\"%0\") do set BINDIR=%%~dpi
0277 set \"BINDIR=%BINDIR:~0,-1%\"
0278 set \"${LOCATION_VARIABLE}=%BINDIR%\"
0279 rem unset temparary variable
0280 set BINDIR=
0281 "
0282       PARENT_SCOPE
0283       )
0284     # Set the values of the guard variables
0285     set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
0286     set(GEANT4_TC_ENDIF_SELFLOCATED "
0287 rem unset local variables
0288 set ${LOCATION_VARIABLE}=
0289 " PARENT_SCOPE)
0290   endif()
0291 endfunction()
0292 
0293 #-----------------------------------------------------------------------
0294 # function _g4tc_setenv_command(<output> <shell> <name> <value>)
0295 #          Set output to a string whose value is the shell command to
0296 #          set an environment variable with name and value
0297 #
0298 function(_g4tc_setenv_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_VALUE)
0299   if(${SHELL_FAMILY} STREQUAL "bourne")
0300     set(${TEMPLATE_NAME}
0301       "export ${VARIABLE_NAME}=${VARIABLE_VALUE}"
0302       PARENT_SCOPE
0303       )
0304   elseif(${SHELL_FAMILY} STREQUAL "cshell")
0305     set(${TEMPLATE_NAME}
0306       "setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}"
0307       PARENT_SCOPE
0308       )
0309   elseif(${SHELL_FAMILY} STREQUAL "cmd")
0310     set(${TEMPLATE_NAME}
0311       "set \"${VARIABLE_NAME}=${VARIABLE_VALUE}\""
0312       PARENT_SCOPE
0313       )
0314   endif()
0315 endfunction()
0316 
0317 #-----------------------------------------------------------------------
0318 # function _g4tc_setenv_ifnotset_command(<output> <shell> <name> <value>)
0319 #          Set output to a string whose value is the shell command to
0320 #          set an environment variable with name and value if the
0321 #          variable is not already set
0322 #
0323 function(_g4tc_setenv_ifnotset_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_VALUE)
0324   # -- bourne
0325   if(${SHELL_FAMILY} STREQUAL "bourne")
0326     # Have to make this section verbatim to get correct formatting
0327     set(${TEMPLATE_NAME}
0328       "
0329 if [ -z \"\$\{${VARIABLE_NAME}-\}\" ] ; then
0330   export ${VARIABLE_NAME}=${VARIABLE_VALUE}
0331 fi
0332 "
0333       PARENT_SCOPE
0334       )
0335   # -- cshell
0336   elseif(${SHELL_FAMILY} STREQUAL "cshell")
0337     # Again, verbatim to get correct formatting...
0338     set(${TEMPLATE_NAME}
0339       "
0340 if ( ! \${?${VARIABLE_NAME}} ) then
0341   setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}
0342 endif
0343 "
0344        PARENT_SCOPE
0345        )
0346   # -- cmd.exe block
0347   elseif(${SHELL_FAMILY} STREQUAL "cmd")
0348     # Again, this is verbatim so final output is formatted correctly
0349     set(${TEMPLATE_NAME}
0350       "
0351 IF NOT DEFINED ${VARIABLE_NAME} (
0352   set \"${VARIABLE_NAME}=${VARIABLE_VALUE}\"
0353 )
0354       "
0355       PARENT_SCOPE
0356       )
0357   endif()
0358 endfunction()
0359 
0360 #-----------------------------------------------------------------------
0361 # function _g4tc_prepend_path(<output> <shell> <name> <value>)
0362 #          Set output to a string whose value is the shell command to
0363 #          prepend supplied value to the path style environment variable
0364 #          name (e.g. 'PATH')
0365 #
0366 function(_g4tc_prepend_path TEMPLATE_NAME SHELL_FAMILY PATH_VARIABLE
0367   APPEND_VARIABLE)
0368   # -- bourne block
0369   if(${SHELL_FAMILY} STREQUAL "bourne")
0370     # We have to make this section verbatim
0371     set(${TEMPLATE_NAME}
0372     "
0373 if [ -z \"\$\{${PATH_VARIABLE}-\}\" ] ; then
0374   export ${PATH_VARIABLE}=${APPEND_VARIABLE}
0375 else
0376   export ${PATH_VARIABLE}=${APPEND_VARIABLE}:\${${PATH_VARIABLE}}
0377 fi
0378 "
0379     PARENT_SCOPE
0380     )
0381   # -- cshell block
0382   elseif(${SHELL_FAMILY} STREQUAL "cshell")
0383     # Again, this is verbatim so final output is formatted correctly
0384     set(${TEMPLATE_NAME}
0385       "
0386 if ( ! \${?${PATH_VARIABLE}} ) then
0387   setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}
0388 else
0389   setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}:\${${PATH_VARIABLE}}
0390 endif
0391       "
0392       PARENT_SCOPE
0393       )
0394   # -- cmd.exe block
0395   elseif(${SHELL_FAMILY} STREQUAL "cmd")
0396     file(TO_NATIVE_PATH ${APPEND_VARIABLE} APPEND_VARIABLE)
0397     set(${TEMPLATE_NAME}
0398       "
0399 set \"${PATH_VARIABLE}=${APPEND_VARIABLE};%${PATH_VARIABLE}%\"
0400 "
0401       PARENT_SCOPE
0402       )
0403   endif()
0404 endfunction()
0405 
0406 #-----------------------------------------------------------------------
0407 # function _g4tc_append_path(<output> <shell> <name> <value>)
0408 #          Set output to a string whose value is the shell command to
0409 #          append supplied value to the path style environment variable
0410 #          name (e.g. 'PATH')
0411 #
0412 function(_g4tc_append_path TEMPLATE_NAME SHELL_FAMILY PATH_VARIABLE
0413   APPEND_VARIABLE)
0414   # -- bourne block
0415   if(${SHELL_FAMILY} STREQUAL "bourne")
0416     # We have to make this section verbatim
0417     set(${TEMPLATE_NAME}
0418     "
0419 if [ -z \"\$\{${PATH_VARIABLE}-\}\" ] ; then
0420   export ${PATH_VARIABLE}=${APPEND_VARIABLE}
0421 else
0422   export ${PATH_VARIABLE}=\${${PATH_VARIABLE}}:${APPEND_VARIABLE}
0423 fi
0424 "
0425     PARENT_SCOPE
0426     )
0427   # -- cshell block
0428   elseif(${SHELL_FAMILY} STREQUAL "cshell")
0429     # Again, this is verbatim so final output is formatted correctly
0430     set(${TEMPLATE_NAME}
0431       "
0432 if ( ! \${?${PATH_VARIABLE}} ) then
0433   setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}
0434 else
0435   setenv ${PATH_VARIABLE} \${${PATH_VARIABLE}}:${APPEND_VARIABLE}
0436 endif
0437       "
0438       PARENT_SCOPE
0439       )
0440   # -- cmd.exe block
0441   elseif(${SHELL_FAMILY} STREQUAL "cmd")
0442     file(TO_NATIVE_PATH ${APPEND_VARIABLE} APPEND_VARIABLE)
0443     set(${TEMPLATE_NAME}
0444       "
0445 set \"${PATH_VARIABLE}=%${PATH_VARIABLE}%;${APPEND_VARIABLE}\"
0446 "
0447       PARENT_SCOPE
0448       )
0449   endif()
0450 endfunction()
0451 
0452 #-----------------------------------------------------------------------
0453 # MACRO(_g4tc_configure_tc_variables)
0454 # Macro to perform the actual setting of the low level toolchain variables
0455 # which need to be set in the final shell files.
0456 # We do this in a separate macro so that we can wrap it in different ways for
0457 # the install and build trees.
0458 #
0459 macro(_g4tc_configure_tc_variables SHELL_FAMILY SCRIPT_NAME)
0460   # - Set up the requested shell
0461   _g4tc_shell_setup(${SHELL_FAMILY})
0462 
0463   # - Locate self
0464   _g4tc_selflocate(GEANT4_TC_LOCATE_SELF_COMMAND ${SHELL_FAMILY} ${SCRIPT_NAME} geant4make_root)
0465 
0466 
0467   # - Standard Setup and Paths
0468   _g4tc_setenv_command(GEANT4_TC_G4SYSTEM ${SHELL_FAMILY} G4SYSTEM ${G4SYSTEM})
0469   _g4tc_setenv_command(GEANT4_TC_G4INSTALL ${SHELL_FAMILY} G4INSTALL ${G4INSTALL})
0470   _g4tc_setenv_command(GEANT4_TC_G4INCLUDE ${SHELL_FAMILY} G4INCLUDE ${G4INCLUDE})
0471 
0472   _g4tc_prepend_path(GEANT4_TC_G4BIN_PATH_SETUP ${SHELL_FAMILY} PATH ${G4BIN_DIR})
0473 
0474   _g4tc_setenv_command(GEANT4_TC_G4LIB ${SHELL_FAMILY} G4LIB ${G4LIB})
0475 
0476   if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
0477     _g4tc_prepend_path(GEANT4_TC_G4LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH ${G4LIB_DIR})
0478   endif()
0479 
0480   _g4tc_setenv_ifnotset_command(GEANT4_TC_G4WORKDIR_SETUP ${SHELL_FAMILY} G4WORKDIR ${G4WORKDIR_DEFAULT})
0481   _g4tc_prepend_path(GEANT4_TC_G4WORKDIR_PATH_SETUP ${SHELL_FAMILY} PATH
0482   \${G4WORKDIR}/bin/\${G4SYSTEM})
0483 
0484   # - Geant4 Library build setup
0485   # We prefer shared libs if these are built, otherwise fall back to static
0486   # On Win32, we also want DLLs?
0487   if(BUILD_SHARED_LIBS)
0488     _g4tc_setenv_command(GEANT4_TC_G4LIB_BUILD_SHARED ${SHELL_FAMILY} G4LIB_BUILD_SHARED 1)
0489     if(WIN32)
0490       _g4tc_setenv_command(GEANT4_TC_G4LIB_USE_DLL ${SHELL_FAMILY} G4LIB_USE_DLL 1)
0491     endif()
0492   else()
0493     _g4tc_setenv_command(GEANT4_TC_G4LIB_BUILD_STATIC ${SHELL_FAMILY} G4LIB_BUILD_STATIC 1)
0494   endif()
0495 
0496   # - Multithreading
0497   if(GEANT4_BUILD_MULTITHREADED)
0498     _g4tc_setenv_command(GEANT4_TC_G4MULTITHREADED ${SHELL_FAMILY} G4MULTITHREADED 1)
0499   endif()
0500 
0501   # - Resource file paths
0502   set(GEANT4_TC_DATASETS )
0503   foreach(_ds ${GEANT4_EXPORTED_DATASETS})
0504     _g4tc_setenv_command(_dssetenvcmd ${SHELL_FAMILY} ${${_ds}_ENVVAR} ${${_ds}_PATH})
0505     set(GEANT4_TC_DATASETS "${GEANT4_TC_DATASETS}${_dssetenvcmd}\n")
0506   endforeach()
0507 
0508   set(GEANT4_TC_TOOLS_FONT_PATH "# FREETYPE SUPPORT NOT AVAILABLE")
0509   if(GEANT4_USE_FREETYPE)
0510     _g4tc_prepend_path(GEANT4_TC_TOOLS_FONT_PATH
0511       ${SHELL_FAMILY}
0512       TOOLS_FONT_PATH
0513       "${TOOLS_FONT_PATH}"
0514       )
0515   endif()
0516 
0517 
0518   # - CLHEP...
0519   if(GEANT4_USE_SYSTEM_CLHEP)
0520     # Have to use detected CLHEP paths to set base dir and others
0521     get_filename_component(_CLHEP_INCLUDE_DIR "${CLHEP_INCLUDE_DIR}" REALPATH)
0522     get_filename_component(_CLHEP_BASE_DIR "${_CLHEP_INCLUDE_DIR}" DIRECTORY)
0523     get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
0524 
0525     get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
0526     get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
0527 
0528     set(GEANT4_TC_G4LIB_USE_CLHEP "# USING SYSTEM CLHEP")
0529     _g4tc_setenv_command(GEANT4_TC_CLHEP_BASE_DIR ${SHELL_FAMILY} CLHEP_BASE_DIR "${_CLHEP_BASE_DIR}")
0530     _g4tc_setenv_command(GEANT4_TC_CLHEP_INCLUDE_DIR ${SHELL_FAMILY} CLHEP_INCLUDE_DIR "${_CLHEP_INCLUDE_DIR}")
0531 
0532     # Only need to handle CLHEP_LIB for granular case
0533     _g4tc_setenv_command(GEANT4_TC_CLHEP_LIB_DIR ${SHELL_FAMILY} CLHEP_LIB_DIR ${_CLHEP_LIB_DIR})
0534 
0535 
0536     if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
0537       _g4tc_prepend_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH \${CLHEP_LIB_DIR})
0538     endif()
0539 
0540   else()
0541     # We have to configure things to point to the internal CLHEP...
0542     # Probably sufficient to do nothing...
0543     set(GEANT4_TC_G4LIB_USE_CLHEP "# USING INTERNAL CLHEP")
0544   endif()
0545 
0546   # - EXPAT
0547   if(GEANT4_USE_SYSTEM_EXPAT)
0548     set(GEANT4_TC_G4LIB_USE_EXPAT "# USING SYSTEM EXPAT")
0549   else()
0550     _g4tc_setenv_command(GEANT4_TC_G4LIB_USE_EXPAT ${SHELL_FAMILY} G4LIB_USE_EXPAT 1)
0551   endif()
0552 
0553   # - ZLIB...
0554   if(GEANT4_USE_SYSTEM_ZLIB)
0555     set(GEANT4_TC_G4LIB_USE_ZLIB "# USING SYSTEM ZLIB")
0556   else()
0557     _g4tc_setenv_command(GEANT4_TC_G4LIB_USE_ZLIB ${SHELL_FAMILY} G4LIB_USE_ZLIB 1)
0558   endif()
0559 
0560   # - PTL...
0561   if(GEANT4_USE_SYSTEM_PTL)
0562     set(GEANT4_TC_G4LIB_USE_PTL "# USING SYSTEM PTL")
0563   else()
0564     _g4tc_setenv_command(GEANT4_TC_G4LIB_USE_PTL ${SHELL_FAMILY} G4LIB_USE_PTL 1)
0565   endif()
0566 
0567   # - GDML...
0568   if(GEANT4_USE_GDML)
0569     _g4tc_setenv_command(GEANT4_TC_G4LIB_USE_GDML ${SHELL_FAMILY} G4LIB_USE_GDML 1)
0570     # Backward compatibility requires XERCESCROOT to be set
0571     # As this is a 'rootdir' determine it from the XERCESC_INCLUDE_DIR
0572     # variable...
0573     get_filename_component(_xercesc_root ${XercesC_INCLUDE_DIR} PATH)
0574     _g4tc_setenv_command(GEANT4_TC_GDML_PATH_SETUP ${SHELL_FAMILY} XERCESCROOT ${_xercesc_root})
0575 
0576     # Needed temporarily to workaround issue on LCG setups
0577     if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
0578       get_filename_component(_xercesc_libdir ${XercesC_LIBRARY_RELEASE} DIRECTORY)
0579       _g4tc_prepend_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH ${_xercesc_libdir})
0580     endif()
0581   else()
0582     set(GEANT4_TC_G4LIB_USE_GDML "# NOT BUILT WITH GDML SUPPORT")
0583   endif()
0584 
0585   # - G3TOG4...
0586   if(GEANT4_USE_G3TOG4)
0587     _g4tc_setenv_command(GEANT4_TC_G4LIB_USE_G3TOG4 ${SHELL_FAMILY} G4LIB_USE_G3TOG4 1)
0588   else()
0589     set(GEANT4_TC_G4LIB_USE_G3TOG4 "# NOT BUILT WITH G3TOG4 SUPPORT")
0590   endif()
0591 
0592   # - USolids/VecGeom
0593   if(GEANT4_USE_USOLIDS)
0594     # Derive base dir from include path, NB, not 100% robust as Geant4GNUmake makes
0595     # significant assumptions about how USolids was installed
0596     get_filename_component(_USOLIDS_INCLUDE_DIR "${USOLIDS_INCLUDE_DIRS}" REALPATH)
0597     get_filename_component(_USOLIDS_BASE_DIR "${VECGEOM_INSTALL_DIR}" REALPATH)
0598     _g4tc_setenv_command(GEANT4_TC_USOLIDS_BASE_DIR ${SHELL_FAMILY} USOLIDS_BASE_DIR "${_USOLIDS_BASE_DIR}")
0599 
0600     if(GEANT4_USE_ALL_USOLIDS)
0601       _g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_USOLIDS ${SHELL_FAMILY} G4GEOM_USE_USOLIDS 1)
0602       set(GEANT4_TC_G4GEOM_USE_PARTIAL_USOLIDS "# FULL USOLIDS REPLACEMENT")
0603     else()
0604       set(GEANT4_TC_G4GEOM_USE_USOLIDS "# PARTIAL USOLIDS REPLACEMENT")
0605       _g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_PARTIAL_USOLIDS ${SHELL_FAMILY} G4GEOM_USE_PARTIAL_USOLIDS 1)
0606       foreach(__g4_usolid_shape ${GEANT4_USE_PARTIAL_USOLIDS_SHAPE_LIST})
0607         _g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_U${__g4_usolid_shape} ${SHELL_FAMILY} G4GEOM_USE_U${__g4_usolid_shape} 1)
0608       endforeach()
0609     endif()
0610   else()
0611     set(GEANT4_TC_USOLIDS_BASE_DIR "# NOT BUILT WITH USOLIDS SUPPORT")
0612   endif()
0613 
0614   # - USER INTERFACE AND VISUALIZATION MODULES...
0615   # - Terminals
0616   if(NOT WIN32)
0617     _g4tc_setenv_command(GEANT4_TC_G4UI_USE_TCSH ${SHELL_FAMILY} G4UI_USE_TCSH 1)
0618     set(GEANT4_TC_G4UI_USE_WIN32 "# WIN32 TERMINAL UI NOT AVAILABLE ON ${CMAKE_SYSTEM_NAME}")
0619   else()
0620     set(GEANT4_TC_G4UI_USE_TCSH "# TCSH TERMINAL UI NOT AVAILABLE ON ${CMAKE_SYSTEM_NAME}")
0621     _g4tc_setenv_command(GEANT4_TC_G4UI_USE_WIN32 ${SHELL_FAMILY} G4UI_USE_WIN32 1)
0622   endif()
0623 
0624   # - Qt UI AND VIS
0625   if(GEANT4_USE_QT)
0626     _g4tc_setenv_command(GEANT4_TC_QT_VERSION ${SHELL_FAMILY} QT_VERSION ${QT_VERSION_MAJOR})
0627     _g4tc_setenv_command(GEANT4_TC_QTHOME ${SHELL_FAMILY} QTHOME ${G4QTHOME})
0628     _g4tc_setenv_command(GEANT4_TC_QTLIBPATH ${SHELL_FAMILY} QTLIBPATH ${G4QTLIBPATH})
0629     _g4tc_setenv_command(GEANT4_TC_G4UI_USE_QT ${SHELL_FAMILY} G4UI_USE_QT 1)
0630     _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLQT ${SHELL_FAMILY} G4VIS_USE_OPENGLQT 1)
0631 
0632     # Dynamic loader path
0633     if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
0634       _g4tc_prepend_path(GEANT4_TC_QT_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH \${QTLIBPATH})
0635     endif()
0636   else()
0637     set(GEANT4_TC_G4UI_USE_QT "# NOT BUILT WITH QT INTERFACE")
0638   endif()
0639 
0640   # - XM UI AND VIS
0641   if(GEANT4_USE_XM)
0642     _g4tc_setenv_command(GEANT4_TC_G4UI_USE_XM ${SHELL_FAMILY} G4UI_USE_XM 1)
0643     _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLXM ${SHELL_FAMILY} G4VIS_USE_OPENGLXM 1)
0644 
0645     # Might need library setup, but for now recommend system install....
0646   else()
0647     set(GEANT4_TC_G4UI_USE_XM "# NOT BUILT WITH XM INTERFACE")
0648   endif()
0649 
0650   # - OpenInventor
0651   if(GEANT4_USE_INVENTOR)
0652     if(UNIX)
0653       _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENINVENTOR ${SHELL_FAMILY} G4VIS_USE_OIX 1)
0654     else()
0655       _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENINVENTOR ${SHELL_FAMILY} G4VIS_USE_OIWIN32 1)
0656     endif()
0657   else()
0658     set(GEANT4_TC_G4VIS_USE_OPENINVENTOR "# NOT BUILT WITH INVENTOR SUPPORT")
0659   endif()
0660 
0661 
0662   # - X11 OpenGL
0663   if(GEANT4_USE_OPENGL_X11)
0664     _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLX ${SHELL_FAMILY} G4VIS_USE_OPENGLX 1)
0665   else()
0666     set(GEANT4_TC_G4VIS_USE_OPENGLX "# NOT BUILT WITH OPENGL(X11) SUPPORT")
0667   endif()
0668 
0669   # - WIN32 OpenGL
0670   if(GEANT4_USE_OPENGL_WIN32)
0671     _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENWIN32 ${SHELL_FAMILY} G4VIS_USE_OPENWIN32 1)
0672   else()
0673     set(GEANT4_TC_G4VIS_USE_OPENGLWIN32 "# NOT BUILT WITH OPENGL(WIN32) SUPPORT")
0674   endif()
0675 
0676   # - X11 RayTracer
0677   if(GEANT4_USE_RAYTRACER_X11)
0678     _g4tc_setenv_command(GEANT4_TC_G4VIS_USE_RAYTRACERX ${SHELL_FAMILY} G4VIS_USE_RAYTRACERX 1)
0679   else()
0680     set(GEANT4_TC_G4VIS_USE_RAYTRACERX "# NOT BUILT WITH RAYTRACER(X11) SUPPORT")
0681   endif()
0682 endmacro()
0683 
0684 
0685 #-----------------------------------------------------------------------
0686 # macro _g4tc_configure_build_tree_scripts()
0687 #       Macro to configure toolchain compatibility scripts for the
0688 #       build tree
0689 #
0690 macro(_g4tc_configure_build_tree_scripts SCRIPT_NAME)
0691   # Need to process for bourne and cshell families
0692   foreach(_shell bourne;cshell)
0693     # Generate the variables
0694     _g4tc_configure_tc_variables(${_shell} ${SCRIPT_NAME})
0695 
0696     # Configure the file - goes straight into the binary dir
0697     configure_file(
0698       ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4make-skeleton.in
0699       ${PROJECT_BINARY_DIR}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
0700       @ONLY
0701       )
0702   endforeach()
0703 endmacro()
0704 
0705 
0706 #-----------------------------------------------------------------------
0707 # macro _g4tc_configure_install_tree_script()
0708 #       Macro to configure toolchain compatibility scripts for the
0709 #       install tree
0710 #
0711 macro(_g4tc_configure_install_tree_scripts CONFIGURE_DESTINATION SCRIPT_NAME INSTALL_DESTINATION)
0712   # Need to process for bourne and cshell families
0713   foreach(_shell bourne;cshell)
0714     # Generate the variables
0715     _g4tc_configure_tc_variables(${_shell} ${SCRIPT_NAME})
0716 
0717     # Configure the file
0718     configure_file(
0719       ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4make-skeleton.in
0720       ${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
0721       @ONLY
0722       )
0723 
0724     # Install it to the required location
0725     install(FILES
0726       ${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
0727       DESTINATION ${INSTALL_DESTINATION}
0728       PERMISSIONS
0729         OWNER_READ OWNER_WRITE OWNER_EXECUTE
0730         GROUP_READ GROUP_EXECUTE
0731         WORLD_READ WORLD_EXECUTE
0732       COMPONENT Development
0733       )
0734   endforeach()
0735 endmacro()
0736 
0737 
0738 #-----------------------------------------------------------------------
0739 # Implementation section
0740 #-----------------------------------------------------------------------
0741 # Configure shell scripts for BUILD TREE
0742 # This means we have to point to libraries in the build tree, but
0743 # includes and resource files will be in the source tree
0744 # This script never needs to be relocatable, so we don't need to use the
0745 # self location functionality.
0746 # N.B. IT WILL NOT WORK when building with VS/Xcode or any multiconfig
0747 # buildtool because we cannot reconcile the output paths these use with
0748 # those expected by the old toolchain...
0749 #
0750 set(G4SYSTEM  "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
0751 set(G4INSTALL ${PROJECT_SOURCE_DIR})
0752 set(G4INCLUDE ${PROJECT_BINARY_DIR}/this_is_a_deliberate_dummy_path)
0753 set(G4BIN_DIR ${PROJECT_BINARY_DIR})
0754 set(G4LIB ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
0755 set(G4LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
0756 set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
0757 
0758 # Resource files
0759 # - Data
0760 geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
0761 foreach(_ds ${GEANT4_EXPORTED_DATASETS})
0762   geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
0763   geant4_get_dataset_property(${_ds} BUILD_DIR ${_ds}_PATH)
0764 endforeach()
0765 
0766 # - Fonts
0767 set(TOOLS_FONT_PATH "${PROJECT_SOURCE_DIR}/source/externals/g4tools/fonts")
0768 
0769 # - Configure the shell scripts for the BUILD TREE
0770 _g4tc_configure_build_tree_scripts(geant4make)
0771 
0772 
0773 #-----------------------------------------------------------------------
0774 # Configure shell scripts for INSTALL TREE
0775 # This means we have to point things to their final location when
0776 # installed. These paths are all determined by the CMAKE_INSTALL_FULL
0777 # directories and others.
0778 # If we are relocatable, then the structure we will have is
0779 # +- CMAKE_INSTALL_PREFIX
0780 #    +- LIBDIR/Geant4-VERSION (G4LIB)
0781 #    +- INCLUDEDIR/Geant4     (G4INCLUDE)
0782 #    +- DATADIR/
0783 #       +- geant4make              (THIS IS G4INSTALL!)
0784 #          +- geant4make.(c)sh
0785 #          +- config/
0786 
0787 # - Construct universal backward compatible INSTALL TREE PATHS.
0788 set(G4SYSTEM  "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
0789 set(G4INSTALL "\"\$geant4make_root\"")
0790 
0791 # - Now need relative paths between 'G4INSTALL' and include/bin/lib dirs
0792 # - Include dir
0793 file(RELATIVE_PATH
0794   G4MAKE_TO_INCLUDEDIR
0795   ${CMAKE_INSTALL_FULL_DATADIR}/geant4make
0796   ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${PROJECT_NAME}
0797   )
0798 set(G4INCLUDE "\"`cd \$geant4make_root/${G4MAKE_TO_INCLUDEDIR} > /dev/null \; pwd`\"")
0799 
0800 # - Bin dir
0801 file(RELATIVE_PATH
0802   G4MAKE_TO_BINDIR
0803   ${CMAKE_INSTALL_FULL_DATADIR}/geant4make
0804   ${CMAKE_INSTALL_FULL_BINDIR}
0805   )
0806 set(G4BIN_DIR "\"`cd \$geant4make_root/${G4MAKE_TO_BINDIR} > /dev/null \; pwd`\"")
0807 
0808 # - Lib dir
0809 file(RELATIVE_PATH
0810   G4MAKE_TO_LIBDIR
0811   ${CMAKE_INSTALL_FULL_DATADIR}/geant4make
0812   ${CMAKE_INSTALL_FULL_LIBDIR}
0813   )
0814 set(G4LIB "\"`cd \$geant4make_root/${G4MAKE_TO_LIBDIR}/Geant4-${Geant4_VERSION} > /dev/null \; pwd`\"")
0815 set(G4LIB_DIR "\"`cd \$geant4make_root/${G4MAKE_TO_LIBDIR} > /dev/null \; pwd`\"")
0816 
0817 set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
0818 
0819 # Resource files
0820 # - Data
0821 geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
0822 foreach(_ds ${GEANT4_EXPORTED_DATASETS})
0823   geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
0824   geant4_get_dataset_property(${_ds} INSTALL_DIR ${_ds}_PATH)
0825 
0826   file(RELATIVE_PATH
0827     G4MAKE_TO_DATADIR
0828     ${CMAKE_INSTALL_FULL_DATADIR}/geant4make
0829     ${${_ds}_PATH}
0830     )
0831   set(${_ds}_PATH "\"`cd \$geant4make_root/${G4MAKE_TO_DATADIR} > /dev/null \; pwd`\"")
0832 endforeach()
0833 
0834 # - Fonts
0835 set(TOOLS_FONT_PATH "\"`cd \$geant4make_root/../fonts > /dev/null ; pwd`\"")
0836 
0837 # - Configure the shell scripts for the INSTALL TREE
0838 _g4tc_configure_install_tree_scripts(
0839     ${PROJECT_BINARY_DIR}/InstallTreeFiles
0840     geant4make
0841     ${CMAKE_INSTALL_DATADIR}/geant4make
0842     )
0843 
0844 
0845 # - For install tree, we also need to install the config directory
0846 #   which contains all the old toolchain scripts, and to create a
0847 #   softlink to the G4SYSTEM directory.
0848 #
0849 install(DIRECTORY config
0850     DESTINATION ${CMAKE_INSTALL_DATADIR}/geant4make
0851     COMPONENT Development
0852     FILES_MATCHING PATTERN "*.gmk"
0853     PATTERN "CVS" EXCLUDE
0854     PATTERN ".svn" EXCLUDE
0855     PATTERN "scripts/" EXCLUDE
0856 )
0857 
0858 # Compatibility softlink to library directory on UNIX only
0859 if(UNIX)
0860   install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E make_directory \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/Geant4-${Geant4_VERSION}\")")
0861   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}\")")
0862 endif()
0863 
0864 #-----------------------------------------------------------------------
0865 # TEMPORARY
0866 # Configure environment setup script for install of Geant4
0867 # Temporarily here to keep all shell setup in one place.
0868 # Later, should be refactored into its own module, with module containing
0869 # all the shell tools above.
0870 #
0871 # - Script base name (without extension
0872 set(_scriptbasename geant4)
0873 
0874 # - Relative path between bindir (where script is) and library directory
0875 file(RELATIVE_PATH
0876   G4ENV_BINDIR_TO_LIBDIR
0877   ${CMAKE_INSTALL_FULL_BINDIR}
0878   ${CMAKE_INSTALL_FULL_LIBDIR}
0879   )
0880 
0881 # Resource Files
0882 # - Data
0883   if(NOT IS_ABSOLUTE ${GEANT4_INSTALL_DATADIR})
0884     file(RELATIVE_PATH
0885       G4ENV_BINDIR_TO_DATADIR
0886       ${CMAKE_INSTALL_FULL_BINDIR}
0887       ${GEANT4_INSTALL_FULL_DATADIR}
0888       )
0889     set(GEANT4_DATA_DIR "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATADIR} > /dev/null \; pwd`\"")
0890     file(TO_NATIVE_PATH ${G4ENV_BINDIR_TO_DATADIR} G4ENV_BINDIR_TO_DATADIR)
0891     set(GEANT4_DATA_DIRW "\%geant4_envbindir\%\\${G4ENV_BINDIR_TO_DATADIR}")
0892   else()
0893     set(GEANT4_DATA_DIR "\"${GEANT4_INSTALL_DATADIR}\"")
0894     file(TO_NATIVE_PATH ${GEANT4_INSTALL_DATADIR} GEANT4_INSTALL_DATADIR)
0895     set(GEANT4_DATA_DIRW "${GEANT4_INSTALL_DATADIR}")
0896   endif()
0897 
0898   geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
0899   foreach(_ds ${GEANT4_EXPORTED_DATASETS})
0900     geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
0901     geant4_get_dataset_property(${_ds} DIRECTORY ${_ds}_PATH)
0902  endforeach()
0903 
0904 # - Fonts
0905 file(RELATIVE_PATH
0906   G4ENV_BINDIR_TO_DATADIR
0907   "${CMAKE_INSTALL_FULL_BINDIR}"
0908   "${CMAKE_INSTALL_FULL_DATADIR}"
0909   )
0910 set(TOOLS_FONT_PATH "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATADIR}/fonts > /dev/null ; pwd`\"")
0911 
0912 # list of shells
0913 set(shells_list bourne;cshell)
0914 if(WIN32)
0915   list(APPEND shells_list cmd)
0916 endif()
0917 
0918 #os which use LD_LIBRARY_PATH
0919 set(_oswithldpath Linux)
0920 
0921 # - Configure for each shell
0922 foreach(_shell IN LISTS shells_list)
0923   # Setup the shell
0924   _g4tc_shell_setup(${_shell})
0925 
0926   # Set script full name
0927   set(_scriptfullname ${_scriptbasename}${GEANT4_TC_SHELL_EXTENSION})
0928 
0929   # Set locate self command
0930   _g4tc_selflocate(GEANT4_ENV_SELFLOCATE_COMMAND
0931     ${_shell}
0932     ${_scriptbasename}
0933     geant4_envbindir
0934     )
0935 
0936   if(NOT ${_shell} STREQUAL cmd)
0937     # Set path, which should be where the script itself is installed
0938     _g4tc_prepend_path(GEANT4_ENV_BINPATH_SETUP
0939       ${_shell}
0940       PATH
0941       "\"\$geant4_envbindir\""
0942       )
0943 
0944     # Set library path, based on relative paths between bindir and libdir
0945     if(${CMAKE_SYSTEM_NAME} IN_LIST _oswithldpath)
0946       _g4tc_prepend_path(GEANT4_ENV_LIBPATH_SETUP
0947         ${_shell}
0948         LD_LIBRARY_PATH
0949         "\"`cd $geant4_envbindir/${G4ENV_BINDIR_TO_LIBDIR} > /dev/null ; pwd`\""
0950         )
0951     endif()
0952 
0953     # Third party lib paths
0954     # - CLHEP, if system
0955     set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "# - Builtin CLHEP used")
0956     if(GEANT4_USE_SYSTEM_CLHEP)
0957       # Handle granular vs singular cases
0958             get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
0959       get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
0960       get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
0961 
0962       if(${CMAKE_SYSTEM_NAME} IN_LIST _oswithldpath)
0963         _g4tc_append_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP
0964           ${_shell}
0965           LD_LIBRARY_PATH
0966           "${_CLHEP_LIB_DIR}"
0967           )
0968       else()
0969         set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "# System CLHEP in use, no configuration required")
0970       endif()
0971     endif()
0972 
0973     # - XercesC
0974     set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "# GDML SUPPORT NOT AVAILABLE")
0975     if(GEANT4_USE_GDML)
0976       get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" REALPATH)
0977       get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" DIRECTORY)
0978       if(${CMAKE_SYSTEM_NAME} IN_LIST _oswithldpath)
0979         _g4tc_append_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP
0980           ${_shell}
0981           LD_LIBRARY_PATH
0982           "${_XERCESC_LIB_DIR}"
0983           )
0984       else()
0985         set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "# GDML Supported, no configuration of Xerces-C required")
0986       endif()
0987     endif()
0988 
0989     # - Set data paths
0990     set(GEANT4_ENV_DATASETS )
0991      _g4tc_setenv_command(_dssetenvcmd ${_shell} GEANT4_DATA_DIR ${GEANT4_DATA_DIR})
0992     set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
0993     set(_dssetenvcmd "
0994 # - Variables for individual datasets
0995 # Uncomment the line and edit the path to the dataset if installed in not standard location.")
0996    set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n\n")
0997    foreach(_ds ${GEANT4_EXPORTED_DATASETS})
0998       _g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} "$GEANT4_DATA_DIR/${${_ds}_PATH}")
0999       set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}# ${_dssetenvcmd}\n")
1000     endforeach()
1001 
1002     # - Set Font Path
1003     set(GEANT4_ENV_TOOLS_FONT_PATH "# FREETYPE SUPPORT NOT AVAILABLE")
1004     if(GEANT4_USE_FREETYPE)
1005       _g4tc_append_path(GEANT4_ENV_TOOLS_FONT_PATH
1006         ${_shell}
1007         TOOLS_FONT_PATH
1008         "${TOOLS_FONT_PATH}"
1009         )
1010     endif()
1011 
1012     # Configure the file
1013     configure_file(
1014       ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-env-skeleton.in
1015       ${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
1016       @ONLY
1017       )
1018  else()
1019    # message(STATUS "bat skeleton")
1020 
1021    # Set path, which should be where the script itself is installed
1022    # the varible synax differnt
1023    _g4tc_prepend_path(GEANT4_ENV_BINPATH_SETUP
1024      ${_shell}
1025      PATH
1026      "%geant4_envbindir%"
1027      )
1028 
1029    ## Set library path, based on relative paths between bindir and libdir
1030    #if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
1031    #  _g4tc_prepend_path(GEANT4_ENV_LIBPATH_SETUP
1032    #    ${_shell}
1033    #    LD_LIBRARY_PATH
1034    #    "\"`cd $geant4_envbindir/${G4ENV_BINDIR_TO_LIBDIR} > /dev/null ; pwd`\""
1035    #    )
1036    # endif()
1037 
1038    # Third party lib paths
1039    # - CLHEP, if system
1040    set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "rem # - Builtin CLHEP used")
1041    if(GEANT4_USE_SYSTEM_CLHEP)
1042       # Handle granular vs singular cases
1043             get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
1044       get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
1045       get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
1046 
1047       if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
1048         _g4tc_append_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP
1049           ${_shell}
1050           PATH
1051           "${_CLHEP_LIB_DIR}"
1052           )
1053       else()
1054         set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "rem # System CLHEP in use, no configuration required")
1055       endif()
1056     endif()
1057 
1058    # - XercesC
1059     set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "rem # GDML SUPPORT NOT AVAILABLE")
1060     if(GEANT4_USE_GDML)
1061       get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" REALPATH)
1062       get_filename_component(_XERCESC_LIB_DIR "${XercesC_LIBRARY}" DIRECTORY)
1063       if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
1064         _g4tc_append_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP
1065           ${_shell}
1066           PATH
1067           "${_XERCESC_LIB_DIR}"
1068           )
1069       else()
1070         set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "rem # GDML Supported, no configuration of Xerces-C required")
1071       endif()
1072     endif()
1073 
1074    # - Set data paths
1075     set(GEANT4_ENV_DATASETS )
1076      _g4tc_setenv_command(_dssetenvcmd ${_shell} GEANT4_DATA_DIR ${GEANT4_DATA_DIRW})
1077     set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
1078     set(_dssetenvcmd "FOR /F %%i IN ( \"%GEANT4_DATA_DIR%\" ) DO set \"GEANT4_DATA_DIR=%%~fi\"")
1079     set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n\n")
1080     set(_dssetenvcmd "
1081 rem - Variables for individual datasets
1082 rem Uncomment the line and edit the path to the dataset if installed in not standard location.")
1083   set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n\n")
1084     foreach(_ds ${GEANT4_EXPORTED_DATASETS})
1085      file(TO_NATIVE_PATH ${${_ds}_PATH} _native_path)
1086      _g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} "%GEANT4_DATA_DIR%\\${_native_path}")
1087      set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}rem ${_dssetenvcmd}\n")
1088    endforeach()
1089 
1090    # - Set Font Path
1091    # ??? We need this variable ?
1092    # ??? path to freetype2 library ???
1093    set(GEANT4_ENV_TOOLS_FONT_PATH "rem # FREETYPE SUPPORT NOT AVAILABLE")
1094    if(GEANT4_USE_FREETYPE)
1095      _g4tc_append_path(GEANT4_ENV_TOOLS_FONT_PATH
1096      ${_shell}
1097      TOOLS_FONT_PATH
1098      "${TOOLS_FONT_PATH}"
1099      )
1100    endif()
1101 
1102    configure_file(
1103      ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-bat-skeleton.in
1104      ${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
1105      @ONLY
1106       )
1107   endif()
1108 
1109   # Install it to the required location
1110   install(FILES
1111     ${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
1112     DESTINATION ${CMAKE_INSTALL_BINDIR}
1113     PERMISSIONS
1114     OWNER_READ OWNER_WRITE OWNER_EXECUTE
1115     GROUP_READ GROUP_EXECUTE
1116     WORLD_READ WORLD_EXECUTE
1117     COMPONENT Runtime
1118     )
1119 endforeach()
1120