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 # - Motif
0273 if(GEANT4_USE_XM)
0274 set(G4_BUILTWITH_MOTIF "yes")
0275 set(G4_CONFIG_NEEDS_X11 TRUE)
0276 else()
0277 set(G4_BUILTWITH_MOTIF "no")
0278 endif()
0279
0280 # - RayTracerX
0281 if(GEANT4_USE_RAYTRACER_X11)
0282 set(G4_BUILTWITH_RAYTRACERX11 "yes")
0283 set(G4_CONFIG_NEEDS_X11 TRUE)
0284 else()
0285 set(G4_BUILTWITH_RAYTRACERX11 "no")
0286 endif()
0287
0288 # - OpenGL X11
0289 if(GEANT4_USE_OPENGL_X11)
0290 set(G4_BUILTWITH_OPENGLX11 "yes")
0291 set(G4_CONFIG_NEEDS_X11 TRUE)
0292 else()
0293 set(G4_BUILTWITH_OPENGLX11 "no")
0294 endif()
0295
0296 # - OpenInventor
0297 if(GEANT4_USE_INVENTOR)
0298 set(G4_BUILTWITH_INVENTOR "yes")
0299 else()
0300 set(G4_BUILTWITH_INVENTOR "no")
0301 endif()
0302
0303 # - VTK
0304 if(GEANT4_USE_VTK)
0305 set(G4_BUILTWITH_VTK "yes")
0306 else()
0307 set(G4_BUILTWITH_VTK "no")
0308 endif()
0309
0310 # If we have a module that uses X11, We have to play with the X11
0311 # paths to get a clean set suitable for inclusion
0312 if(G4_CONFIG_NEEDS_X11)
0313 set(_raw_x11_includes ${X11_INCLUDE_DIR})
0314 list(REMOVE_DUPLICATES _raw_x11_includes)
0315 if(_cxx_compiler_dirs)
0316 list(REMOVE_ITEM _raw_x11_includes ${_cxx_compiler_dirs})
0317 endif()
0318 set(G4_X11_CFLAGS )
0319 foreach(_p ${_raw_x11_includes})
0320 set(G4_X11_CFLAGS "-I${_p} ${G4_X11_CFLAGS}")
0321 endforeach()
0322 endif()
0323
0324 # Configure the script
0325 # - BUILD TREE
0326 # Ouch, the include path will be LONG, but at least we always have
0327 # absolute paths...
0328 set(GEANT4_CONFIG_SELF_LOCATION "# BUILD TREE IS NON-RELOCATABLE")
0329 set(GEANT4_CONFIG_INSTALL_PREFIX "${PROJECT_BINARY_DIR}")
0330 set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
0331 # NB: this only works for *single* mode generators. With multimode
0332 # generators, which mode to use is not clear...
0333 set(GEANT4_CONFIG_LIBDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
0334
0335 get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
0336 GEANT4_BUILDTREE_INCLUDE_DIRS)
0337
0338 foreach(_dir ${__geant4_buildtree_include_dirs})
0339 set(GEANT4_CONFIG_INCLUDE_DIRS "${GEANT4_CONFIG_INCLUDE_DIRS} \\
0340 ${_dir}")
0341 endforeach()
0342
0343 # - Data
0344 geant4_export_datasets(BUILD GEANT4_CONFIG_DATASET_DESCRIPTIONS)
0345
0346 # Configure the build tree script
0347 configure_file(
0348 ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-config.in
0349 ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
0350 @ONLY
0351 )
0352
0353 file(COPY
0354 ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
0355 DESTINATION ${PROJECT_BINARY_DIR}
0356 FILE_PERMISSIONS
0357 OWNER_READ OWNER_WRITE OWNER_EXECUTE
0358 GROUP_READ GROUP_EXECUTE
0359 WORLD_READ WORLD_EXECUTE
0360 )
0361
0362 # - Install Tree
0363 # Much easier :-)
0364 # Non-Relocatable case...
0365 if(CMAKE_INSTALL_IS_NONRELOCATABLE)
0366 # Hardcoded paths
0367 set(GEANT4_CONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
0368 set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
0369 set(GEANT4_CONFIG_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
0370 set(GEANT4_CONFIG_INCLUDE_DIRS "${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4")
0371 else()
0372 # Calculate base of self contained install based on relative path from
0373 # CMAKE_INSTALL_FULL_BINDIR to CMAKE_INSTALL_PREFIX.
0374 file(RELATIVE_PATH _bin_to_prefix ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_PREFIX})
0375 # Strip any trailing path separators just for neatness.
0376 string(REGEX REPLACE "[/\\]$" "" _bin_to_prefix "${_bin_to_prefix}")
0377
0378 set(GEANT4_CONFIG_INSTALL_PREFIX "$scriptloc/${_bin_to_prefix}")
0379 set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
0380 set(GEANT4_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
0381 set(GEANT4_CONFIG_INCLUDE_DIRS "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/Geant4")
0382 endif()
0383
0384 # - Data
0385 geant4_export_datasets(INSTALL GEANT4_CONFIG_DATASET_DESCRIPTIONS)
0386
0387 # Configure the install tree script
0388 configure_file(
0389 ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-config.in
0390 ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
0391 @ONLY
0392 )
0393
0394 # Install it
0395 install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
0396 DESTINATION ${CMAKE_INSTALL_BINDIR}
0397 PERMISSIONS
0398 OWNER_READ OWNER_WRITE OWNER_EXECUTE
0399 GROUP_READ GROUP_EXECUTE
0400 WORLD_READ WORLD_EXECUTE
0401 COMPONENT Development
0402 )
0403
0404 # Win32 helper file geant4-config.cmd
0405 if(WIN32)
0406 # No configuration just a copy
0407 configure_file(
0408 ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-config-cmd.in
0409 ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config.cmd
0410 @ONLY
0411 )
0412
0413 # Install helper
0414 install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config.cmd
0415 DESTINATION ${CMAKE_INSTALL_BINDIR}
0416 PERMISSIONS
0417 OWNER_READ OWNER_WRITE OWNER_EXECUTE
0418 GROUP_READ GROUP_EXECUTE
0419 WORLD_READ WORLD_EXECUTE
0420 COMPONENT Development
0421 )
0422 endif()
0423 endif()