Warning, /geant4/cmake/Modules/G4ConfigureCMakeHelpers.cmake is written in an unsupported language. File is not indexed.
0001 #.rst:
0002 # G4ConfigureCMakeHelpers
0003 # -----------------------
0004 #
0005 # This module configures and installs CMake modules allowing clients
0006 # to find and use Geant4 libraries using CMake's find_package command.
0007 #
0008
0009 #-----------------------------------------------------------------
0010 # License and Disclaimer
0011 #
0012 # The Geant4 software is copyright of the Copyright Holders of
0013 # the Geant4 Collaboration. It is provided under the terms and
0014 # conditions of the Geant4 Software License, included in the file
0015 # LICENSE and available at http://cern.ch/geant4/license . These
0016 # include a list of copyright holders.
0017 #
0018 # Neither the authors of this software system, nor their employing
0019 # institutes,nor the agencies providing financial support for this
0020 # work make any representation or warranty, express or implied,
0021 # regarding this software system or assume any liability for its
0022 # use. Please see the license in the file LICENSE and URL above
0023 # for the full disclaimer and the limitation of liability.
0024 #
0025 # This code implementation is the result of the scientific and
0026 # technical work of the GEANT4 collaboration.
0027 # By using, copying, modifying or distributing the software (or
0028 # any work based on the software) you agree to acknowledge its
0029 # use in resulting scientific publications, and indicate your
0030 # acceptance of all terms of the Geant4 Software license.
0031 #
0032 #-----------------------------------------------------------------
0033
0034 #-----------------------------------------------------------------------
0035 # Collect all global variables we need to export to the config files
0036 # Do this here for now, later on we could collect them as we go.
0037 #
0038
0039 # Compiler flags (because user apps are a bit dependent on them...)
0040 set(GEANT4_COMPILER_FLAG_HINTS "#
0041 set(Geant4_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${GEANT4_CXXSTD_FLAGS}\")
0042 set(Geant4_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\")")
0043
0044 foreach(_mode DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
0045 set(GEANT4_COMPILER_FLAG_HINTS "${GEANT4_COMPILER_FLAG_HINTS}
0046 set(Geant4_CXX_FLAGS_${_mode} \"${CMAKE_CXX_FLAGS_${_mode}}\")")
0047 endforeach()
0048
0049 if(NOT CMAKE_CONFIGURATION_TYPES)
0050 set(GEANT4_COMPILER_FLAG_HINTS "${GEANT4_COMPILER_FLAG_HINTS}
0051 set(Geant4_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")")
0052 endif()
0053
0054 # Third party includes (libraries *should* be handled by the imports)
0055 set(GEANT4_THIRD_PARTY_INCLUDES )
0056
0057 # Imports of third party packages used with imported targets
0058 set(GEANT4_THIRD_PARTY_IMPORT_SETUP )
0059
0060 # Externals libraries that may be present
0061 set(GEANT4_EXTERNALS_TARGETS )
0062
0063 # - Stuff from G4OptionalComponents.cmake
0064 # - CLHEP
0065 # If it's internal, add it to the externals list
0066 if(NOT GEANT4_USE_SYSTEM_CLHEP)
0067 list(APPEND GEANT4_EXTERNALS_TARGETS G4clhep)
0068 endif()
0069
0070 # - Expat
0071 # If it's internal, add it to the externals list
0072 if(NOT GEANT4_USE_SYSTEM_EXPAT)
0073 list(APPEND GEANT4_EXTERNALS_TARGETS G4expat)
0074 endif()
0075
0076 # - ZLIB
0077 # If it's internal, add it to the externals list
0078 if(NOT GEANT4_USE_SYSTEM_ZLIB)
0079 list(APPEND GEANT4_EXTERNALS_TARGETS G4zlib)
0080 endif()
0081
0082 # - PTL
0083 # If it's internal, add it to the externals list
0084 if(NOT GEANT4_USE_SYSTEM_PTL)
0085 list(APPEND GEANT4_EXTERNALS_TARGETS G4ptl)
0086 set(PTL_BUILDTREE_PREFIX "${PROJECT_BINARY_DIR}/source/externals/ptl")
0087 set(PTL_INSTALLTREE_PREFIX "\${_geant4_thisdir}/PTL")
0088 endif()
0089
0090 # - USolids
0091 # Compile definitions
0092 if(GEANT4_USE_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
0093 set(GEANT4_USE_USOLIDS_EITHER ON)
0094 endif()
0095
0096
0097 #-----------------------------------------------------------------------
0098 # - Common Build/Install Tree Configuration files
0099 #-----------------------------------------------------------------------
0100 # External package variables
0101 geant4_export_package_variables(${PROJECT_BINARY_DIR}/Geant4PackageCache.cmake)
0102
0103 # Versioning file
0104 configure_file(
0105 ${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4ConfigVersion.cmake.in
0106 ${PROJECT_BINARY_DIR}/Geant4ConfigVersion.cmake
0107 @ONLY
0108 )
0109
0110 #-----------------------------------------------------------------------
0111 # - Generate Build Tree Configuration Files
0112 #-----------------------------------------------------------------------
0113 # Set needed variables for the build tree
0114 set(GEANT4_CMAKE_DIR "${PROJECT_BINARY_DIR}")
0115
0116 # Set include path for build tree. This is always an absolute path, or
0117 # rather paths. We extract the paths from the global
0118 # GEANT4_BUILDTREE_INCLUDE_DIRS property and use this to create the
0119 # header setup
0120 # This is *ONLY* required in case clients use ROOT dictionaries, whose
0121 # generation mechanism is blind to usage requirements
0122 #
0123 get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
0124 GEANT4_BUILDTREE_INCLUDE_DIRS
0125 )
0126
0127 set(GEANT4_INCLUDE_DIR_SETUP "
0128 # Geant4 configured for use from the build tree - absolute paths are used.
0129 set(Geant4_INCLUDE_DIR \"${__geant4_buildtree_include_dirs}\")
0130 ")
0131 # Builtin PTL is self located
0132 set(PACKAGE_PTL_PREFIX "${PTL_BUILDTREE_PREFIX}")
0133 # Geant4 data used in build tree
0134 geant4_export_datasets(BUILD GEANT4_DATASET_DESCRIPTIONS)
0135
0136 # Export targets in the Geant4LibraryDepends export set from the build tree
0137 export(EXPORT Geant4LibraryDepends
0138 NAMESPACE Geant4::
0139 FILE ${PROJECT_BINARY_DIR}/Geant4LibraryDepends.cmake
0140 )
0141
0142 # Configure the build tree config file...
0143 configure_file(
0144 ${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4Config.cmake.in
0145 ${PROJECT_BINARY_DIR}/Geant4Config.cmake
0146 @ONLY
0147 )
0148
0149 # Copy the custom modules into the build tree
0150 configure_file(
0151 ${PROJECT_SOURCE_DIR}/cmake/Modules/IntelCompileFeatures.cmake
0152 ${PROJECT_BINARY_DIR}/Modules/IntelCompileFeatures.cmake
0153 COPYONLY
0154 )
0155
0156 configure_file(
0157 ${PROJECT_SOURCE_DIR}/cmake/Modules/MSVCCompileFeatures.cmake
0158 ${PROJECT_BINARY_DIR}/Modules/MSVCCompileFeatures.cmake
0159 COPYONLY
0160 )
0161
0162 configure_file(
0163 ${PROJECT_SOURCE_DIR}/cmake/Modules/G4EXPATShim.cmake
0164 ${PROJECT_BINARY_DIR}/G4EXPATShim.cmake
0165 COPYONLY
0166 )
0167
0168 # Required for CMake clients between 3.8 and 3.10
0169 configure_file(
0170 ${PROJECT_SOURCE_DIR}/cmake/Modules/G4FreetypeShim.cmake
0171 ${PROJECT_BINARY_DIR}/G4FreetypeShim.cmake
0172 COPYONLY
0173 )
0174
0175 configure_file(
0176 ${PROJECT_SOURCE_DIR}/cmake/Modules/G4HDF5Shim.cmake
0177 ${PROJECT_BINARY_DIR}/G4HDF5Shim.cmake
0178 COPYONLY
0179 )
0180
0181 configure_file(
0182 ${PROJECT_SOURCE_DIR}/cmake/Modules/G4MotifShim.cmake
0183 ${PROJECT_BINARY_DIR}/G4MotifShim.cmake
0184 COPYONLY
0185 )
0186
0187 configure_file(
0188 ${PROJECT_SOURCE_DIR}/cmake/Modules/G4X11Shim.cmake
0189 ${PROJECT_BINARY_DIR}/G4X11Shim.cmake
0190 COPYONLY
0191 )
0192
0193
0194 foreach(_mod FLUKAInterface HepMC Pythia6 Pythia8 StatTest TBB XQuartzGL)
0195 configure_file(
0196 ${PROJECT_SOURCE_DIR}/cmake/Modules/Find${_mod}.cmake
0197 ${PROJECT_BINARY_DIR}/Modules/Find${_mod}.cmake
0198 COPYONLY
0199 )
0200 endforeach()
0201
0202 # Copy the Main and Internal Use file into the build tree
0203 configure_file(
0204 ${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4.cmake
0205 ${PROJECT_BINARY_DIR}/UseGeant4.cmake
0206 COPYONLY
0207 )
0208
0209 configure_file(
0210 ${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4_internal.cmake
0211 ${PROJECT_BINARY_DIR}/UseGeant4_internal.cmake
0212 COPYONLY
0213 )
0214
0215 #-----------------------------------------------------------------------
0216 # - Generate Install Tree Configuration Files
0217 #-----------------------------------------------------------------------
0218 # Set needed variables for the install tree
0219 set(GEANT4_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
0220
0221 # Header path for install tree is dependent on whether we have a relocatable
0222 # install.
0223 if(CMAKE_INSTALL_IS_NONRELOCATABLE)
0224 # Use ABSOLUTE paths...
0225 set(GEANT4_INCLUDE_DIR_SETUP "
0226 # Geant4 configured for the install tree with absolute paths, so use these
0227 set(Geant4_INCLUDE_DIR \"${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4\")
0228 ")
0229 else()
0230 # Use RELATIVE paths... Where we measure relative to GEANT4_CMAKE_DIR
0231 file(RELATIVE_PATH GEANT4_RELATIVE_HEADER_PATH
0232 ${CMAKE_INSTALL_PREFIX}/${GEANT4_CMAKE_DIR}
0233 ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
0234 )
0235
0236 set(GEANT4_INCLUDE_DIR_SETUP "
0237 # Geant4 configured for the install with relative paths, so use these
0238 get_filename_component(Geant4_INCLUDE_DIR \"\${_geant4_thisdir}/${GEANT4_RELATIVE_HEADER_PATH}\" ABSOLUTE)
0239 ")
0240 endif()
0241 # Builtin PTL is self located
0242 set(PACKAGE_PTL_PREFIX "${PTL_INSTALLTREE_PREFIX}")
0243 # Geant4 data used in install tree
0244 geant4_export_datasets(INSTALL GEANT4_DATASET_DESCRIPTIONS)
0245
0246 # Install exported targets file for the install tree - we just install
0247 # the named export
0248 install(EXPORT Geant4LibraryDepends
0249 NAMESPACE Geant4::
0250 DESTINATION ${GEANT4_CMAKE_DIR}
0251 COMPONENT Development
0252 )
0253
0254 # Configure the install tree config file...
0255 configure_file(
0256 ${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4Config.cmake.in
0257 ${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4Config.cmake
0258 @ONLY
0259 )
0260
0261 # Install the config, config versioning and use files
0262 install(FILES
0263 ${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4Config.cmake
0264 ${PROJECT_BINARY_DIR}/Geant4ConfigVersion.cmake
0265 ${PROJECT_BINARY_DIR}/G4EXPATShim.cmake
0266 ${PROJECT_BINARY_DIR}/G4FreetypeShim.cmake
0267 ${PROJECT_BINARY_DIR}/G4HDF5Shim.cmake
0268 ${PROJECT_BINARY_DIR}/G4MotifShim.cmake
0269 ${PROJECT_BINARY_DIR}/G4X11Shim.cmake
0270 ${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4.cmake
0271 DESTINATION ${GEANT4_CMAKE_DIR}
0272 COMPONENT Development
0273 )
0274
0275 # Install the package settings file if required (always for now)
0276 option(GEANT4_INSTALL_PACKAGE_CACHE "Install file recording build-time locations of required packages" ON)
0277 mark_as_advanced(GEANT4_INSTALL_PACKAGE_CACHE)
0278 if(GEANT4_INSTALL_PACKAGE_CACHE)
0279 install(FILES ${PROJECT_BINARY_DIR}/Geant4PackageCache.cmake
0280 DESTINATION ${GEANT4_CMAKE_DIR}
0281 COMPONENT Development
0282 )
0283 endif()
0284
0285 # Install the custom modules for dependencies/examples
0286 install(DIRECTORY
0287 ${PROJECT_BINARY_DIR}/Modules
0288 DESTINATION ${GEANT4_CMAKE_DIR}
0289 COMPONENT Development
0290 )
0291