33#
44# 21st September 2010 Ben Morgan
55#
6- # $Id: CMakeLists.txt,v 1.6 2010/12/ 08 16:36:34 bmorgan Exp $
7- # GEANT4 Tag $Name: geant4-09-04 $
6+ # $Id: CMakeLists.txt,v 1.6 2010-12- 08 16:36:34 bmorgan Exp $
7+ # GEANT4 Tag $Name: not supported by cvs2svn $
88#
99
1010#------------------------------------------------------------------------------
11- # Enforce out-of-source builds before anything else
11+ # - Enforce an out-of-source builds before anything else
1212#
1313if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
1414 message (STATUS "Geant4 requires an out-of-source build." )
@@ -21,201 +21,127 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
2121endif ()
2222
2323#------------------------------------------------------------------------------
24- # Define CMake requirements and override make rules as needed
24+ # - Define CMake requirements and override make rules as needed
2525#
2626cmake_minimum_required (VERSION 2.6)
2727set (CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
2828 ${CMAKE_SOURCE_DIR} /cmake/Modules/Geant4MakeRules_cxx.cmake)
2929
30- set (CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran
31- ${CMAKE_SOURCE_DIR} /cmake/Modules/Geant4MakeRules_fortran.cmake)
30+ # set(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran
31+ # ${CMAKE_SOURCE_DIR}/cmake/Modules/Geant4MakeRules_fortran.cmake)
3232
3333#------------------------------------------------------------------------------
34- # Define the project
34+ # - Project definition
3535#
36- project (geant4 )
36+ project (Geant4 )
3737
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" )
4638
47- #------------------------------------------------------------------------------
48- # Set up path to internal set of CMake modules.
39+ #----------------------------------------------------------------------------
40+ # - Prepend our own CMake Modules to the search path
41+ # This allows us to customize, add, and factor out functionality
42+ # NB: if our custom modules include others that we don't supply, those in the
43+ # base path will be used, so watch for incompatibilities!!
4944#
5045set (CMAKE_MODULE_PATH
51- ${geant4_SOURCE_DIR} /cmake
52- ${geant4_SOURCE_DIR} /cmake/Modules
46+ ${PROJECT_SOURCE_DIR} /cmake/Modules
5347 ${CMAKE_MODULE_PATH} )
5448
5549
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
50+ #----------------------------------------------------------------------------
51+ # - Add functionality provided by standard and custom modules
52+ # See the documentation in each of these modules for further details.
7053#
71- include (Geant4CPackBase)
72- include (FeatureSummary)
73- include (Geant4MacroUtilities)
74- include (CMakeDependentOption)
54+ # - Versioning. We do this here for now
55+ set (${PROJECT_NAME} _VERSION "9.5.0" )
56+ set (${PROJECT_NAME} _VERSION_MAJOR "9" )
57+ set (${PROJECT_NAME} _VERSION_MINOR "5" )
58+ set (${PROJECT_NAME} _VERSION_PATCH "0" )
7559
60+ # - Provide dependent options as these are needed for some Geant4 features
61+ include (CMakeDependentOption)
7662
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 )
63+ # - Provide general CMake utilities for Geant4.
64+ include (Geant4MacroUtilities)
9465
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)
66+ # - Provide an 'uninstall' target.
67+ include (CMakeUninstallTarget)
10268
69+ # - Provide the 'validate_sources' target.
70+ include (Geant4ValidateSources)
10371
104- #------------------------------------------------------------------------------
105- # Geant4 defaults for data libraries
106- # Not required for build, so how best to handle?
107- #
72+ # - Provide standard install directories permitting customization.
73+ include (Geant4InstallDirs)
10874
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)
75+ # - Provide options to control how Geant4 libraries are built
76+ include (Geant4LibraryBuildOptions)
11577
78+ # - Provide interface to control use of optional components
79+ include (Geant4OptionalComponents)
11680
117- #------------------------------------------------------------------------------
118- # Geant4 User Interface Options
119- # Written in separate module for clarity
120- #
81+ # - Provide interface to control use of UI/Vis components
82+ # Written in a separate module from other optional components because
83+ # there are many complex options to handle.
12184include (Geant4InterfaceOptions)
12285
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-
86+ # - Provide options to enable wrapping of Geant4 by other languages
87+ include (Geant4Wrapping)
13688
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 ()
15389
15490#------------------------------------------------------------------------------
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" )
91+ # Add the source and environments subdirectories
92+ # source : Process all the Geant4 core targets
93+ # environments : Process optional wrappings of Geant4 (NOTYETIMPLEMENTED)
94+ add_subdirectory (source )
95+ #add_subdirectory(environments)
16496
16597
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?)
98+ #----------------------------------------------------------------------------
99+ # - Perform all post build tasks
100+ # At the CMake level, this simply means that we must know about targets
101+ # and other properties processed in source and environments trees before
102+ # these tasks can be performed.
170103#
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.
104+ #----------------------------------------------------------------------------
105+ # Installation of optional read-only architecture independent data files.
106+ # E.g. Examples, data libraries, documentation.
107+ # Done before toolchain generation because it may affect what we have to do
108+ # there!
187109#
188- add_subdirectory (source )
189-
110+ include (Geant4InstallData)
190111
191112#------------------------------------------------------------------------------
192113# Generate any Use/Config files here once everything else has been processed
193114# e.g. "UseGeant4.cmake", "Geant4Config.cmake" - library dependencies etc
194115#
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-
204116include (Geant4ToolchainBackwardCompatibility)
205117include (Geant4ConfigureConfigScript)
206118
207-
208- #------------------------------------------------------------------------------
209- # Install any extra files needed such as documentation and legacy Makefiles
119+ #----------------------------------------------------------------------------
120+ # Create the Geant4Config files and supporting modules
210121#
211- # User example code
212- install (DIRECTORY examples
213- DESTINATION ${GEANT4_DATAROOTDIR} /geant4-${geant4_VERSION}
214- PATTERN "CVS" EXCLUDE )
122+ include (Geant4BuildProjectConfig)
215123
124+ #------------------------------------------------------------------------------
125+ # Add the examples and tests subdirectories
126+ # This is done after the Geant4Config.cmake file has been generated
127+ if (GEANT4_ENABLE_TESTING)
128+ include (Geant4CTest)
129+ add_subdirectory (tests)
130+ if (EXISTS ${CMAKE_SOURCE_DIR} /benchmarks)
131+ add_subdirectory (benchmarks)
132+ endif ()
133+ endif ()
134+ if (GEANT4_BUILD_EXAMPLES)
135+ set (Geant4_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Current build directory" )
136+ add_subdirectory (examples)
137+ endif ()
138+ #-----------------------------------------------------------------------------
139+ # Provide packaging with CPack.
140+ include (Geant4CPackBase)
216141
217- #
142+ #----------------------------------------------------------------------------
218143# Final output - show what's been enabled so that user knows what's
219144# happening - also useful for later problem solving!
220145#
221146GEANT4_PRINT_ENABLED_FEATURES()
147+
0 commit comments