#.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: # # /lib/G4SYSTEM-G4COMPILER # # is provided by installing a directory 'geant4-' in the # /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() # 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(