|
| 1 | +#------------------------------------------------------------------------------ |
| 2 | +# Top Level CMakeLists.txt for Geant4 Build |
| 3 | +# |
| 4 | +# 21st September 2010 Ben Morgan |
| 5 | +# |
| 6 | +# $Id: CMakeLists.txt,v 1.6 2010/12/08 16:36:34 bmorgan Exp $ |
| 7 | +# GEANT4 Tag $Name: geant4-09-04 $ |
| 8 | +# |
| 9 | + |
| 10 | +#------------------------------------------------------------------------------ |
| 11 | +# Enforce out-of-source builds before anything else |
| 12 | +# |
| 13 | +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) |
| 14 | + message(STATUS "Geant4 requires an out-of-source build.") |
| 15 | + message(STATUS "Please remove these files from ${CMAKE_BINARY_DIR} first:") |
| 16 | + message(STATUS "CMakeCache.txt") |
| 17 | + message(STATUS "CMakeFiles") |
| 18 | + message(STATUS "Once these files are removed, create a separate directory") |
| 19 | + message(STATUS "and run CMake from there") |
| 20 | + message(FATAL_ERROR "in-source build detected") |
| 21 | +endif() |
| 22 | + |
| 23 | +#------------------------------------------------------------------------------ |
| 24 | +# Define CMake requirements and override make rules as needed |
| 25 | +# |
| 26 | +cmake_minimum_required(VERSION 2.6) |
| 27 | +set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX |
| 28 | + ${CMAKE_SOURCE_DIR}/cmake/Modules/Geant4MakeRules_cxx.cmake) |
| 29 | + |
| 30 | +set(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran |
| 31 | + ${CMAKE_SOURCE_DIR}/cmake/Modules/Geant4MakeRules_fortran.cmake) |
| 32 | + |
| 33 | +#------------------------------------------------------------------------------ |
| 34 | +# Define the project |
| 35 | +# |
| 36 | +project(geant4) |
| 37 | + |
| 38 | +#------------------------------------------------------------------------------ |
| 39 | +# Define the version of the project - can be used to generate sources, |
| 40 | +# but just used for CPack the the moment |
| 41 | +# |
| 42 | +set(${PROJECT_NAME}_VERSION "9.4.0") |
| 43 | +set(${PROJECT_NAME}_VERSION_MAJOR "9") |
| 44 | +set(${PROJECT_NAME}_VERSION_MINOR "4") |
| 45 | +set(${PROJECT_NAME}_VERSION_PATCH "0") |
| 46 | + |
| 47 | +#------------------------------------------------------------------------------ |
| 48 | +# Set up path to internal set of CMake modules. |
| 49 | +# |
| 50 | +set(CMAKE_MODULE_PATH |
| 51 | + ${geant4_SOURCE_DIR}/cmake |
| 52 | + ${geant4_SOURCE_DIR}/cmake/Modules |
| 53 | + ${CMAKE_MODULE_PATH}) |
| 54 | + |
| 55 | + |
| 56 | +#------------------------------------------------------------------------------ |
| 57 | +# Set up Build types or configurations |
| 58 | +# If further tuning of compiler flags is needed then it should be done here. |
| 59 | +# (It can't be done in the make rules override section). |
| 60 | +# However, exercise care when doing this not to override existing flags!! |
| 61 | +# We don't do this on WIN32 platforms because of some teething issues |
| 62 | +# with compiler specifics and linker flags |
| 63 | +if(NOT WIN32) |
| 64 | + include(Geant4BuildModes) |
| 65 | +endif(NOT WIN32) |
| 66 | + |
| 67 | + |
| 68 | +#------------------------------------------------------------------------------ |
| 69 | +# Includes for common utilities |
| 70 | +# |
| 71 | +include(Geant4CPackBase) |
| 72 | +include(FeatureSummary) |
| 73 | +include(Geant4MacroUtilities) |
| 74 | +include(CMakeDependentOption) |
| 75 | + |
| 76 | + |
| 77 | +#------------------------------------------------------------------------------ |
| 78 | +# Geant4 library build options. |
| 79 | +# Only global or granular libraries can be built. Global libraries are the |
| 80 | +# default, and provide an advanced option to switch to granular build. |
| 81 | +# Only developers really need the granular build. |
| 82 | +option(GEANT4_BUILD_GRANULAR_LIBS "Build Geant4 with granular libraries" OFF) |
| 83 | +mark_as_advanced(GEANT4_BUILD_GRANULAR_LIBS) |
| 84 | +GEANT4_ADD_FEATURE(GEANT4_BUILD_GRANULAR_LIBS "Build granular Geant4 libraries") |
| 85 | + |
| 86 | +# Default to static libraries on win32 until declspec issues resolved |
| 87 | +if(WIN32) |
| 88 | + option(BUILD_STATIC_LIBS "Build Geant4 static libraries" ON) |
| 89 | + option(BUILD_SHARED_LIBS "Build Geant4 dynamic libraries" OFF) |
| 90 | +else(WIN32) |
| 91 | + option(BUILD_STATIC_LIBS "Build Geant4 static libraries" OFF) |
| 92 | + option(BUILD_SHARED_LIBS "Build Geant4 dynamic libraries" ON) |
| 93 | +endif(WIN32) |
| 94 | + |
| 95 | +#------------------------------------------------------------------------------ |
| 96 | +# Build output |
| 97 | +# Output all binaries to single directory based on their type |
| 98 | +# |
| 99 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/runtime) |
| 100 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/library) |
| 101 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/archive) |
| 102 | + |
| 103 | + |
| 104 | +#------------------------------------------------------------------------------ |
| 105 | +# Geant4 defaults for data libraries |
| 106 | +# Not required for build, so how best to handle? |
| 107 | +# |
| 108 | + |
| 109 | +#------------------------------------------------------------------------------ |
| 110 | +# Find required CLHEP package |
| 111 | +# Use REQUIRED - we MUST have it. An EXACT version number is not used at |
| 112 | +# present, but can be added later as needed. |
| 113 | +# |
| 114 | +find_package(CLHEP 2.1.0.1 REQUIRED) |
| 115 | + |
| 116 | + |
| 117 | +#------------------------------------------------------------------------------ |
| 118 | +# Geant4 User Interface Options |
| 119 | +# Written in separate module for clarity |
| 120 | +# |
| 121 | +include(Geant4InterfaceOptions) |
| 122 | + |
| 123 | +#------------------------------------------------------------------------------ |
| 124 | +# Geant4 Extra Modules Options |
| 125 | +# |
| 126 | +#------------------------------------------------------------------------------ |
| 127 | +# Optional support for GDML - requires XercesC package |
| 128 | +# |
| 129 | +option(GEANT4_USE_GDML "Build Geant4 with GDML support" OFF) |
| 130 | +if(GEANT4_USE_GDML) |
| 131 | + find_package(XercesC REQUIRED) |
| 132 | +endif(GEANT4_USE_GDML) |
| 133 | + |
| 134 | +GEANT4_ADD_FEATURE(GEANT4_USE_GDML "Build Geant4 with GDML support") |
| 135 | + |
| 136 | + |
| 137 | +#------------------------------------------------------------------------------ |
| 138 | +# Build G3ToG4 converter program |
| 139 | +# The G3toG4 *library* will always be built, but the application requires |
| 140 | +# a Fortran compiler AND CERNLIB, so is optional. |
| 141 | +# Only on *NIX because converter requires CERNLIB, and Windows support for |
| 142 | +# this is an unknown quantity at present (can always change later). |
| 143 | +# |
| 144 | +if(UNIX) |
| 145 | + option(GEANT4_USE_GEANT3TOGEANT4 "Build the Geant3-to-Geant4 converter application" OFF) |
| 146 | + if(GEANT4_USE_GEANT3TOGEANT4) |
| 147 | + enable_language(Fortran) |
| 148 | + #find_package(CERNLIB REQUIRED) |
| 149 | + endif(GEANT4_USE_GEANT3TOGEANT4) |
| 150 | + |
| 151 | + GEANT4_ADD_FEATURE(GEANT4_USE_GEANT3TOGEANT4 "Build the Geant3-to-Geant4 converter application") |
| 152 | +endif() |
| 153 | + |
| 154 | +#------------------------------------------------------------------------------ |
| 155 | +# Optional use of system zlib library |
| 156 | +# |
| 157 | +#option(GEANT4_USE_SYSTEM_ZLIB "Use the system's zlib library" OFF) |
| 158 | +if(GEANT4_USE_SYSTEM_ZLIB) |
| 159 | + # This needs more work - use ITK's way of doing it as an example. |
| 160 | + find_package(ZLIB) |
| 161 | +endif(GEANT4_USE_SYSTEM_ZLIB) |
| 162 | + |
| 163 | +GEANT4_ADD_FEATURE(GEANT4_USE_SYSTEM_ZLIB "Use system zlib library") |
| 164 | + |
| 165 | + |
| 166 | +#------------------------------------------------------------------------------ |
| 167 | +# Optional build of Python wrappers (Geant4Py) |
| 168 | +# Suggested that this be brought under the wing of the CMake system. |
| 169 | +# -> Requires Global/Shared library build (all platforms?) |
| 170 | +# |
| 171 | +#CMAKE_DEPENDENT_OPTION(GEANT4_WRAP_PYTHON "Wrap Geant4 classes into the Python language" OFF "GEANT4_BUILD_GLOBAL_LIBS;BUILD_SHARED_LIBS" OFF) |
| 172 | +#if(GEANT4_WRAP_PYTHON) |
| 173 | + # We need Boost-Python and Python |
| 174 | + # NB: Watch for FindPythonLibs picking up the static version... |
| 175 | + # Known issue with CMake 2.6 module - see Bug #8389 and 2257 for details |
| 176 | + # of fix |
| 177 | + # find_package(Boost REQUIRED COMPONENTS python) |
| 178 | + #find_package(PythonLibs REQUIRED) |
| 179 | + #endif(GEANT4_WRAP_PYTHON) |
| 180 | + |
| 181 | + #GEANT4_ADD_FEATURE(GEANT4_WRAP_PYTHON "Wrap Geant4 classes into the Python language") |
| 182 | + |
| 183 | + |
| 184 | +#------------------------------------------------------------------------------ |
| 185 | +# Add the source subdirectory - all the source code for the libraries is under |
| 186 | +# this. |
| 187 | +# |
| 188 | +add_subdirectory(source) |
| 189 | + |
| 190 | + |
| 191 | +#------------------------------------------------------------------------------ |
| 192 | +# Generate any Use/Config files here once everything else has been processed |
| 193 | +# e.g. "UseGeant4.cmake", "Geant4Config.cmake" - library dependencies etc |
| 194 | +# |
| 195 | +set(GEANT4_PREFIX ${CMAKE_INSTALL_PREFIX}) |
| 196 | +set(GEANT4_EXEC_PREFIX ${GEANT4_PREFIX}) |
| 197 | +set(GEANT4_BINDIR ${GEANT4_EXEC_PREFIX}/bin) |
| 198 | +set(GEANT4_LIBDIR ${GEANT4_PREFIX}/lib) |
| 199 | +set(GEANT4_DATAROOTDIR ${GEANT4_PREFIX}/share) |
| 200 | +set(GEANT4_DATADIR ${GEANT4_DATAROOTDIR}) |
| 201 | +set(GEANT4_INCLUDEDIR ${GEANT4_PREFIX}/include) |
| 202 | +set(GEANT4_DOCDIR ${GEANT4_DATAROOTDIR}/doc/geant4-${geant4_VERSION}) |
| 203 | + |
| 204 | +include(Geant4ToolchainBackwardCompatibility) |
| 205 | +include(Geant4ConfigureConfigScript) |
| 206 | + |
| 207 | + |
| 208 | +#------------------------------------------------------------------------------ |
| 209 | +# Install any extra files needed such as documentation and legacy Makefiles |
| 210 | +# |
| 211 | +# User example code |
| 212 | +install(DIRECTORY examples |
| 213 | + DESTINATION ${GEANT4_DATAROOTDIR}/geant4-${geant4_VERSION} |
| 214 | + PATTERN "CVS" EXCLUDE) |
| 215 | + |
| 216 | + |
| 217 | +# |
| 218 | +# Final output - show what's been enabled so that user knows what's |
| 219 | +# happening - also useful for later problem solving! |
| 220 | +# |
| 221 | +GEANT4_PRINT_ENABLED_FEATURES() |
0 commit comments