Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #.rst:
0002 # G4ConfigurePkgConfigHelpers
0003 # ---------------------------
0004 #
0005 # This module configures and installs pkg-config scripts and the
0006 # geant4-config program to help clients compile and link against
0007 # the Geant4 libraries.
0008 #
0009 # The geant4-config script provides an sh based interface to provide
0010 # information on the Geant4 installation, including installation prefix,
0011 # version number, compiler and linker flags.
0012 #
0013 # The script is generated from a template file and then installed to the
0014 # known bindir as an executable.
0015 #
0016 # Paths are always hardcoded in the build tree version as this is never
0017 # intended to be relocatable.
0018 # The Install Tree script uses self-location based on that in
0019 # {root,clhep}-config is the install itself is relocatable, otherwise
0020 # absolute paths are encoded.
0021 #
0022 #
0023 
0024 #-----------------------------------------------------------------
0025 # License and Disclaimer
0026 #
0027 # The  Geant4 software  is  copyright of the Copyright Holders  of
0028 # the Geant4 Collaboration.  It is provided  under  the terms  and
0029 # conditions of the Geant4 Software License,  included in the file
0030 # LICENSE and available at  http://cern.ch/geant4/license .  These
0031 # include a list of copyright holders.
0032 #
0033 # Neither the authors of this software system, nor their employing
0034 # institutes,nor the agencies providing financial support for this
0035 # work  make  any representation or  warranty, express or implied,
0036 # regarding  this  software system or assume any liability for its
0037 # use.  Please see the license in the file  LICENSE  and URL above
0038 # for the full disclaimer and the limitation of liability.
0039 #
0040 # This  code  implementation is the result of  the  scientific and
0041 # technical work of the GEANT4 collaboration.
0042 # By using,  copying,  modifying or  distributing the software (or
0043 # any work based  on the software)  you  agree  to acknowledge its
0044 # use  in  resulting  scientific  publications,  and indicate your
0045 # acceptance of all terms of the Geant4 Software license.
0046 #
0047 #-----------------------------------------------------------------
0048 
0049 
0050 #-----------------------------------------------------------------------
0051 # function get_system_include_dirs
0052 #          return list of directories our C++ compiler searches
0053 #          by default.
0054 #
0055 #          The idea comes from CMake's inbuilt technique to do this
0056 #          for the Eclipse and CodeBlocks generators, but we implement
0057 #          our own function because the CMake functionality is internal
0058 #          so we can't rely on it.
0059 function(get_system_include_dirs _dirs)
0060   # Only for GCC, Clang and Intel
0061   if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel)
0062     # Proceed
0063     file(WRITE "${PROJECT_BINARY_DIR}/CMakeFiles/g4dummy" "\n")
0064 
0065     # Save locale, them to "C" english locale so we can parse in English
0066     set(_orig_lc_all      $ENV{LC_ALL})
0067     set(_orig_lc_messages $ENV{LC_MESSAGES})
0068     set(_orig_lang        $ENV{LANG})
0069 
0070     set(ENV{LC_ALL}      C)
0071     set(ENV{LC_MESSAGES} C)
0072     set(ENV{LANG}        C)
0073 
0074     execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v -E -x c++ -dD g4dummy
0075       WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/CMakeFiles
0076       ERROR_VARIABLE _cxxOutput
0077       OUTPUT_VARIABLE _cxxStdout
0078       )
0079 
0080     file(REMOVE "${PROJECT_BINARY_DIR}/CMakeFiles/g4dummy")
0081 
0082     # Parse and extract search dirs
0083     set(_resultIncludeDirs )
0084     if( "${_cxxOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" )
0085       string(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}")
0086       foreach(nextLine ${_includeLines})
0087         string(REGEX REPLACE "\\(framework directory\\)" "" nextLineNoFramework "${nextLine}")
0088         string(STRIP "${nextLineNoFramework}" _includePath)
0089         list(APPEND _resultIncludeDirs "${_includePath}")
0090       endforeach()
0091     endif()
0092 
0093     # Restore original locale
0094     set(ENV{LC_ALL}      ${_orig_lc_all})
0095     set(ENV{LC_MESSAGES} ${_orig_lc_messages})
0096     set(ENV{LANG}        ${_orig_lang})
0097 
0098     set(${_dirs} ${_resultIncludeDirs} PARENT_SCOPE)
0099   else()
0100     set(${_dirs} "" PARENT_SCOPE)
0101   endif()
0102 endfunction()
0103 
0104 #-----------------------------------------------------------------------
0105 # Only create script if we have a global library build...
0106 #
0107 #if(NOT GEANT4_BUILD_GRANULAR_LIBS AND UNIX)
0108 if(NOT GEANT4_BUILD_GRANULAR_LIBS)
0109   # Get implicit search paths
0110   get_system_include_dirs(_cxx_compiler_dirs)
0111 
0112   # Setup variables needed for expansion in configuration file
0113   # - C++ Filesystem, if needed
0114   if(GEANT4_CXX_FILESYSTEM_LIBRARY)
0115     set(G4_LINK_CXX_FILESYSTEM "-l${GEANT4_CXX_FILESYSTEM_LIBRARY}")
0116   endif()
0117 
0118   # - Static libs
0119   if(BUILD_STATIC_LIBS)
0120     set(G4_BUILTWITH_STATICLIBS "yes")
0121   else()
0122     set(G4_BUILTWITH_STATICLIBS "no")
0123   endif()
0124 
0125   # - Multithreading
0126   if(GEANT4_BUILD_MULTITHREADED)
0127     set(G4_BUILTWITH_MULTITHREADING "yes")
0128   else()
0129     set(G4_BUILTWITH_MULTITHREADING "no")
0130   endif()
0131 
0132   # - PHP_AS_HP
0133   if(GEANT4_BUILD_PHP_AS_HP)
0134     set(G4_BUILTWITH_PHP_AS_HP "yes")
0135   else()
0136     set(G4_BUILTWITH_PHP_AS_HP "no")
0137   endif()
0138 
0139   # - Smart Stack
0140   if(GEANT4_USE_SMARTSTACK)
0141     set(G4_BUILTWITH_SMARTSTACK "yes")
0142   else()
0143     set(G4_BUILTWITH_SMARTSTACK "no")
0144   endif()
0145 
0146   # - CLHEP
0147   if(GEANT4_USE_SYSTEM_CLHEP)
0148     set(G4_BUILTWITH_CLHEP "no")
0149     #inc path
0150     get_filename_component(G4_SYSTEM_CLHEP_INCLUDE_DIR "${CLHEP_INCLUDE_DIR}" ABSOLUTE)
0151 
0152     #libpath
0153     list(GET CLHEP_LIBRARIES 0 _zeroth_clhep_lib)
0154     get_target_property(_system_clhep_libdir "${_zeroth_clhep_lib}" LOCATION)
0155     get_filename_component(_system_clhep_libdir "${_system_clhep_libdir}" REALPATH)
0156     get_filename_component(_system_clhep_libdir "${_system_clhep_libdir}" DIRECTORY)
0157     set(G4_SYSTEM_CLHEP_LIBRARIES "-L${_system_clhep_libdir}")
0158 
0159     foreach(_clhep_lib ${CLHEP_LIBRARIES})
0160       get_target_property(_curlib "${_clhep_lib}" LOCATION)
0161       get_filename_component(_curlib "${_curlib}" NAME)
0162       string(REGEX REPLACE "^lib(.*)\\.(so|a|dylib|lib|dll)$" "\\1" _curlib "${_curlib}")
0163       set(G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES} -l${_curlib}")
0164     endforeach()
0165   else()
0166     set(G4_BUILTWITH_CLHEP "yes")
0167   endif()
0168 
0169   # - EXPAT
0170   if(GEANT4_USE_SYSTEM_EXPAT)
0171     set(G4_BUILTWITH_EXPAT "no")
0172   else()
0173     set(G4_BUILTWITH_EXPAT "yes")
0174   endif()
0175 
0176   # - ZLIB
0177   if(GEANT4_USE_SYSTEM_ZLIB)
0178     set(G4_BUILTWITH_ZLIB "no")
0179   else()
0180     set(G4_BUILTWITH_ZLIB "yes")
0181   endif()
0182 
0183   # - PTL
0184   if(GEANT4_USE_SYSTEM_PTL)
0185     set(G4_BUILTWITH_PTL "no")
0186   else()
0187     set(G4_BUILTWITH_PTL "yes")
0188   endif()
0189 
0190   # - GDML
0191   if(GEANT4_USE_GDML)
0192     set(G4_BUILTWITH_GDML "yes")
0193     set(G4_XERCESC_INCLUDE_DIRS ${XercesC_INCLUDE_DIR})
0194     list(REMOVE_DUPLICATES G4_XERCESC_INCLUDE_DIRS)
0195     if(_cxx_compiler_dirs)
0196       list(REMOVE_ITEM G4_XERCESC_INCLUDE_DIRS ${_cxx_compiler_dirs})
0197     endif()
0198 
0199     set(G4_XERCESC_CFLAGS )
0200     foreach(_dir ${G4_XERCESC_INCLUDE_DIRS})
0201       set(G4_XERCESC_CFLAGS "${G4_XERCESC_CFLAGS} -I${_dir}")
0202     endforeach()
0203   else()
0204     set(G4_BUILTWITH_GDML "no")
0205   endif()
0206 
0207   # - G3ToG4
0208   if(GEANT4_USE_G3TOG4)
0209     set(G4_BUILTWITH_G3TOG4 "yes")
0210   else()
0211     set(G4_BUILTWITH_G3TOG4 "no")
0212   endif()
0213 
0214   # - USolids
0215   if(GEANT4_USE_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
0216     set(G4_BUILTWITH_USOLIDS "yes")
0217     get_target_property(G4_USOLIDS_INCLUDE_DIRS VecGeom::vecgeom INTERFACE_INCLUDE_DIRECTORIES)
0218     list(REMOVE_DUPLICATES G4_USOLIDS_INCLUDE_DIRS)
0219     foreach(_dir ${G4_USOLIDS_INCLUDE_DIRS})
0220       set(G4_USOLIDS_CFLAGS "${G4_USOLIDS_CFLAGS} -I${_dir}")
0221     endforeach()
0222     # NB: should ALSO account for VecGeom having compile_options, but
0223     # this is better handled through proper pkg-config support
0224   else()
0225     set(G4_BUILTWITH_USOLIDS "no")
0226   endif()
0227 
0228   # - Freetype
0229   if(GEANT4_USE_FREETYPE)
0230     set(G4_BUILTWITH_FREETYPE "yes")
0231   else()
0232     set(G4_BUILTWITH_FREETYPE "no")
0233   endif()
0234 
0235   # - HDF5
0236   if(GEANT4_USE_HDF5)
0237     set(G4_BUILTWITH_HDF5 "yes")
0238   else()
0239     set(G4_BUILTWITH_HDF5 "no")
0240   endif()
0241 
0242   # - Qt
0243   if(GEANT4_USE_QT)
0244     set(G4_BUILTWITH_QT "yes")
0245     set(_qtcomps Core Gui Widgets OpenGL)
0246     if(QT_VERSION_MAJOR VERSION_GREATER_EQUAL 5.15)
0247       list(APPEND _qtcomp 3DCore 3DExtras 3DRender)
0248     endif()
0249 
0250     set(G4_QT_INCLUDE_DIRS )
0251     foreach(_qtc ${_qtcomps})
0252       list(APPEND G4_QT_INCLUDE_DIRS ${Qt${QT_VERSION_MAJOR}${_qtc}_INCLUDE_DIRS})
0253     endforeach()
0254 
0255     list(REMOVE_DUPLICATES G4_QT_INCLUDE_DIRS)
0256     if(_cxx_compiler_dirs)
0257       list(REMOVE_ITEM G4_QT_INCLUDE_DIRS ${_cxx_compiler_dirs})
0258     endif()
0259 
0260     set(G4_QT_CFLAGS )
0261     foreach(_dir ${G4_QT_INCLUDE_DIRS})
0262       set(G4_QT_CFLAGS "${G4_QT_CFLAGS} -I${_dir}")
0263     endforeach()
0264 
0265     if(APPLE AND G4_QT_CFLAGS MATCHES "QtCore\.framework")
0266       set(G4_QT_CFLAGS "${G4_QT_CFLAGS} -F${G4QTLIBPATH}")
0267     endif()
0268   else()
0269     set(G4_BUILTWITH_QT "no")
0270   endif()
0271 
0272   # - QT3D
0273   if(GEANT4_USE_QT3D)
0274     set(G4_BUILTWITH_QT3D "yes")
0275   else()
0276     set(G4_BUILTWITH_QT3D "no")
0277   endif()
0278 
0279   # - Motif
0280   if(GEANT4_USE_XM)
0281     set(G4_BUILTWITH_MOTIF "yes")
0282     set(G4_CONFIG_NEEDS_X11 TRUE)
0283   else()
0284     set(G4_BUILTWITH_MOTIF "no")
0285   endif()
0286 
0287   # - RayTracerX
0288   if(GEANT4_USE_RAYTRACER_X11)
0289     set(G4_BUILTWITH_RAYTRACERX11 "yes")
0290     set(G4_CONFIG_NEEDS_X11 TRUE)
0291   else()
0292     set(G4_BUILTWITH_RAYTRACERX11 "no")
0293   endif()
0294 
0295   # - OpenGL X11
0296   if(GEANT4_USE_OPENGL_X11)
0297     set(G4_BUILTWITH_OPENGLX11 "yes")
0298     set(G4_CONFIG_NEEDS_X11 TRUE)
0299   else()
0300     set(G4_BUILTWITH_OPENGLX11 "no")
0301   endif()
0302 
0303   # - OpenInventor
0304   if(GEANT4_USE_INVENTOR)
0305     set(G4_BUILTWITH_INVENTOR "yes")
0306   else()
0307     set(G4_BUILTWITH_INVENTOR "no")
0308   endif()
0309 
0310   # - VTK
0311   if(GEANT4_USE_VTK)
0312     set(G4_BUILTWITH_VTK "yes")
0313   else()
0314     set(G4_BUILTWITH_VTK "no")
0315   endif()
0316 
0317   # If we have a module that uses X11, We have to play with the X11
0318   # paths to get a clean set suitable for inclusion
0319   if(G4_CONFIG_NEEDS_X11)
0320     set(_raw_x11_includes ${X11_INCLUDE_DIR})
0321     list(REMOVE_DUPLICATES _raw_x11_includes)
0322     if(_cxx_compiler_dirs)
0323       list(REMOVE_ITEM _raw_x11_includes ${_cxx_compiler_dirs})
0324     endif()
0325     set(G4_X11_CFLAGS )
0326     foreach(_p ${_raw_x11_includes})
0327       set(G4_X11_CFLAGS "-I${_p} ${G4_X11_CFLAGS}")
0328     endforeach()
0329   endif()
0330 
0331   # Configure the script
0332   # - BUILD TREE
0333   # Ouch, the include path will be LONG, but at least we always have
0334   # absolute paths...
0335   set(GEANT4_CONFIG_SELF_LOCATION "# BUILD TREE IS NON-RELOCATABLE")
0336   set(GEANT4_CONFIG_INSTALL_PREFIX "${PROJECT_BINARY_DIR}")
0337   set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
0338   # NB: this only works for *single* mode generators. With multimode
0339   # generators, which mode to use is not clear...
0340   set(GEANT4_CONFIG_LIBDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
0341 
0342   get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
0343     GEANT4_BUILDTREE_INCLUDE_DIRS)
0344 
0345   foreach(_dir ${__geant4_buildtree_include_dirs})
0346     set(GEANT4_CONFIG_INCLUDE_DIRS "${GEANT4_CONFIG_INCLUDE_DIRS} \\
0347     ${_dir}")
0348   endforeach()
0349 
0350   # - Data
0351   geant4_export_datasets(BUILD GEANT4_CONFIG_DATASET_DESCRIPTIONS)
0352 
0353   # Configure the build tree script
0354   configure_file(
0355     ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-config.in
0356     ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
0357     @ONLY
0358     )
0359 
0360   file(COPY
0361     ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
0362     DESTINATION ${PROJECT_BINARY_DIR}
0363     FILE_PERMISSIONS
0364       OWNER_READ OWNER_WRITE OWNER_EXECUTE
0365       GROUP_READ GROUP_EXECUTE
0366       WORLD_READ WORLD_EXECUTE
0367     )
0368 
0369   # - Install Tree
0370   # Much easier :-)
0371   # Non-Relocatable case...
0372   if(CMAKE_INSTALL_IS_NONRELOCATABLE)
0373     # Hardcoded paths
0374     set(GEANT4_CONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
0375     set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
0376     set(GEANT4_CONFIG_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
0377     set(GEANT4_CONFIG_INCLUDE_DIRS "${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4")
0378   else()
0379     # Calculate base of self contained install based on relative path from
0380     # CMAKE_INSTALL_FULL_BINDIR to CMAKE_INSTALL_PREFIX.
0381     file(RELATIVE_PATH _bin_to_prefix ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_PREFIX})
0382     # Strip any trailing path separators just for neatness.
0383     string(REGEX REPLACE "[/\\]$" "" _bin_to_prefix "${_bin_to_prefix}")
0384 
0385     set(GEANT4_CONFIG_INSTALL_PREFIX "$scriptloc/${_bin_to_prefix}")
0386     set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
0387     set(GEANT4_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
0388     set(GEANT4_CONFIG_INCLUDE_DIRS "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/Geant4")
0389   endif()
0390 
0391   # - Data
0392   geant4_export_datasets(INSTALL GEANT4_CONFIG_DATASET_DESCRIPTIONS)
0393 
0394   # Configure the install tree script
0395   configure_file(
0396     ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-config.in
0397     ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
0398     @ONLY
0399     )
0400 
0401   # Install it
0402   install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
0403     DESTINATION ${CMAKE_INSTALL_BINDIR}
0404     PERMISSIONS
0405       OWNER_READ OWNER_WRITE OWNER_EXECUTE
0406       GROUP_READ GROUP_EXECUTE
0407       WORLD_READ WORLD_EXECUTE
0408     COMPONENT Development
0409     )
0410 
0411   # Win32 helper file geant4-config.cmd
0412   if(WIN32)
0413     # No configuration just a copy
0414     configure_file(
0415       ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-config-cmd.in
0416       ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config.cmd
0417       @ONLY
0418       )
0419 
0420     # Install helper
0421     install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config.cmd
0422       DESTINATION ${CMAKE_INSTALL_BINDIR}
0423       PERMISSIONS
0424         OWNER_READ OWNER_WRITE OWNER_EXECUTE
0425         GROUP_READ GROUP_EXECUTE
0426         WORLD_READ WORLD_EXECUTE
0427       COMPONENT Development
0428       )
0429 endif()
0430 endif()