Geant4 Cross Reference |
1 # - Use file for Geant4 1 # - Use file for Geant4 2 # Add Module directory so that examples can us << 2 # This file may be included after a find_package call has successfully 3 # modules. Appended to minimize any conflict w << 3 # located Geant4 to set global compile definitions, include directories, 4 # settings << 4 # and compiler flags for building and linking to the Geant4 libraries. 5 # DEPRECATED: Only needed by certain examples << 5 # 6 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_ << 6 # If Geant4 has been located via the Geant4Config.cmake config file, the >> 7 # following variable will be set: >> 8 # >> 9 # Geant4_USE_FILE : Point to the location of the use file for the found >> 10 # Geant4 installation. >> 11 # >> 12 # Inclusion of this file, e.g. via >> 13 # >> 14 # include(${Geant4_USE_FILE}) >> 15 # >> 16 # results in the addition of the Geant4 compile definitions and >> 17 # include directories to those of the directory in which this file is >> 18 # included. >> 19 # >> 20 # Header paths are added via include_directories as SYSTEM type directories >> 21 # >> 22 # The recommended Geant4 compiler flags are also prepended to >> 23 # CMAKE_CXX_FLAGS but duplicated flags are NOT removed. This permits >> 24 # client of UseGeant4 to override Geant4's recommended flags if required >> 25 # and at their own risk. >> 26 # >> 27 # Advanced users requiring special sets of flags, or the removal of >> 28 # duplicate flags should therefore *not* use this file, preferring the >> 29 # direct use of the Geant4_XXXX variables set by the Geant4Config file. >> 30 # >> 31 # The last thing the module does is to optionally include an internal Use >> 32 # file. This file can contain variables, functions and macros for strict >> 33 # internal use in Geant4, such as building and running validation tests. >> 34 # >> 35 >> 36 #----------------------------------------------------------------------- >> 37 # We need to set the compile definitions and include directories >> 38 # >> 39 add_definitions(${Geant4_DEFINITIONS}) >> 40 include_directories(AFTER SYSTEM ${Geant4_INCLUDE_DIRS}) >> 41 >> 42 #----------------------------------------------------------------------- >> 43 # Because Geant4 is sensitive to the compiler flags, set the base >> 44 # set here. This reproduces as far as possible the behaviour of the >> 45 # original makefile system. >> 46 # >> 47 set(CMAKE_CXX_FLAGS "${Geant4_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") >> 48 set(CMAKE_CXX_FLAGS_DEBUG "${Geant4_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}") >> 49 set(CMAKE_CXX_FLAGS_MINSIZEREL "${Geant4_CXX_FLAGS_MINSIZEREL} ${CMAKE_CXX_FLAGS_MINSIZEREL}") >> 50 set(CMAKE_CXX_FLAGS_RELEASE "${Geant4_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}") >> 51 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${Geant4_CXX_FLAGS_RELWITHDEBINFO} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") >> 52 set(CMAKE_EXE_LINKER_FLAGS "${Geant4_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") >> 53 >> 54 #----------------------------------------------------------------------- >> 55 # Update build type information ONLY for single mode build tools, adding >> 56 # type used to build this install if none has been set, but otherwise leaving >> 57 # value alone. >> 58 # NB: this doesn't allow "None" for the build type - would need something >> 59 # more sophisticated using an internal cache variable. >> 60 # Good enough for now! >> 61 # >> 62 if(NOT CMAKE_CONFIGURATION_TYPES) >> 63 if(NOT CMAKE_BUILD_TYPE) >> 64 # Default to type used to build this install. >> 65 set(CMAKE_BUILD_TYPE "${Geant4_BUILD_TYPE}" >> 66 CACHE STRING "Choose the type of build, options are: None Release MinSizeRel Debug RelWithDebInfo MinSizeRel." >> 67 FORCE >> 68 ) >> 69 else() >> 70 # Force to the cache, but use existing value. >> 71 set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" >> 72 CACHE STRING "Choose the type of build, options are: None Release MinSizeRel Debug RelWithDebInfo MinSizeRel." >> 73 FORCE >> 74 ) >> 75 endif() >> 76 endif() >> 77 >> 78 #----------------------------------------------------------------------- >> 79 # Locate ourselves >> 80 # >> 81 get_filename_component(_use_geant4_dir ${CMAKE_CURRENT_LIST_FILE} PATH) >> 82 >> 83 #----------------------------------------------------------------------- >> 84 # Append the local module path to CMAKE_MODULE_PATH to automatically >> 85 # make FindXXX modules for examples available >> 86 # >> 87 list(APPEND CMAKE_MODULE_PATH ${_use_geant4_dir}/Modules) >> 88 >> 89 #----------------------------------------------------------------------- >> 90 # Include internal use file if it exists. It should only exist in the >> 91 # build tree! >> 92 # >> 93 include(${_use_geant4_dir}/UseGeant4_internal.cmake OPTIONAL) >> 94