Warning, /geant4/cmake/Modules/G4CMakeSettings.cmake is written in an unsupported language. File is not indexed.
0001 #.rst:
0002 # G4CMakeSettings.cmake
0003 # ---------------------
0004 #
0005 # Set defaults for core CMake behaviour useful or required for building,
0006 # testing and installing Geant4.
0007
0008 #-----------------------------------------------------------------
0009 # License and Disclaimer
0010 #
0011 # The Geant4 software is copyright of the Copyright Holders of
0012 # the Geant4 Collaboration. It is provided under the terms and
0013 # conditions of the Geant4 Software License, included in the file
0014 # LICENSE and available at http://cern.ch/geant4/license . These
0015 # include a list of copyright holders.
0016 #
0017 # Neither the authors of this software system, nor their employing
0018 # institutes,nor the agencies providing financial support for this
0019 # work make any representation or warranty, express or implied,
0020 # regarding this software system or assume any liability for its
0021 # use. Please see the license in the file LICENSE and URL above
0022 # for the full disclaimer and the limitation of liability.
0023 #
0024 # This code implementation is the result of the scientific and
0025 # technical work of the GEANT4 collaboration.
0026 # By using, copying, modifying or distributing the software (or
0027 # any work based on the software) you agree to acknowledge its
0028 # use in resulting scientific publications, and indicate your
0029 # acceptance of all terms of the Geant4 Software license.
0030 #
0031 #-----------------------------------------------------------------
0032
0033 if(NOT __G4CMAKESETTINGS_INCLUDED)
0034 set(__G4CMAKESETTINGS_INCLUDED TRUE)
0035 else()
0036 return()
0037 endif()
0038
0039 #-----------------------------------------------------------------------
0040 #.rst:
0041 # General Configuration Settings
0042 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0043 #
0044 # The following CMake modules and variables are used to control configuration time
0045 # behaviour such as location of dependencies.
0046 #
0047
0048 #.rst:
0049 # - ``G4CMakeUtilities`
0050 #
0051 # - Included to provide additional macros and functions
0052 #
0053 include(G4CMakeUtilities)
0054
0055 #
0056 # - ``CMAKE_EXPORT_NO_PACKAGE_REGISTRY`` : ON
0057 # - ``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` : ON
0058 # - ``CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`` : ON
0059 #
0060 # - These variables are set to ensure that CMake never creates or searches
0061 # for config files in any package registry. This prevents the
0062 # :cmake:command:`find_package <cmake:command:find_package>`
0063 # command from locating potentially spurious config files.
0064 #
0065 set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
0066 set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON)
0067 set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON)
0068
0069 #-----------------------------------------------------------------------
0070 #.rst:
0071 # General Build Settings
0072 # ^^^^^^^^^^^^^^^^^^^^^^
0073 #
0074 # The following CMake variables and options are configured by default
0075 # when including this module:
0076 #
0077 # - ``CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE`` : ON
0078 #
0079 # - Force project directories to appear first in any list of include paths.
0080 # This applies to both full paths and those created by generator expressions.
0081 #
0082 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
0083
0084 #.rst:
0085 # - ``CMAKE_LINK_DEPENDS_NO_SHARED`` : ON
0086 #
0087 # - Do not relink a target to any shared library dependencies when
0088 # only the shared library implementation has changed.
0089 #
0090 set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
0091
0092 #.rst:
0093 # A custom ``validate_sources`` targets is declared to compare files listed
0094 # in `sources.cmake` scripts with on-disk files. As sources.cmake lists
0095 # source files of Geant4 explicitely, we can often a mismatch can occur
0096 # between this list and what's actually on disk.
0097 #
0098 # The ``validate_sources`` target executes a CMake script to
0099 # check for these errors and report mismatches. It fails with FATAL_ERROR
0100 # if any mismatch is found, but will not do so until it has reported
0101 # all errors.
0102 # Configure the script
0103 configure_file(
0104 ${PROJECT_SOURCE_DIR}/cmake/Templates/geant4_validate_sources.cmake.in
0105 ${PROJECT_BINARY_DIR}/geant4_validate_sources.cmake
0106 @ONLY
0107 )
0108
0109 # Create the target
0110 add_custom_target(validate_sources
0111 COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/geant4_validate_sources.cmake
0112 COMMENT "Validating Geant4 Module Source Lists"
0113 )
0114
0115 #.rst:
0116 # Custom ``validate_no_module_cycles`` and ``validate_module_consistency`` targets
0117 # are declared if Python3.9 is available.
0118 # These runs the geant4_module_check.py Python script to check for cycles or
0119 # inconsistencies in the module dependency graph and declarations.
0120 find_package(Python3 3.9 QUIET COMPONENTS Interpreter)
0121 if(Python3_FOUND)
0122 set(G4MODULE_VALIDATION_CMD Python3::Interpreter
0123 ${PROJECT_SOURCE_DIR}/cmake/Modules/geant4_module_check.py
0124 -db ${PROJECT_BINARY_DIR}/G4ModuleInterfaceMap.csv)
0125
0126 add_custom_target(validate_no_module_cycles
0127 COMMAND ${G4MODULE_VALIDATION_CMD} --find-cycles
0128 COMMENT "Checking for cycles in declared source module dependencies"
0129 )
0130
0131 add_custom_target(validate_module_consistency
0132 COMMAND ${G4MODULE_VALIDATION_CMD} --find-inconsistencies
0133 COMMENT "Checking for inconsistencies in declared source module dependencies"
0134 USES_TERMINAL
0135 )
0136 endif()
0137
0138 #-----------------------------------------------------------------------
0139 #.rst:
0140 # General Installation Settings
0141 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0142 #
0143 # Geant4 custom defaults
0144
0145 set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH
0146 "Read-only architecture-independent data root (share)")
0147
0148 set(CMAKE_INSTALL_DATADIR
0149 "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}" CACHE PATH
0150 "Read-only architecture-independent data (DATAROOTDIR/${PROJECT_NAME})")
0151
0152 #
0153 # CMake's builtin `GNUInstallDirs` module is used to set and provide variables
0154 # for the destinations to which for executables, libraries and other files
0155 # should be installed.
0156 #
0157 include(GNUInstallDirs)
0158
0159 # Check for non-relocatable install directories
0160 foreach(dir
0161 BINDIR
0162 LIBDIR
0163 INCLUDEDIR
0164 DATAROOTDIR
0165 DATADIR
0166 MANDIR
0167 DOCDIR
0168 )
0169 if(IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
0170 set(CMAKE_INSTALL_IS_NONRELOCATABLE 1)
0171 endif()
0172 endforeach()
0173
0174 #.rst:
0175 # The following CMake variables are additionally set to control install
0176 # policy and reporting:
0177
0178 #.rst:
0179 # - ``CMAKE_INSTALL_MESSAGE`` : ``LAZY``
0180 #
0181 # - Only report new or updated files installed by the ``install`` target.
0182 #
0183 set(CMAKE_INSTALL_MESSAGE LAZY)
0184
0185 #.rst:
0186 # An `uninstall` target is provided to assist in removing previously installed
0187 # files. It will not remove any installed directories per standard behaviour.
0188 # Note that if files are removed from the install manifest between invocations
0189 # of the `install` and `uninstall` targets, they will *not* be removed by the
0190 # latter.
0191 #
0192 include(CMakeUninstallTarget)
0193