Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -1,138 +0,0 @@
|
||||
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
|
||||
# parsing the arguments given to that macro or function.
|
||||
# It processes the arguments and defines a set of variables which hold the
|
||||
# values of the respective options.
|
||||
#
|
||||
# The <options> argument contains all options for the respective macro,
|
||||
# i.e. keywords which can be used when calling the macro without any value
|
||||
# following, like e.g. the OPTIONAL keyword of the install() command.
|
||||
#
|
||||
# The <one_value_keywords> argument contains all keywords for this macro
|
||||
# which are followed by one value, like e.g. DESTINATION keyword of the
|
||||
# install() command.
|
||||
#
|
||||
# The <multi_value_keywords> argument contains all keywords for this macro
|
||||
# which can be followed by more than one value, like e.g. the TARGETS or
|
||||
# FILES keywords of the install() command.
|
||||
#
|
||||
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
|
||||
# keywords listed in <options>, <one_value_keywords> and
|
||||
# <multi_value_keywords> a variable composed of the given <prefix>
|
||||
# followed by "_" and the name of the respective keyword.
|
||||
# These variables will then hold the respective value from the argument list.
|
||||
# For the <options> keywords this will be TRUE or FALSE.
|
||||
#
|
||||
# All remaining arguments are collected in a variable
|
||||
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
|
||||
# your macro was called with unrecognized parameters.
|
||||
#
|
||||
# As an example here a my_install() macro, which takes similar arguments as the
|
||||
# real install() command:
|
||||
#
|
||||
# function(MY_INSTALL)
|
||||
# set(options OPTIONAL FAST)
|
||||
# set(oneValueArgs DESTINATION RENAME)
|
||||
# set(multiValueArgs TARGETS CONFIGURATIONS)
|
||||
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
# ...
|
||||
#
|
||||
# Assume my_install() has been called like this:
|
||||
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
|
||||
#
|
||||
# After the cmake_parse_arguments() call the macro will have set the following
|
||||
# variables:
|
||||
# MY_INSTALL_OPTIONAL = TRUE
|
||||
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
|
||||
# MY_INSTALL_DESTINATION = "bin"
|
||||
# MY_INSTALL_RENAME = "" (was not used)
|
||||
# MY_INSTALL_TARGETS = "foo;bar"
|
||||
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
|
||||
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
|
||||
#
|
||||
# You can the continue and process these variables.
|
||||
#
|
||||
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
|
||||
# another recognized keyword follows, this is interpreted as the beginning of
|
||||
# the new option.
|
||||
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
|
||||
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
|
||||
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
|
||||
|
||||
|
||||
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
|
||||
# first set all result variables to empty/FALSE
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach(arg_name)
|
||||
|
||||
foreach(option ${_optionNames})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach(option)
|
||||
|
||||
set(${prefix}_UNPARSED_ARGUMENTS)
|
||||
|
||||
set(insideValues FALSE)
|
||||
set(currentArgName)
|
||||
|
||||
# now iterate over all arguments and fill the result variables
|
||||
foreach(currentArg ${ARGN})
|
||||
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
|
||||
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
|
||||
if(insideValues)
|
||||
if("${insideValues}" STREQUAL "SINGLE")
|
||||
set(${prefix}_${currentArgName} ${currentArg})
|
||||
set(insideValues FALSE)
|
||||
elseif("${insideValues}" STREQUAL "MULTI")
|
||||
list(APPEND ${prefix}_${currentArgName} ${currentArg})
|
||||
endif()
|
||||
else(insideValues)
|
||||
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
|
||||
endif(insideValues)
|
||||
else()
|
||||
if(NOT ${optionIndex} EQUAL -1)
|
||||
set(${prefix}_${currentArg} TRUE)
|
||||
set(insideValues FALSE)
|
||||
elseif(NOT ${singleArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "SINGLE")
|
||||
elseif(NOT ${multiArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "MULTI")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endforeach(currentArg)
|
||||
|
||||
# propagate the result variables to the caller:
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
|
||||
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
|
||||
endforeach(arg_name)
|
||||
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
|
||||
|
||||
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
|
||||
@@ -1,355 +0,0 @@
|
||||
# - Try to find the CLHEP High Energy Physics library and headers
|
||||
# Usage of this module is as follows
|
||||
#
|
||||
# == Using any header-only components of CLHEP: ==
|
||||
#
|
||||
# find_package( CLHEP 2.3.1.0 )
|
||||
# if(CLHEP_FOUND)
|
||||
# include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
# add_executable(foo foo.cc)
|
||||
# endif()
|
||||
#
|
||||
# == Using the binary CLHEP library ==
|
||||
#
|
||||
# find_package( CLHEP 2.3.1.0 )
|
||||
# if(CLHEP_FOUND)
|
||||
# include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
# add_executable(foo foo.cc)
|
||||
# target_link_libraries(foo ${CLHEP_LIBRARIES})
|
||||
# endif()
|
||||
#
|
||||
# You can provide a minimum version number that should be used.
|
||||
# If you provide this version number and specify the REQUIRED attribute,
|
||||
# this module will fail if it can't find a CLHEP of the specified version
|
||||
# or higher. If you further specify the EXACT attribute, then this module
|
||||
# will fail if it can't find a CLHEP with a version eaxctly as specified.
|
||||
#
|
||||
# ===========================================================================
|
||||
# Variables used by this module which can be used to change the default
|
||||
# behaviour, and hence need to be set before calling find_package:
|
||||
#
|
||||
# CLHEP_ROOT_DIR The preferred installation prefix for searching for
|
||||
# CLHEP. Set this if the module has problems finding
|
||||
# the proper CLHEP installation.
|
||||
#
|
||||
# If you don't supply CLHEP_ROOT_DIR, the module will search on the standard
|
||||
# system paths. On UNIX, the module will also try to find the clhep-config
|
||||
# program in the PATH, and if found will use the prefix supplied by this
|
||||
# program as a HINT on where to find the CLHEP headers and libraries.
|
||||
#
|
||||
# You can re-run CMake with a different version of CLHEP_ROOT_DIR to
|
||||
# force a new search for CLHEP using the new version of CLHEP_ROOT_DIR.
|
||||
# CLHEP_ROOT_DIR is cached and so can be editted in the CMake curses
|
||||
# and GUI interfaces
|
||||
#
|
||||
# ============================================================================
|
||||
# Variables set by this module:
|
||||
#
|
||||
# CLHEP_FOUND System has CLHEP.
|
||||
#
|
||||
# CLHEP_INCLUDE_DIRS CLHEP include directories: not cached.
|
||||
#
|
||||
# CLHEP_LIBRARIES Link to these to use the CLHEP library: not cached.
|
||||
#
|
||||
# ===========================================================================
|
||||
# If CLHEP is installed in a non-standard way, e.g. a non GNU-style install
|
||||
# of <prefix>/{lib,include}, then this module may fail to locate the headers
|
||||
# and libraries as needed. In this case, the following cached variables can
|
||||
# be editted to point to the correct locations.
|
||||
#
|
||||
# CLHEP_INCLUDE_DIR The path to the CLHEP include directory: cached
|
||||
#
|
||||
# CLHEP_LIBRARY The path to the CLHEP library: cached
|
||||
#
|
||||
# You should not need to set these in the vast majority of cases
|
||||
#
|
||||
|
||||
#============================================================================
|
||||
# Copyright (C) 2010,2011 Ben Morgan <Ben.Morgan@warwick.ac.uk>
|
||||
# Copyright (C) 2010,2011 University of Warwick
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the University of Warwick nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#============================================================================
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Define library components for use if requested
|
||||
#
|
||||
set(CLHEP_COMPONENTS
|
||||
Cast
|
||||
Evaluator
|
||||
Exceptions
|
||||
GenericFunctions
|
||||
Geometry
|
||||
Matrix
|
||||
Random
|
||||
RandomObjects
|
||||
RefCount
|
||||
Vector
|
||||
)
|
||||
|
||||
# - and their interdependencies (taken from CLHEP webpage, may not
|
||||
# be totally up to date, but assumed to be complete
|
||||
set(CLHEP_Geometry_REQUIRES Vector)
|
||||
set(CLHEP_Matrix_REQUIRES Random Vector)
|
||||
set(CLHEP_RandomObjects_REQUIRES Matrix Random Vector)
|
||||
set(CLHEP_RefCount_REQUIRES Cast)
|
||||
set(CLHEP_Exceptions_REQUIRES RefCount Cast)
|
||||
|
||||
set(CLHEP_ROOT_DIR "${CLHEP_ROOT_DIR}" CACHE PATH "prefix of system CLHEP installation")
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Enable re-search if known CLHEP_ROOT_DIR changes?
|
||||
#
|
||||
if(NOT "${CLHEP_ROOT_DIR}" STREQUAL "${CLHEP_INTERNAL_ROOT_DIR}")
|
||||
if(CLHEP_INTERNAL_ROOT_DIR AND NOT CLHEP_FIND_QUIETLY)
|
||||
message(STATUS "CLHEP_ROOT_DIR Changed, Rechecking for CLHEP")
|
||||
endif()
|
||||
|
||||
set(CLHEP_INTERNAL_ROOT_DIR ${CLHEP_ROOT_DIR}
|
||||
CACHE INTERNAL "Last value supplied for where to locate CLHEP")
|
||||
#set(CLHEP_INCLUDE_DIR CLHEP_INCLUDE_DIR-NOTFOUND)
|
||||
#set(CLHEP_LIBRARY CLHEP_LIBRARY-NOTFOUND)
|
||||
#foreach(__clhep_comp ${CLHEP_COMPONENTS})
|
||||
#set(CLHEP_${__clhep_comp}_LIBRARY CLHEP_${__clhep_comp}_LIBRARY-NOTFOUND)
|
||||
#endforeach()
|
||||
#set(CLHEP_CONFIG_EXECUTABLE CLHEP_CONFIG_EXECUTABLE-NOTFOUND)
|
||||
unset(CLHEP_INCLUDE_DIR CACHE)
|
||||
unset(CLHEP_LIBRARY CACHE)
|
||||
foreach(__clhep_comp ${CLHEP_COMPONENTS})
|
||||
unset(CLHEP_${__clhep_comp}_LIBRARY CACHE)
|
||||
endforeach()
|
||||
unset(CLHEP_CONFIG_EXECUTABLE CACHE)
|
||||
|
||||
|
||||
set(CLHEP_LIBRARIES )
|
||||
set(CLHEP_INCLUDE_DIRS )
|
||||
set(CLHEP_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# - If we already found CLHEP, be quiet
|
||||
#
|
||||
if(CLHEP_INCLUDE_DIR AND CLHEP_LIBRARY)
|
||||
set(CLHEP_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Set up HINTS on where to look for CLHEP
|
||||
# If we're on UNIX, see if we can find clhep-config and use its --prefix
|
||||
# as an extra hint.
|
||||
#
|
||||
set(_clhep_root_hints ${CLHEP_ROOT_DIR})
|
||||
|
||||
if(UNIX)
|
||||
# Try and find clhep-config in the user's path, but hint at the bin
|
||||
# directory under CLHEP_ROOT_DIR because we'd ideally like to pick up
|
||||
# the config program that matches the libraries/headers.
|
||||
# We only use it as a fallback though.
|
||||
find_program(CLHEP_CONFIG_EXECUTABLE clhep-config
|
||||
HINTS ${_clhep_root_hints}/bin
|
||||
DOC "Path to CLHEP's clhep-config program")
|
||||
mark_as_advanced(CLHEP_CONFIG_EXECUTABLE)
|
||||
|
||||
if(CLHEP_CONFIG_EXECUTABLE)
|
||||
execute_process(COMMAND ${CLHEP_CONFIG_EXECUTABLE} --prefix
|
||||
OUTPUT_VARIABLE _clhep_config_prefix
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
list(APPEND _clhep_root_hints ${_clhep_config_prefix})
|
||||
endif()
|
||||
elseif(WIN32 AND NOT UNIX)
|
||||
# Do we need to set suitable defaults?
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Find the CLHEP headers
|
||||
# Use Units/defs.h as locator as this is pretty consistent through versions
|
||||
find_path(CLHEP_INCLUDE_DIR CLHEP/Units/defs.h
|
||||
HINTS ${_clhep_root_hints}
|
||||
PATH_SUFFIXES include
|
||||
DOC "Path to the CLHEP headers"
|
||||
)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Extract the CLHEP version from defs.h
|
||||
# Versions COMPATIBLE if RequestedVersion > FoundVersion
|
||||
# Also check if versions exact
|
||||
|
||||
if(CLHEP_INCLUDE_DIR)
|
||||
set(CLHEP_VERSION 0)
|
||||
file(READ "${CLHEP_INCLUDE_DIR}/CLHEP/Units/defs.h" _CLHEP_DEFS_CONTENTS)
|
||||
string(REGEX REPLACE ".*#define (PACKAGE|CLHEP_UNITS)+_VERSION \"([0-9.]+).*" "\\2"
|
||||
CLHEP_VERSION "${_CLHEP_DEFS_CONTENTS}")
|
||||
|
||||
if(NOT CLHEP_FIND_QUIETLY)
|
||||
message(STATUS "Found CLHEP Version ${CLHEP_VERSION}")
|
||||
endif()
|
||||
|
||||
if(CLHEP_FIND_VERSION)
|
||||
set(CLHEP_VERSIONING_TESTS CLHEP_VERSION_COMPATIBLE)
|
||||
|
||||
if("${CLHEP_VERSION}" VERSION_LESS "${CLHEP_FIND_VERSION}")
|
||||
set(CLHEP_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(CLHEP_VERSION_COMPATIBLE TRUE)
|
||||
|
||||
if(CLHEP_FIND_VERSION_EXACT)
|
||||
if("${CLHEP_VERSION}" VERSION_EQUAL "${CLHEP_FIND_VERSION}")
|
||||
set(CLHEP_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
list(APPEND CLHEP_VERSIONING_TESTS CLHEP_VERSION_EXACT)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Find the CLHEP library - AFTER version checking because CLHEP component
|
||||
# libs are named including the version number
|
||||
# Prefer lib64 if available.
|
||||
set(__CLHEP_LIBRARY_SET)
|
||||
|
||||
if(CLHEP_FIND_COMPONENTS)
|
||||
# Resolve dependencies of requested components
|
||||
set(CLHEP_RESOLVED_FIND_COMPONENTS)
|
||||
|
||||
foreach(__clhep_comp ${CLHEP_FIND_COMPONENTS})
|
||||
list(APPEND CLHEP_RESOLVED_FIND_COMPONENTS ${__clhep_comp} ${CLHEP_${__clhep_comp}_REQUIRES})
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES CLHEP_RESOLVED_FIND_COMPONENTS)
|
||||
|
||||
foreach(__clhep_comp ${CLHEP_RESOLVED_FIND_COMPONENTS})
|
||||
find_library(CLHEP_${__clhep_comp}_LIBRARY CLHEP-${__clhep_comp}-${CLHEP_VERSION}
|
||||
HINTS ${_clhep_root_hints}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
DOC "Path to the CLHEP ${__clhep_comp} library"
|
||||
)
|
||||
list(APPEND __CLHEP_LIBRARY_SET "CLHEP_${__clhep_comp}_LIBRARY")
|
||||
endforeach()
|
||||
else()
|
||||
find_library(CLHEP_LIBRARY CLHEP
|
||||
HINTS ${_clhep_root_hints}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
DOC "Path to the CLHEP library"
|
||||
)
|
||||
set(__CLHEP_LIBRARY_SET "CLHEP_LIBRARY")
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Construct an error message for FPHSA
|
||||
#
|
||||
set(CLHEP_DEFAULT_MSG "Could NOT find CLHEP:\n")
|
||||
|
||||
if(NOT CLHEP_INCLUDE_DIR)
|
||||
set(CLHEP_DEFAULT_MSG "${CLHEP_DEFAULT_MSG}CLHEP Header Path Not Found\n")
|
||||
endif()
|
||||
|
||||
if(NOT CLHEP_FIND_COMPONENTS AND NOT CLHEP_LIBRARY)
|
||||
set(CLHEP_DEFAULT_MSG "${CLHEP_DEFAULT_MSG}CLHEP Library Not Found\n")
|
||||
endif()
|
||||
|
||||
if(CLHEP_FIND_VERSION)
|
||||
if(NOT CLHEP_VERSION_COMPATIBLE)
|
||||
set(CLHEP_DEFAULT_MSG "${CLHEP_DEFAULT_MSG}Incompatible versions, ${CLHEP_VERSION}(found) < ${CLHEP_FIND_VERSION}(required)\n")
|
||||
endif()
|
||||
|
||||
if(CLHEP_FIND_VERSION_EXACT)
|
||||
if(NOT CLHEP_VERSION_EXACT)
|
||||
set(CLHEP_DEFAULT_MSG "${CLHEP_DEFAULT_MSG}Non-exact versions, ${CLHEP_VERSION}(found) != ${CLHEP_FIND_VERSION}(required)\n")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Handle the QUIETLY and REQUIRED arguments, setting CLHEP_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
#
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CLHEP
|
||||
"${CLHEP_DEFAULT_MSG}"
|
||||
${__CLHEP_LIBRARY_SET}
|
||||
CLHEP_INCLUDE_DIR
|
||||
${CLHEP_VERSIONING_TESTS}
|
||||
)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# If we found CLHEP, set the needed non-cache variables
|
||||
#
|
||||
if(CLHEP_FOUND)
|
||||
set(CLHEP_LIBRARIES)
|
||||
foreach(__clhep_lib ${__CLHEP_LIBRARY_SET})
|
||||
list(APPEND CLHEP_LIBRARIES ${${__clhep_lib}})
|
||||
endforeach()
|
||||
set(CLHEP_INCLUDE_DIRS ${CLHEP_INCLUDE_DIR})
|
||||
|
||||
# Create imported targets
|
||||
foreach(__clhep_lib ${__CLHEP_LIBRARY_SET})
|
||||
# Construct imported target name
|
||||
string(REPLACE "_LIBRARY" "" __clhep_imp_lib "${__clhep_lib}")
|
||||
string(REPLACE "_" "::" __clhep_imp_lib "${__clhep_imp_lib}")
|
||||
if(__clhep_imp_lib STREQUAL "CLHEP")
|
||||
# Create both CLHEP and CLHEP::CLHEP targets
|
||||
if(NOT TARGET CLHEP::CLHEP)
|
||||
add_library(CLHEP::CLHEP UNKNOWN IMPORTED)
|
||||
set_target_properties(CLHEP::CLHEP PROPERTIES
|
||||
IMPORTED_LOCATION "${CLHEP_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CLHEP_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
if(NOT TARGET CLHEP)
|
||||
add_library(CLHEP UNKNOWN IMPORTED)
|
||||
set_target_properties(CLHEP PROPERTIES
|
||||
IMPORTED_LOCATION "${CLHEP_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CLHEP_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
# Have a component target - these are always namespaced
|
||||
# Note that at present, link interfaces aren't created...
|
||||
if(NOT TARGET ${__clhep_imp_lib})
|
||||
add_library(${__clhep_imp_lib} UNKNOWN IMPORTED)
|
||||
set_target_properties(${__clhep_imp_lib} PROPERTIES
|
||||
IMPORTED_LOCATION "${${__clhep_lib}}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CLHEP_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Mark cache variables that can be adjusted as advanced
|
||||
#
|
||||
mark_as_advanced(CLHEP_INCLUDE_DIR CLHEP_LIBRARY)
|
||||
foreach(__clhep_comp ${CLHEP_COMPONENTS})
|
||||
mark_as_advanced(CLHEP_${__clhep_comp}_LIBRARY)
|
||||
endforeach()
|
||||
@@ -1,84 +0,0 @@
|
||||
# - Add Geant4 specific build modes and additional flags
|
||||
#
|
||||
# This follows the guide on adding a new mode on the CMake wiki:
|
||||
#
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_extend_the_build_modes_with_a_custom_made_one_.3F
|
||||
#
|
||||
# Geant4 supports the standard CMake build types/configurations of
|
||||
#
|
||||
# Release Debug MinSizeRel RelWithDebInfo
|
||||
#
|
||||
# In addition, two types specifically for development are added:
|
||||
#
|
||||
# TestRelease:
|
||||
# For trial production and extended testing. It has verbose
|
||||
# output, has debugging symbols, and adds definitions to allow FPE
|
||||
# and physics conservation law testing where supported.
|
||||
#
|
||||
# Maintainer:
|
||||
# For development of the toolkit. It adds debugging, and enables the use
|
||||
# of library specific debugging via standardized definitions.
|
||||
#
|
||||
# Compiler flags specific to these build types are set in the cache, and
|
||||
# the types are added to the CMAKE_BUILD_TYPE cache string and to
|
||||
# CMAKE_CONFIGURATION_TYPES if appropriate to the build tool being used.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Add TestRelease{Debug} Modes and cache init flags
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS_TESTRELEASE "${CMAKE_CXX_FLAGS_TESTRELEASE_INIT}"
|
||||
CACHE STRING "Flags used by the compiler during TestRelease builds"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Add Maintainer Mode
|
||||
#
|
||||
set(CMAKE_CXX_FLAGS_MAINTAINER "${CMAKE_CXX_FLAGS_MAINTAINER_INIT}"
|
||||
CACHE STRING "Flags used by the compiler during Maintainer builds"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Mark all the additional mode flags as advanced because most users will
|
||||
# never need to see them
|
||||
mark_as_advanced(
|
||||
CMAKE_CXX_FLAGS_TESTRELEASE
|
||||
CMAKE_CXX_FLAGS_MAINTAINER
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Add the new configuration types ONLY if the build tool supports multiple
|
||||
# configurations
|
||||
#
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES TestRelease)
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
|
||||
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}"
|
||||
CACHE STRING "Geant4 configurations for multimode build tools"
|
||||
FORCE
|
||||
)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Update build type information ONLY for single mode build tools, adding
|
||||
# default type if none has been set, but otherwise leaving value alone.
|
||||
# NB: this doesn't allow "None" for the build type - would need something
|
||||
# more sophiticated using an internal cache variable.
|
||||
# Good enough for now!
|
||||
#
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
# Default to a Release build if nothing else...
|
||||
set(CMAKE_BUILD_TYPE Release
|
||||
CACHE STRING "Choose the type of build, options are: None Release TestRelease MinSizeRel Debug RelWithDebInfo MinSizeRel Maintainer."
|
||||
FORCE
|
||||
)
|
||||
else()
|
||||
# Force to the cache, but use existing value.
|
||||
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}"
|
||||
CACHE STRING "Choose the type of build, options are: None Release TestRelease MinSizeRel Debug RelWithDebInfo MinSizeRel Maintainer."
|
||||
FORCE
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,258 +0,0 @@
|
||||
# - Build Geant4Config.cmake file and support scripts for build and install.
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Collect all global variables we need to export to the config files
|
||||
# Do this here for now, later on we could collect them as we go.
|
||||
#
|
||||
|
||||
# Compiler flags (because user apps are a bit dependent on them...)
|
||||
set(GEANT4_COMPILER_FLAG_HINTS "#
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(Geant4_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${GEANT4_CXXSTD_FLAGS}\")
|
||||
set(Geant4_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\")")
|
||||
|
||||
foreach(_mode DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
|
||||
set(GEANT4_COMPILER_FLAG_HINTS "${GEANT4_COMPILER_FLAG_HINTS}
|
||||
set(Geant4_CXX_FLAGS_${_mode} \"${CMAKE_CXX_FLAGS_${_mode}}\")")
|
||||
endforeach()
|
||||
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(GEANT4_COMPILER_FLAG_HINTS "${GEANT4_COMPILER_FLAG_HINTS}
|
||||
set(Geant4_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")")
|
||||
endif()
|
||||
|
||||
# Core compile definitions...
|
||||
set(GEANT4_CORE_DEFINITIONS )
|
||||
|
||||
# Third party includes (libraries *should* be handled by the imports)
|
||||
set(GEANT4_THIRD_PARTY_INCLUDES )
|
||||
|
||||
# Imports of third party packages used with imported targets
|
||||
set(GEANT4_THIRD_PARTY_IMPORT_SETUP )
|
||||
|
||||
# Externals libraries that may be present
|
||||
set(GEANT4_EXTERNALS_TARGETS )
|
||||
|
||||
# - Stuff from Geant4LibraryBuildOptions.cmake
|
||||
if(GEANT4_BUILD_STORE_TRAJECTORY)
|
||||
list(APPEND GEANT4_CORE_DEFINITIONS -DG4_STORE_TRAJECTORY)
|
||||
endif()
|
||||
|
||||
if(GEANT4_BUILD_VERBOSE_CODE)
|
||||
list(APPEND GEANT4_CORE_DEFINITIONS -DG4VERBOSE)
|
||||
endif()
|
||||
|
||||
# - Stuff from Geant4OptionalComponents.cmake
|
||||
# - CLHEP
|
||||
# If it's internal, add it to the externals list
|
||||
if(NOT GEANT4_USE_SYSTEM_CLHEP)
|
||||
list(APPEND GEANT4_EXTERNALS_TARGETS G4clhep)
|
||||
endif()
|
||||
|
||||
# - Expat
|
||||
# If it's internal, add it to the externals list
|
||||
if(NOT GEANT4_USE_SYSTEM_EXPAT)
|
||||
list(APPEND GEANT4_EXTERNALS_TARGETS G4expat)
|
||||
endif()
|
||||
|
||||
# - ZLIB
|
||||
# If it's internal, add it to the externals list
|
||||
if(NOT GEANT4_USE_SYSTEM_ZLIB)
|
||||
list(APPEND GEANT4_EXTERNALS_TARGETS G4zlib)
|
||||
endif()
|
||||
|
||||
# - GDML
|
||||
# Need to include Xerces-C headers becuase these do appear in the public
|
||||
# interface of GDML. The library should then be in the LINK_INTERFACE of
|
||||
# persistency...
|
||||
if(GEANT4_USE_GDML)
|
||||
list(APPEND GEANT4_THIRD_PARTY_INCLUDES ${XERCESC_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# - USolids
|
||||
# Compile definitions
|
||||
if(GEANT4_USE_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
|
||||
set(GEANT4_USE_USOLIDS_EITHER ON)
|
||||
list(APPEND GEANT4_CORE_DEFINITIONS ${GEANT4_USOLIDS_COMPILE_DEFINITIONS})
|
||||
|
||||
# System USolids headers, because these do appear in Geant4's
|
||||
# public interface. The library should be in the link interface
|
||||
# of G4geometry (may need refinding)
|
||||
list(APPEND GEANT4_THIRD_PARTY_INCLUDES ${USOLIDS_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# - Stuff from Geant4InterfaceOptions.cmake
|
||||
if(GEANT4_USE_QT)
|
||||
list(APPEND GEANT4_THIRD_PARTY_INCLUDES
|
||||
${QT_INCLUDE_DIR}
|
||||
${QT_QTCORE_INCLUDE_DIR}
|
||||
${QT_QTGUI_INCLUDE_DIR}
|
||||
${QT_QTOPENGL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# On WIN32, re-import the Qt targets.
|
||||
if(WIN32)
|
||||
set(GEANT4_QT4_IMPORT_SETUP "
|
||||
# Qt reimport on WIN32
|
||||
set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE})
|
||||
set(QT_USE_IMPORTED_TARGETS ON)
|
||||
find_package(Qt4 REQUIRED)
|
||||
")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Generate Build Tree Configuration Files
|
||||
#-----------------------------------------------------------------------
|
||||
# Set needed variables for the build tree
|
||||
set(GEANT4_CMAKE_DIR "${PROJECT_BINARY_DIR}")
|
||||
|
||||
# Set include path for build tree. This is always an absolute path, or
|
||||
# rather paths. We extract the paths from the global
|
||||
# GEANT4_BUILDTREE_INCLUDE_DIRS property and use this to create the
|
||||
# header setup
|
||||
#
|
||||
get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
|
||||
GEANT4_BUILDTREE_INCLUDE_DIRS
|
||||
)
|
||||
|
||||
set(GEANT4_INCLUDE_DIR_SETUP "
|
||||
# Geant4 configured for use from the build tree - absolute paths are used.
|
||||
set(Geant4_INCLUDE_DIR ${__geant4_buildtree_include_dirs})
|
||||
")
|
||||
|
||||
set(GEANT4_MODULE_PATH_SETUP "
|
||||
# Geant4 configured for use CMake modules from source tree
|
||||
set(CMAKE_MODULE_PATH \${CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH})
|
||||
")
|
||||
|
||||
# Geant4 data used in build tree
|
||||
geant4_export_datasets(BUILD GEANT4_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Export targets from the build tree. We rely on the GEANT4_EXPORTED_TARGETS
|
||||
# global property to list these for us.
|
||||
#
|
||||
get_property(__geant4_exported_targets GLOBAL PROPERTY GEANT4_EXPORTED_TARGETS)
|
||||
|
||||
export(TARGETS ${__geant4_exported_targets}
|
||||
FILE ${PROJECT_BINARY_DIR}/Geant4LibraryDepends.cmake
|
||||
)
|
||||
|
||||
# Configure the build tree config file...
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4Config.cmake.in
|
||||
${PROJECT_BINARY_DIR}/Geant4Config.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Configure the build tree versioning file
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4ConfigVersion.cmake.in
|
||||
${PROJECT_BINARY_DIR}/Geant4ConfigVersion.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Copy the custom modules into the build tree
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules/CMakeMacroParseArguments.cmake
|
||||
${PROJECT_BINARY_DIR}/Modules/CMakeMacroParseArguments.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules/IntelCompileFeatures.cmake
|
||||
${PROJECT_BINARY_DIR}/Modules/IntelCompileFeatures.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
foreach(_mod AIDA CLHEP HepMC Pythia6 ROOT StatTest TBB)
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules/Find${_mod}.cmake
|
||||
${PROJECT_BINARY_DIR}/Modules/Find${_mod}.cmake
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# Copy the Main and Internal Use file into the build tree
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4.cmake
|
||||
${PROJECT_BINARY_DIR}/UseGeant4.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4_internal.cmake
|
||||
${PROJECT_BINARY_DIR}/UseGeant4_internal.cmake
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Generate Install Tree Configuration Files
|
||||
#-----------------------------------------------------------------------
|
||||
# Set needed variables for the install tree
|
||||
set(GEANT4_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION})
|
||||
|
||||
# Header path for install tree is dependent on whether we have a relocatable
|
||||
# install.
|
||||
if(CMAKE_INSTALL_IS_NONRELOCATABLE)
|
||||
# Use ABSOLUTE paths...
|
||||
set(GEANT4_INCLUDE_DIR_SETUP "
|
||||
# Geant4 configured for the install tree with absolute paths, so use these
|
||||
set(Geant4_INCLUDE_DIR \"${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4\")
|
||||
")
|
||||
else()
|
||||
# Use RELATIVE paths... Where we measure relative to GEANT4_CMAKE_DIR
|
||||
file(RELATIVE_PATH GEANT4_RELATIVE_HEADER_PATH
|
||||
${CMAKE_INSTALL_PREFIX}/${GEANT4_CMAKE_DIR}
|
||||
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
)
|
||||
|
||||
set(GEANT4_INCLUDE_DIR_SETUP "
|
||||
# Geant4 configured for the install with relative paths, so use these
|
||||
get_filename_component(Geant4_INCLUDE_DIR \"\${_geant4_thisdir}/${GEANT4_RELATIVE_HEADER_PATH}\" ABSOLUTE)
|
||||
")
|
||||
endif()
|
||||
|
||||
set(GEANT4_MODULE_PATH_SETUP)
|
||||
|
||||
# Geant4 data used in install tree
|
||||
geant4_export_datasets(INSTALL GEANT4_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Install exported targets file for the install tree - we just install
|
||||
# the named export
|
||||
install(EXPORT Geant4LibraryDepends
|
||||
DESTINATION ${GEANT4_CMAKE_DIR}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
# Configure the install tree config file...
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4Config.cmake.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4Config.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Configure the install tree config versioning file...
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/Geant4ConfigVersion.cmake.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4ConfigVersion.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install the config, config versioning and use files
|
||||
install(FILES
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4Config.cmake
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/Geant4ConfigVersion.cmake
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/UseGeant4.cmake
|
||||
DESTINATION ${GEANT4_CMAKE_DIR}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
# Install the custom modules for the examples
|
||||
install(DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/Modules
|
||||
DESTINATION ${GEANT4_CMAKE_DIR}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
@@ -1,347 +0,0 @@
|
||||
# - Script for configuring and installing geant4-config script
|
||||
#
|
||||
# The geant4-config script provides an sh based interface to provide
|
||||
# information on the Geant4 installation, including installation prefix,
|
||||
# version number, compiler and linker flags.
|
||||
#
|
||||
# The script is generated from a template file and then installed to the
|
||||
# known bindir as an executable.
|
||||
#
|
||||
# Paths are always hardcoded in the build tree version as this is never
|
||||
# intended to be relocatable.
|
||||
# The Install Tree script uses self-location based on that in
|
||||
# {root,clehep}-config is the install itself is relocatable, otherwise
|
||||
# absolute paths are encoded.
|
||||
#
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function get_system_include_dirs
|
||||
# return list of directories our C++ compiler searches
|
||||
# by default.
|
||||
#
|
||||
# The idea comes from CMake's inbuilt technique to do this
|
||||
# for the Eclipse and CodeBlocks generators, but we implement
|
||||
# our own function because the CMake functionality is internal
|
||||
# so we can't rely on it.
|
||||
function(get_system_include_dirs _dirs)
|
||||
# Only for GCC, Clang and Intel
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel)
|
||||
# Proceed
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/g4dummy" "\n")
|
||||
|
||||
# Save locale, them to "C" english locale so we can parse in English
|
||||
set(_orig_lc_all $ENV{LC_ALL})
|
||||
set(_orig_lc_messages $ENV{LC_MESSAGES})
|
||||
set(_orig_lang $ENV{LANG})
|
||||
|
||||
set(ENV{LC_ALL} C)
|
||||
set(ENV{LC_MESSAGES} C)
|
||||
set(ENV{LANG} C)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v -E -x c++ -dD g4dummy
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
|
||||
ERROR_VARIABLE _cxxOutput
|
||||
OUTPUT_VARIABLE _cxxStdout
|
||||
)
|
||||
|
||||
file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/g4dummy")
|
||||
|
||||
# Parse and extract search dirs
|
||||
set(_resultIncludeDirs )
|
||||
if( "${_cxxOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" )
|
||||
string(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}")
|
||||
foreach(nextLine ${_includeLines})
|
||||
string(REGEX REPLACE "\\(framework directory\\)" "" nextLineNoFramework "${nextLine}")
|
||||
string(STRIP "${nextLineNoFramework}" _includePath)
|
||||
list(APPEND _resultIncludeDirs "${_includePath}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Restore original locale
|
||||
set(ENV{LC_ALL} ${_orig_lc_all})
|
||||
set(ENV{LC_MESSAGES} ${_orig_lc_messages})
|
||||
set(ENV{LANG} ${_orig_lang})
|
||||
|
||||
set(${_dirs} ${_resultIncludeDirs} PARENT_SCOPE)
|
||||
else()
|
||||
set(${_dirs} "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Only create script if we have a global library build...
|
||||
#
|
||||
if(NOT GEANT4_BUILD_GRANULAR_LIBS AND UNIX)
|
||||
# Get implicit search paths
|
||||
get_system_include_dirs(_cxx_compiler_dirs)
|
||||
|
||||
# Setup variables needed for expansion in configuration file
|
||||
# - Static libs
|
||||
if(BUILD_STATIC_LIBS)
|
||||
set(G4_BUILTWITH_STATICLIBS "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_STATICLIBS "no")
|
||||
endif()
|
||||
|
||||
# - Multithreading
|
||||
if(GEANT4_BUILD_MULTITHREADED)
|
||||
set(G4_BUILTWITH_MULTITHREADING "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_MULTITHREADING "no")
|
||||
endif()
|
||||
|
||||
# - CLHEP
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
set(G4_BUILTWITH_CLHEP "no")
|
||||
#inc path
|
||||
get_filename_component(G4_SYSTEM_CLHEP_INCLUDE_DIR "${CLHEP_INCLUDE_DIR}" ABSOLUTE)
|
||||
|
||||
#libpath
|
||||
list(GET CLHEP_LIBRARIES 0 _zeroth_clhep_lib)
|
||||
get_target_property(_system_clhep_libdir "${_zeroth_clhep_lib}" LOCATION)
|
||||
get_filename_component(_system_clhep_libdir "${_system_clhep_libdir}" REALPATH)
|
||||
get_filename_component(_system_clhep_libdir "${_system_clhep_libdir}" DIRECTORY)
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES "-L${_system_clhep_libdir}")
|
||||
|
||||
foreach(_clhep_lib ${CLHEP_LIBRARIES})
|
||||
get_target_property(_curlib "${_clhep_lib}" LOCATION)
|
||||
get_filename_component(_curlib "${_curlib}" NAME)
|
||||
string(REGEX REPLACE "^lib(.*)\\.(so|a|dylib|lib|dll)$" "\\1" _curlib "${_curlib}")
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES} -l${_curlib}")
|
||||
endforeach()
|
||||
else()
|
||||
set(G4_BUILTWITH_CLHEP "yes")
|
||||
endif()
|
||||
|
||||
# - EXPAT
|
||||
if(GEANT4_USE_SYSTEM_EXPAT)
|
||||
set(G4_BUILTWITH_EXPAT "no")
|
||||
else()
|
||||
set(G4_BUILTWITH_EXPAT "yes")
|
||||
endif()
|
||||
|
||||
# - ZLIB
|
||||
if(GEANT4_USE_SYSTEM_ZLIB)
|
||||
set(G4_BUILTWITH_ZLIB "no")
|
||||
else()
|
||||
set(G4_BUILTWITH_ZLIB "yes")
|
||||
endif()
|
||||
|
||||
# - GDML
|
||||
if(GEANT4_USE_GDML)
|
||||
set(G4_BUILTWITH_GDML "yes")
|
||||
set(G4_XERCESC_INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS})
|
||||
list(REMOVE_DUPLICATES G4_XERCESC_INCLUDE_DIRS)
|
||||
list(REMOVE_ITEM G4_XERCESC_INCLUDE_DIRS ${_cxx_compiler_dirs})
|
||||
|
||||
set(G4_XERCESC_CFLAGS )
|
||||
foreach(_dir ${G4_XERCESC_INCLUDE_DIRS})
|
||||
set(G4_XERCESC_CFLAGS "${G4_XERCESC_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
else()
|
||||
set(G4_BUILTWITH_GDML "no")
|
||||
endif()
|
||||
|
||||
# - G3ToG4
|
||||
if(GEANT4_USE_G3TOG4)
|
||||
set(G4_BUILTWITH_G3TOG4 "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_G3TOG4 "no")
|
||||
endif()
|
||||
|
||||
# - USolids
|
||||
if(GEANT4_USE_USOLIDS OR GEANT4_USE_PARTIAL_USOLIDS)
|
||||
set(G4_BUILTWITH_USOLIDS "yes")
|
||||
set(G4_USOLIDS_INCLUDE_DIRS ${USOLIDS_INCLUDE_DIRS})
|
||||
list(REMOVE_DUPLICATES G4_USOLIDS_INCLUDE_DIRS)
|
||||
list(REMOVE_ITEM G4_USOLIDS_INCLUDE_DIRS ${_cxx_compiler_dirs})
|
||||
|
||||
string(REPLACE ";" " " G4_USOLIDS_CFLAGS "${GEANT4_USOLIDS_COMPILE_DEFINITIONS}")
|
||||
foreach(_dir ${G4_USOLIDS_INCLUDE_DIRS})
|
||||
set(G4_USOLIDS_CFLAGS "${G4_USOLIDS_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
else()
|
||||
set(G4_BUILTWITH_USOLIDS "no")
|
||||
endif()
|
||||
|
||||
# - Freetype
|
||||
if(GEANT4_USE_FREETYPE)
|
||||
set(G4_BUILTWITH_FREETYPE "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_FREETYPE "no")
|
||||
endif()
|
||||
|
||||
# - Qt
|
||||
if(GEANT4_USE_QT)
|
||||
set(G4_BUILTWITH_QT "yes")
|
||||
if(QT4_FOUND)
|
||||
set(G4_QT_INCLUDE_DIRS ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR})
|
||||
else()
|
||||
set(G4_QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES G4_QT_INCLUDE_DIRS)
|
||||
list(REMOVE_ITEM G4_QT_INCLUDE_DIRS ${_cxx_compiler_dirs})
|
||||
|
||||
set(G4_QT_CFLAGS )
|
||||
foreach(_dir ${G4_QT_INCLUDE_DIRS})
|
||||
set(G4_QT_CFLAGS "${G4_QT_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
set(G4_BUILTWITH_QT "no")
|
||||
endif()
|
||||
|
||||
# - Wt
|
||||
if(GEANT4_USE_WT)
|
||||
set(G4_BUILTWITH_WT "yes")
|
||||
set(G4_WT_INCLUDE_DIRS ${Wt_INCLUDE_DIR} ${Boost_INCLUDE_DIR} )
|
||||
|
||||
set(G4_WT_CFLAGS )
|
||||
foreach(_dir ${G4_WT_INCLUDE_DIRS})
|
||||
set(G4_WT_CFLAGS "${G4_WT_CFLAGS} -I${_dir}")
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
set(G4_BUILTWITH_WT "no")
|
||||
endif()
|
||||
|
||||
# - Motif
|
||||
if(GEANT4_USE_XM)
|
||||
set(G4_BUILTWITH_MOTIF "yes")
|
||||
set(G4_CONFIG_NEEDS_X11 TRUE)
|
||||
else()
|
||||
set(G4_BUILTWITH_MOTIF "no")
|
||||
endif()
|
||||
|
||||
# - RayTracerX
|
||||
if(GEANT4_USE_RAYTRACER_X11)
|
||||
set(G4_BUILTWITH_RAYTRACERX11 "yes")
|
||||
set(G4_CONFIG_NEEDS_X11 TRUE)
|
||||
else()
|
||||
set(G4_BUILTWITH_RAYTRACERX11 "no")
|
||||
endif()
|
||||
|
||||
# - OpenGL X11
|
||||
if(GEANT4_USE_OPENGL_X11)
|
||||
set(G4_BUILTWITH_OPENGLX11 "yes")
|
||||
set(G4_CONFIG_NEEDS_X11 TRUE)
|
||||
else()
|
||||
set(G4_BUILTWITH_OPENGLX11 "no")
|
||||
endif()
|
||||
|
||||
# - OpenInventor
|
||||
if(GEANT4_USE_INVENTOR)
|
||||
set(G4_BUILTWITH_INVENTOR "yes")
|
||||
else()
|
||||
set(G4_BUILTWITH_INVENTOR "no")
|
||||
endif()
|
||||
|
||||
# If we have a module that uses X11, We have to play with the X11
|
||||
# paths to get a clean set suitable for inclusion
|
||||
if(G4_CONFIG_NEEDS_X11)
|
||||
set(_raw_x11_includes ${X11_INCLUDE_DIR})
|
||||
list(REMOVE_DUPLICATES _raw_x11_includes)
|
||||
list(REMOVE_ITEM _raw_x11_includes ${_cxx_compiler_dirs})
|
||||
set(G4_X11_CFLAGS )
|
||||
foreach(_p ${_raw_x11_includes})
|
||||
set(G4_X11_CFLAGS "-I${_p} ${G4_X11_CFLAGS}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Configure the script
|
||||
# - BUILD TREE
|
||||
# Ouch, the include path will be LONG, but at least we always have
|
||||
# absolute paths...
|
||||
set(GEANT4_CONFIG_SELF_LOCATION "# BUILD TREE IS NON-RELOCATABLE")
|
||||
set(GEANT4_CONFIG_INSTALL_PREFIX "${PROJECT_BINARY_DIR}")
|
||||
set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
|
||||
# NB: this only works for *single* mode generators. With multimode
|
||||
# generators, which mode to use is not clear...
|
||||
set(GEANT4_CONFIG_LIBDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
|
||||
get_property(__geant4_buildtree_include_dirs GLOBAL PROPERTY
|
||||
GEANT4_BUILDTREE_INCLUDE_DIRS)
|
||||
|
||||
foreach(_dir ${__geant4_buildtree_include_dirs})
|
||||
set(GEANT4_CONFIG_INCLUDE_DIRS "${GEANT4_CONFIG_INCLUDE_DIRS} \\
|
||||
${_dir}")
|
||||
endforeach()
|
||||
|
||||
# - Data
|
||||
geant4_export_datasets(BUILD GEANT4_CONFIG_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Configure the build tree script
|
||||
# If we're on CMake 2.8 and above, we try to use file(COPY) to create an
|
||||
# executable script
|
||||
# Not sure if version check is o.k., but I'll be shocked if we ever see
|
||||
# a CMake 2.7 in the wild...
|
||||
if(${CMAKE_VERSION} VERSION_GREATER 2.7)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-config.in
|
||||
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
|
||||
@ONLY
|
||||
)
|
||||
|
||||
file(COPY
|
||||
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/geant4-config
|
||||
DESTINATION ${PROJECT_BINARY_DIR}
|
||||
FILE_PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
else()
|
||||
# Changing permissions is awkward, so just configure and document
|
||||
# that you have to do 'sh geant4-config' in this case.
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-config.in
|
||||
${PROJECT_BINARY_DIR}/geant4-config
|
||||
@ONLY
|
||||
)
|
||||
endif()
|
||||
|
||||
# - Install Tree
|
||||
# Much easier :-)
|
||||
# Non-Relocatable case...
|
||||
if(CMAKE_INSTALL_IS_NONRELOCATABLE)
|
||||
# Hardcoded paths
|
||||
set(GEANT4_CONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
|
||||
set(GEANT4_CONFIG_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
set(GEANT4_CONFIG_INCLUDE_DIRS "${CMAKE_INSTALL_FULL_INCLUDEDIR}/Geant4")
|
||||
else()
|
||||
# Calculate base of self contained install based on relative path from
|
||||
# CMAKE_INSTALL_FULL_BINDIR to CMAKE_INSTALL_PREFIX.
|
||||
file(RELATIVE_PATH _bin_to_prefix ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_PREFIX})
|
||||
# Strip any trailing path separators just for neatness.
|
||||
string(REGEX REPLACE "[/\\]$" "" _bin_to_prefix "${_bin_to_prefix}")
|
||||
|
||||
set(GEANT4_CONFIG_INSTALL_PREFIX "$scriptloc/${_bin_to_prefix}")
|
||||
set(GEANT4_CONFIG_INSTALL_EXECPREFIX \"\")
|
||||
set(GEANT4_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(GEANT4_CONFIG_INCLUDE_DIRS "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/Geant4")
|
||||
endif()
|
||||
|
||||
# - Data
|
||||
geant4_export_datasets(INSTALL GEANT4_CONFIG_DATASET_DESCRIPTIONS)
|
||||
|
||||
# Configure the install tree script
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-config.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install it
|
||||
install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-config
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Development
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
# - Script for configuring and installing a Modulefile for Geant4
|
||||
#
|
||||
# Environment Modules is a standard tool for configuring the environment
|
||||
# for a package in a shell/intepreter agnostic way. See:
|
||||
#
|
||||
# http://modules.sourceforge.net/
|
||||
#
|
||||
# As with other Geant4 tool support, a template file is provided to
|
||||
# generate the modulefile using the known build settings. Though
|
||||
# modulefiles are generally only used for installed packages, modulefiles
|
||||
# are generated for both the Build and Install Trees.
|
||||
#
|
||||
# The resultant modulefile for the Build Tree is only provided on an
|
||||
# 'as is' basis. It is intended for Geant4 developers only, and is
|
||||
# otherwise unsupported.
|
||||
#
|
||||
# The resultant modulefile for the Install Tree is installed to the
|
||||
# share directory, though this is not intended to be its final location.
|
||||
# System Admins may wish to move the file to their local modulefile path.
|
||||
# Absolute paths to the install of Geant4 are used to help move the
|
||||
# modulefile around, so if both modulefile and install of Geant4 are
|
||||
# moved, the paths in the modulefile should be patched/sedded.
|
||||
#
|
||||
|
||||
macro(_geant4_prepare_modulefile_inputs)
|
||||
cmake_parse_arguments(GPI
|
||||
""
|
||||
"MODE"
|
||||
""
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
# - Paths
|
||||
if("${GPI_MODE}" STREQUAL "INSTALL")
|
||||
set(GEANT4_MODULEFILE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(GEANT4_MODULEFILE_INSTALL_BINDIR "${CMAKE_INSTALL_FULL_BINDIR}")
|
||||
set(GEANT4_MODULEFILE_INSTALL_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
geant4_export_datasets(INSTALL GEANT4_EXPORTED_DATASETS)
|
||||
else()
|
||||
set(GEANT4_MODULEFILE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}")
|
||||
set(GEANT4_MODULEFILE_INSTALL_BINDIR "${PROJECT_BINARY_DIR}")
|
||||
set(GEANT4_MODULEFILE_INSTALL_LIBDIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
geant4_export_datasets(BUILD GEANT4_EXPORTED_DATASETS)
|
||||
endif()
|
||||
|
||||
# - Compatibility
|
||||
if(APPLE)
|
||||
set(DYNAMIC_LOADER_PATHNAME "DYLD_LIBRARY_PATH")
|
||||
else()
|
||||
set(DYNAMIC_LOADER_PATHNAME "LD_LIBRARY_PATH")
|
||||
endif()
|
||||
|
||||
# - Datasets
|
||||
set(G4DATASET_TCLLIST)
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
# listify tuple
|
||||
string(REPLACE "|" ";" _ds "${_ds}")
|
||||
# Extract envar and path entries
|
||||
list(GET _ds 1 _ds_ENVVAR)
|
||||
list(GET _ds 2 _ds_PATH)
|
||||
set(G4DATASET_TCLLIST "${G4DATASET_TCLLIST} ${_ds_ENVVAR} ${_ds_PATH}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
function(geant4_configure_modulefile)
|
||||
# Install Tree
|
||||
# - prepare configuration environment
|
||||
_geant4_prepare_modulefile_inputs(MODE INSTALL)
|
||||
|
||||
# - Configure the file
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-modulefile.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-${Geant4_VERSION}
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# - Install it
|
||||
install(FILES ${PROJECT_BINARY_DIR}/InstallTreeFiles/geant4-${Geant4_VERSION}
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}
|
||||
COMPONENT Development
|
||||
)
|
||||
|
||||
# Build Tree
|
||||
# - prepare configuration environment
|
||||
_geant4_prepare_modulefile_inputs()
|
||||
|
||||
# - Configure the file
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/geant4-modulefile.in
|
||||
${PROJECT_BINARY_DIR}/geant4-${Geant4_VERSION}
|
||||
@ONLY
|
||||
)
|
||||
endfunction()
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
# - Define standard installation directories for Geant4
|
||||
# Provides install directory variables as defined for GNU software:
|
||||
# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
|
||||
# Inclusion of this module defines the following variables:
|
||||
# CMAKE_INSTALL_<dir> - destination for files of a given type
|
||||
# CMAKE_INSTALL_FULL_<dir> - corresponding absolute path
|
||||
# where <dir> is one of:
|
||||
# BINDIR - user executables (bin)
|
||||
# LIBDIR - object code libraries (lib or lib64)
|
||||
# INCLUDEDIR - C header files (include)
|
||||
# DATAROOTDIR - read-only architecture-independent data root (share)
|
||||
# DATADIR - read-only architecture-independent data (DATAROOTDIR)
|
||||
# MANDIR - man documentation (DATAROOTDIR/man)
|
||||
# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME)
|
||||
# Each CMAKE_INSTALL_<dir> value may be passed to the DESTINATION options
|
||||
# of install() commands for the corresponding file type. If the includer
|
||||
# does not define a value the above-shown default will be used and the
|
||||
# value will appear in the cache for editing by the user.
|
||||
# If any of these values are absolute paths, the install of Geant4 is
|
||||
# regarded as non-relocatable, and the variable:
|
||||
# CMAKE_INSTALL_IS_NONRELOCATABLE
|
||||
# will be set.
|
||||
# Each CMAKE_INSTALL_FULL_<dir> value contains an absolute path constructed
|
||||
# from the corresponding destination by prepending (if necessary) the value
|
||||
# of CMAKE_INSTALL_PREFIX.
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2011 Nikita Krupen'ko <krnekit@gmail.com>
|
||||
# Copyright 2011 Kitware, Inc.
|
||||
#
|
||||
# CMake - Cross Platform Makefile Generator
|
||||
# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||
# nor the names of their contributors may be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# The above copyright and license notice applies to distributions of
|
||||
# CMake in source and binary form. Some source files contain additional
|
||||
# notices of original copyright by their contributors; see each source
|
||||
# for details. Third-party software packages supplied with CMake under
|
||||
# compatible licenses provide their own copyright notices documented in
|
||||
# corresponding subdirectories.
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# CMake was initially developed by Kitware with the following sponsorship:
|
||||
#
|
||||
# * National Library of Medicine at the National Institutes of Health
|
||||
# as part of the Insight Segmentation and Registration Toolkit (ITK).
|
||||
#
|
||||
# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
|
||||
# Visualization Initiative.
|
||||
#
|
||||
# * National Alliance for Medical Image Computing (NAMIC) is funded by the
|
||||
# National Institutes of Health through the NIH Roadmap for Medical Research,
|
||||
# Grant U54 EB005149.
|
||||
#
|
||||
# * Kitware, Inc.
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
# Installation directories
|
||||
#
|
||||
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(_LIBDIR_DEFAULT "lib")
|
||||
# Override this default 'lib' with 'lib64' iff:
|
||||
# - we are on Linux system but NOT cross-compiling
|
||||
# - we are NOT on debian
|
||||
# - we are on a 64 bits system
|
||||
# reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
|
||||
# Note that the future of multi-arch handling may be even
|
||||
# more complicated than that: http://wiki.debian.org/Multiarch
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux"
|
||||
AND NOT CMAKE_CROSSCOMPILING
|
||||
AND NOT EXISTS "/etc/debian_version")
|
||||
if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
|
||||
message(AUTHOR_WARNING
|
||||
"Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
|
||||
"Please enable at least one language before including GNUInstallDirs.")
|
||||
else()
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
set(_LIBDIR_DEFAULT "lib64")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
|
||||
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
|
||||
set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Values whose defaults are relative to DATAROOTDIR.
|
||||
# Store empty values in the cache and store the defaults in local
|
||||
# variables if the cache values are not set explicitly. This auto-updates
|
||||
# the defaults as DATAROOTDIR changes.
|
||||
#
|
||||
if(NOT CMAKE_INSTALL_DATADIR)
|
||||
set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
|
||||
set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_MANDIR)
|
||||
set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
|
||||
set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_DOCDIR)
|
||||
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
|
||||
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
CMAKE_INSTALL_BINDIR
|
||||
CMAKE_INSTALL_LIBDIR
|
||||
CMAKE_INSTALL_INCLUDEDIR
|
||||
CMAKE_INSTALL_DATAROOTDIR
|
||||
CMAKE_INSTALL_DATADIR
|
||||
CMAKE_INSTALL_MANDIR
|
||||
CMAKE_INSTALL_DOCDIR
|
||||
)
|
||||
|
||||
# Result directories
|
||||
#
|
||||
foreach(dir
|
||||
BINDIR
|
||||
LIBDIR
|
||||
INCLUDEDIR
|
||||
DATAROOTDIR
|
||||
DATADIR
|
||||
MANDIR
|
||||
DOCDIR
|
||||
)
|
||||
if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
|
||||
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
|
||||
set(CMAKE_INSTALL_IS_NONRELOCATABLE 1)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -1,366 +0,0 @@
|
||||
# - Setup of general build options for Geant4 Libraries
|
||||
#
|
||||
# In addition to the core compiler/linker flags (configured in the
|
||||
# Geant4MakeRules_<LANG>.cmake files) for Geant4, the build may require
|
||||
# further configuration. This module performs this task whicj includes:
|
||||
#
|
||||
# 1) Extra build modes for developers
|
||||
# 2) Additional compiler definitions to assist visualization or optimize
|
||||
# performance.
|
||||
# 3) Additional compiler flags which may be added optionally.
|
||||
# 4) Whether to build shared and/or static libraries.
|
||||
# 5) Whether to build libraries in global or granular format.
|
||||
#
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Load needed modules
|
||||
#
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(IntelCompileFeatures)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Set up Build types or configurations
|
||||
# If further tuning of compiler flags is needed then it should be done here.
|
||||
# (It can't be done in the make rules override section).
|
||||
# However, exercise care when doing this not to override existing flags!!
|
||||
# We don't do this on WIN32 platforms yet because of some teething issues
|
||||
# with compiler specifics and linker flags
|
||||
if(NOT WIN32)
|
||||
include(Geant4BuildModes)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Provide optional file level parallelization with MSVC compiler
|
||||
# NB: This will only work if the build tool performs compilations
|
||||
# with multiple sources, e.g. "cl.exe a.cc b.cc c.cc"
|
||||
if(MSVC)
|
||||
option(GEANT4_BUILD_MSVC_MP "Use /MP option with MSVC for file level parallel builds" OFF)
|
||||
mark_as_advanced(GEANT4_BUILD_MSVC_MP)
|
||||
|
||||
if(GEANT4_BUILD_MSVC_MP)
|
||||
set(CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure/Select C++ Standard
|
||||
# Require at least C++11 with no extensions and the following features
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(GEANT4_TARGET_COMPILE_FEATURES
|
||||
cxx_alias_templates
|
||||
cxx_auto_type
|
||||
cxx_delegating_constructors
|
||||
cxx_enum_forward_declarations
|
||||
cxx_explicit_conversions
|
||||
cxx_final
|
||||
cxx_lambdas
|
||||
cxx_nullptr
|
||||
cxx_override
|
||||
cxx_range_for
|
||||
cxx_strong_enums
|
||||
cxx_uniform_initialization
|
||||
# Features that MSVC 18.0 cannot support but in list of Geant4 coding
|
||||
# guidelines - to be required once support for that compiler is dropped.
|
||||
# Version 10.2 is coded without these being required.
|
||||
#cxx_deleted_functions
|
||||
#cxx_generalized_initializers
|
||||
#cxx_constexpr
|
||||
#cxx_inheriting_constructors
|
||||
)
|
||||
|
||||
# - GEANT4_BUILD_CXXSTD
|
||||
# Choose C++ Standard to build against from supported list. Allow user
|
||||
# to supply it as a simple year or as 'c++XY'. If the latter, post process
|
||||
# to remove the 'c++'
|
||||
# Mark as advanced because most users will not need it
|
||||
enum_option(GEANT4_BUILD_CXXSTD
|
||||
DOC "C++ Standard to compile against"
|
||||
VALUES 11 14 c++11 c++14
|
||||
CASE_INSENSITIVE
|
||||
)
|
||||
|
||||
string(REGEX REPLACE "^c\\+\\+" "" GEANT4_BUILD_CXXSTD "${GEANT4_BUILD_CXXSTD}")
|
||||
mark_as_advanced(GEANT4_BUILD_CXXSTD)
|
||||
geant4_add_feature(GEANT4_BUILD_CXXSTD "Compiling against C++ Standard '${GEANT4_BUILD_CXXSTD}'")
|
||||
|
||||
# If a standard higher than 11 has been selected, check that compiler has
|
||||
# at least one feature from that standard and append these to the required
|
||||
# feature list
|
||||
if(GEANT4_BUILD_CXXSTD GREATER 11)
|
||||
if(CMAKE_CXX${GEANT4_BUILD_CXXSTD}_COMPILE_FEATURES)
|
||||
list(APPEND GEANT4_TARGET_COMPILE_FEATURES ${CMAKE_CXX${GEANT4_BUILD_CXXSTD}_COMPILE_FEATURES})
|
||||
else()
|
||||
message(FATAL_ERROR "Geant4 requested to be compiled against C++ standard '${GEANT4_BUILD_CXXSTD}'\nbut detected compiler '${CMAKE_CXX_COMPILER_ID}', version '${CMAKE_CXX_COMPILER_VERSION}'\ndoes not support any features of that standard")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - Check for Standard Library Implementation Features
|
||||
# Smart pointers are a library implementation feature
|
||||
# Hashed containers are a library implementation feature
|
||||
# Random numbers are a library implementation feature?
|
||||
# - Thread local? Yes, though on AppleClang platforms, see this:
|
||||
#http://stackoverflow.com/questions/28094794/why-does-apple-clang-disallow-c11-thread-local-when-official-clang-supports
|
||||
# An example of where a workaround is needed
|
||||
# Rest of concurrency a library implementation feature
|
||||
|
||||
# Add Definition to flags for temporary back compatibility
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DG4USE_STD11")
|
||||
|
||||
# Hold any appropriate compile flag(s) in variable for later export to
|
||||
# config files. Needed to support late CMake 2.8 where compile features
|
||||
# are not available.
|
||||
set(GEANT4_CXXSTD_FLAGS "${CMAKE_CXX${GEANT4_BUILD_CXXSTD}_STANDARD_COMPILE_OPTION}")
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Optional compiler definitions which are applicable globally
|
||||
#
|
||||
# - G4MULTITHREADED
|
||||
# OFF by default. Switching on will enable multithreading, adding the
|
||||
# G4MULTITHREADED definition globally and appending the relevant
|
||||
# compiler flags to CMAKE_CXX_FLAGS
|
||||
# Enabling the option allows advanced users to further select the
|
||||
# thread local storage model if GNU/Clang/Intel compiler is used.
|
||||
option(GEANT4_BUILD_MULTITHREADED "Enable multithreading in Geant4" OFF)
|
||||
|
||||
if(WIN32)
|
||||
mark_as_advanced(GEANT4_BUILD_MULTITHREADED)
|
||||
endif()
|
||||
|
||||
if(GEANT4_BUILD_MULTITHREADED)
|
||||
# - Need Thread Local Storage support (POSIX)
|
||||
if(UNIX)
|
||||
check_cxx_source_compiles("__thread int i; int main(){return 0;}" HAVE_TLS)
|
||||
if(NOT HAVE_TLS)
|
||||
message(FATAL_ERROR "Configured compiler ${CMAKE_CXX_COMPILER} does not support thread local storage")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - Emit warning on Windows - message will format oddly on CMake prior
|
||||
# to 2.8, but still print
|
||||
if(WIN32)
|
||||
message(WARNING "GEANT4_BUILD_MULTITHREADED IS NOT SUPPORTED on Win32. This option should only be activated by developers")
|
||||
endif()
|
||||
|
||||
# - Allow advanced users to select the thread local storage model,
|
||||
# if the compiler supports it, defaulting to that recommended by Geant4
|
||||
if(TLSMODEL_IS_AVAILABLE)
|
||||
enum_option(GEANT4_BUILD_TLS_MODEL
|
||||
DOC "Build libraries with Thread Local Storage model"
|
||||
VALUES ${TLSMODEL_IS_AVAILABLE}
|
||||
CASE_INSENSITIVE
|
||||
)
|
||||
mark_as_advanced(GEANT4_BUILD_TLS_MODEL)
|
||||
geant4_add_feature(GEANT4_BUILD_TLS_MODEL "Building with TLS model '${GEANT4_BUILD_TLS_MODEL}'")
|
||||
|
||||
set(GEANT4_MULTITHREADED_CXX_FLAGS "${GEANT4_MULTITHREADED_CXX_FLAGS} ${${GEANT4_BUILD_TLS_MODEL}_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Set Defs/Compiler Flags
|
||||
add_definitions(-DG4MULTITHREADED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GEANT4_MULTITHREADED_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
geant4_add_feature(GEANT4_BUILD_MULTITHREADED "Build multithread enabled libraries")
|
||||
|
||||
# - G4_STORE_TRAJECTORY
|
||||
# ON by default, switching off can improve performance. Needs to be on
|
||||
# for visualization to work fully. Mark as advanced because most users
|
||||
# should not need to worry about it.
|
||||
# FIXES : Bug #1208
|
||||
option(GEANT4_BUILD_STORE_TRAJECTORY
|
||||
"Store trajectories in event processing. Switch off for improved performance but note that visualization of trajectories will not be possible"
|
||||
ON)
|
||||
mark_as_advanced(GEANT4_BUILD_STORE_TRAJECTORY)
|
||||
|
||||
if(GEANT4_BUILD_STORE_TRAJECTORY)
|
||||
add_definitions(-DG4_STORE_TRAJECTORY)
|
||||
endif()
|
||||
|
||||
# - G4VERBOSE
|
||||
# ON by default, switching off can improve performance, but at the cost
|
||||
# of fewer informational or warning messages. Mark as advanced because
|
||||
# most users should not need to worry about it.
|
||||
option(GEANT4_BUILD_VERBOSE_CODE
|
||||
"Enable verbose output from Geant4 code. Switch off for better performance at the cost of fewer informational messages or warnings"
|
||||
ON)
|
||||
mark_as_advanced(GEANT4_BUILD_VERBOSE_CODE)
|
||||
|
||||
if(GEANT4_BUILD_VERBOSE_CODE)
|
||||
add_definitions(-DG4VERBOSE)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Setup Library Format Option.
|
||||
# Always build global libraries - always FATAL_ERROR if old
|
||||
# granular library switch is set, e.g. from command line
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
message(FATAL_ERROR " Granular libraries are no longer supported!")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Setup Shared and/or Static Library builds
|
||||
# We name these options without a 'GEANT4_' prefix because they are
|
||||
# really higher level CMake options.
|
||||
# Default to building shared libraries, mark options as advanced because
|
||||
# most user should not have to touch them.
|
||||
option(BUILD_SHARED_LIBS "Build Geant4 shared libraries" ON)
|
||||
option(BUILD_STATIC_LIBS "Build Geant4 static libraries" OFF)
|
||||
mark_as_advanced(BUILD_SHARED_LIBS BUILD_STATIC_LIBS)
|
||||
|
||||
# Because both could be switched off accidently, FATAL_ERROR if neither
|
||||
# option has been selected.
|
||||
if(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "Neither static nor shared libraries will be built")
|
||||
endif()
|
||||
|
||||
# On WIN32, we need to build the genwindef application to create export
|
||||
# def files for building DLLs.
|
||||
# We only use it as a helper application at the moment so we exclude it from
|
||||
# the ALL target.
|
||||
# TODO: We could move this section into the Geant4MacroLibraryTargets.cmake
|
||||
# if it can be protected so that the genwindef target wouldn't be defined
|
||||
# more than once... Put it here for now...
|
||||
if(WIN32)
|
||||
# Assume the sources are co-located
|
||||
get_filename_component(_genwindef_src_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
add_executable(genwindef EXCLUDE_FROM_ALL
|
||||
${_genwindef_src_dir}/genwindef/genwindef.cpp
|
||||
${_genwindef_src_dir}/genwindef/LibSymbolInfo.h
|
||||
${_genwindef_src_dir}/genwindef/LibSymbolInfo.cpp)
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Setup symbol visibility (library interface)
|
||||
# We need to define that we're building Geant4
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Optional build of examples - only intended for testing
|
||||
#
|
||||
option(GEANT4_BUILD_EXAMPLES "Build all the examples of the project" OFF)
|
||||
GEANT4_ADD_FEATURE(GEANT4_BUILD_EXAMPLES "Build all the examples of the project")
|
||||
mark_as_advanced(GEANT4_BUILD_EXAMPLES)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Integration and unit tests
|
||||
# - "ENABLE_TESTING" means all tests under tests/
|
||||
option(GEANT4_ENABLE_TESTING "Enable and define all the tests of the project" OFF)
|
||||
GEANT4_ADD_FEATURE(GEANT4_ENABLE_TESTING "Enable and define all the tests of the project")
|
||||
mark_as_advanced(GEANT4_ENABLE_TESTING)
|
||||
|
||||
# - "BUILD_TESTS" means all 'tests' in individual categories.
|
||||
option(GEANT4_BUILD_TESTS "Build all the tests of the project" OFF)
|
||||
GEANT4_ADD_FEATURE(GEANT4_BUILD_TESTS "Build all the tests of the project")
|
||||
mark_as_advanced(GEANT4_BUILD_TESTS)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Setup Locations for Build Outputs
|
||||
# Because of the highly nested structure of Geant4, targets will be
|
||||
# distributed throughout this tree, potentially making usage and debugging
|
||||
# difficult (especially if developers use non-CMake tools).
|
||||
#
|
||||
# We therefore set the output directory of runtime, library and archive
|
||||
# targets to some low level directories under the build tree.
|
||||
#
|
||||
# On Unices, we try to make the output directory backward compatible
|
||||
# with the old style 'SYSTEM-COMPILER' format so that applications may be
|
||||
# built against the targets in the build tree.
|
||||
#
|
||||
# Note that for multi-configuration generators like VS and Xcode, these
|
||||
# directories will have the configuration type (e.g. Debug) appended to
|
||||
# them, so are not backward compatible with the old Make toolchain in
|
||||
# these cases.
|
||||
#
|
||||
# Also, we only do this on UNIX because we want to avoid mixing static and
|
||||
# dynamic libraries on windows until the differences are better understood.
|
||||
#------------------------------------------------------------------------
|
||||
# Determine the backward compatible system name
|
||||
#
|
||||
if(NOT WIN32)
|
||||
set(GEANT4_SYSTEM ${CMAKE_SYSTEM_NAME})
|
||||
else()
|
||||
set(GEANT4_SYSTEM "WIN32")
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Determine the backward compatible compiler name
|
||||
# NB: At present Clang detection only works on CMake > 2.8.1
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(GEANT4_COMPILER "g++")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
set(GEANT4_COMPILER "clang")
|
||||
|
||||
# - Newer g++ on OS X may identify as Clang
|
||||
if(APPLE AND (CMAKE_CXX_COMPILER MATCHES ".*g\\+\\+"))
|
||||
set(GEANT4_COMPILER "g++")
|
||||
endif()
|
||||
|
||||
elseif(MSVC)
|
||||
set(GEANT4_COMPILER "VC")
|
||||
elseif(CMAKE_CXX_COMPILER MATCHES "icpc.*|icc.*")
|
||||
set(GEANT4_COMPILER "icc")
|
||||
else()
|
||||
set(GEANT4_COMPILER "UNSUPPORTED")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Set the output paths to be backward compatible on UNIX
|
||||
# - Check that install dirs have been defined as we want to match the
|
||||
# output layout!
|
||||
if((NOT DEFINED CMAKE_INSTALL_BINDIR) OR (NOT DEFINED CMAKE_INSTALL_LIBDIR))
|
||||
message(FATAL_ERROR "Cannot configure build output dirs as install directories have not yet been defined")
|
||||
endif()
|
||||
|
||||
# - Single root dir of all products
|
||||
set(BASE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/BuildProducts")
|
||||
|
||||
# - Default outputs for different products, will be used by single mode
|
||||
# generators. Creates the structure:
|
||||
#
|
||||
# BuildProducts/
|
||||
# +- bin/
|
||||
# +- lib/
|
||||
# +- <GEANT4_SYSTEM>-<GEANT4_COMPILER> -> symlink -> .
|
||||
#
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_INSTALL_BINDIR}")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
# - Create libdir/softlink to fool geant4make, but only for single mode case
|
||||
if(UNIX AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink . ${GEANT4_SYSTEM}-${GEANT4_COMPILER}
|
||||
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# - For multiconfig generators, we create the same structure once for each
|
||||
# mode. Results in the structure:
|
||||
#
|
||||
# BuildProducts/
|
||||
# +- Release/
|
||||
# | +- bin/
|
||||
# | +- lib/
|
||||
# +- Debug/
|
||||
# | +- bin/
|
||||
# | +- lib/
|
||||
# | ...
|
||||
#
|
||||
foreach(_conftype ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${_conftype} _conftype_uppercase)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${_conftype_uppercase}
|
||||
"${BASE_OUTPUT_DIRECTORY}/${_conftype}/${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${_conftype_uppercase}
|
||||
"${BASE_OUTPUT_DIRECTORY}/${_conftype}/${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${_conftype_uppercase}
|
||||
"${BASE_OUTPUT_DIRECTORY}/${_conftype}/${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
# Geant4MacroUtilities - useful macros and functions for generic tasks
|
||||
#
|
||||
# CMake Extensions
|
||||
# ----------------
|
||||
# macro set_ifnot(<var> <value>)
|
||||
# If variable var is not set, set its value to that provided
|
||||
#
|
||||
# function enum_option(<option>
|
||||
# VALUES <value1> ... <valueN>
|
||||
# TYPE <valuetype>
|
||||
# DOC <docstring>
|
||||
# [DEFAULT <elem>]
|
||||
# [CASE_INSENSITIVE])
|
||||
# Declare a cache variable <option> that can only take values
|
||||
# listed in VALUES. TYPE may be FILEPATH, PATH or STRING.
|
||||
# <docstring> should describe that option, and will appear in
|
||||
# the interactive CMake interfaces. If DEFAULT is provided,
|
||||
# <elem> will be taken as the zero-indexed element in VALUES
|
||||
# to which the value of <option> should default to if not
|
||||
# provided. Otherwise, the default is taken as the first
|
||||
# entry in VALUES. If CASE_INSENSITIVE is present, then
|
||||
# checks of the value of <option> against the allowed values
|
||||
# will ignore the case when performing string comparison.
|
||||
#
|
||||
#
|
||||
# General Geant4
|
||||
# --------------
|
||||
# function geant4_add_feature(<NAME> <DOCSTRING>)
|
||||
# Add a Geant4 feature, whose activation is specified by the
|
||||
# existence of the variable <NAME>, to the list of enabled/disabled
|
||||
# features, plus a docstring describing the feature
|
||||
#
|
||||
# function geant4_print_enabled_features()
|
||||
# Print enabled Geant4 features plus their docstrings.
|
||||
#
|
||||
# Datasets
|
||||
# --------
|
||||
# TODO: Move to dedicated datasets module
|
||||
# function geant4_latest_version(<dir> <name> <output variable>)
|
||||
# Locate latest version of dataset <name> in <dir>, setting value
|
||||
# of output variable to the full path to the dataset
|
||||
#
|
||||
# Testing
|
||||
# -------
|
||||
# TODO: Move to dedicated tests module
|
||||
# function geant4_add_unit_tests(test1 test2 ... [dir1 ...]
|
||||
# INCLUDE_DIRS dir1 dir2 ...
|
||||
# LIBRARIES library1 library2 ...)
|
||||
#
|
||||
|
||||
# - Include guard
|
||||
if(__geant4macroutilities_isloaded)
|
||||
return()
|
||||
endif()
|
||||
set(__geant4macroutilities_isloaded YES)
|
||||
|
||||
include(Geant4MacroDefineModule)
|
||||
include(Geant4MacroLibraryTargets)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# CMAKE EXTENSIONS
|
||||
#-----------------------------------------------------------------------
|
||||
# macro set_ifnot(<var> <value>)
|
||||
# If variable var is not set, set its value to that provided
|
||||
#
|
||||
macro(set_ifnot _var _value)
|
||||
if(NOT ${_var})
|
||||
set(${_var} ${_value})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function enum_option(<option>
|
||||
# VALUES <value1> ... <valueN>
|
||||
# TYPE <valuetype>
|
||||
# DOC <docstring>
|
||||
# [DEFAULT <elem>]
|
||||
# [CASE_INSENSITIVE])
|
||||
# Declare a cache variable <option> that can only take values
|
||||
# listed in VALUES. TYPE may be FILEPATH, PATH or STRING.
|
||||
# <docstring> should describe that option, and will appear in
|
||||
# the interactive CMake interfaces. If DEFAULT is provided,
|
||||
# <elem> will be taken as the zero-indexed element in VALUES
|
||||
# to which the value of <option> should default to if not
|
||||
# provided. Otherwise, the default is taken as the first
|
||||
# entry in VALUES. If CASE_INSENSITIVE is present, then
|
||||
# checks of the value of <option> against the allowed values
|
||||
# will ignore the case when performing string comparison.
|
||||
#
|
||||
function(enum_option _var)
|
||||
set(options CASE_INSENSITIVE)
|
||||
set(oneValueArgs DOC TYPE DEFAULT)
|
||||
set(multiValueArgs VALUES)
|
||||
cmake_parse_arguments(_ENUMOP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# - Validation as needed arguments
|
||||
if(NOT _ENUMOP_VALUES)
|
||||
message(FATAL_ERROR "enum_option must be called with non-empty VALUES\n(Called for enum_option '${_var}')")
|
||||
endif()
|
||||
|
||||
# - Set argument defaults as needed
|
||||
if(_ENUMOP_CASE_INSENSITIVE)
|
||||
set(_ci_values )
|
||||
foreach(_elem ${_ENUMOP_VALUES})
|
||||
string(TOLOWER "${_elem}" _ci_elem)
|
||||
list(APPEND _ci_values "${_ci_elem}")
|
||||
endforeach()
|
||||
set(_ENUMOP_VALUES ${_ci_values})
|
||||
endif()
|
||||
|
||||
set_ifnot(_ENUMOP_TYPE STRING)
|
||||
set_ifnot(_ENUMOP_DEFAULT 0)
|
||||
list(GET _ENUMOP_VALUES ${_ENUMOP_DEFAULT} _default)
|
||||
|
||||
if(NOT DEFINED ${_var})
|
||||
set(${_var} ${_default} CACHE ${_ENUMOP_TYPE} "${_ENUMOP_DOC} (${_ENUMOP_VALUES})")
|
||||
else()
|
||||
set(_var_tmp ${${_var}})
|
||||
if(_ENUMOP_CASE_INSENSITIVE)
|
||||
string(TOLOWER ${_var_tmp} _var_tmp)
|
||||
endif()
|
||||
|
||||
list(FIND _ENUMOP_VALUES ${_var_tmp} _elem)
|
||||
if(_elem LESS 0)
|
||||
message(FATAL_ERROR "Value '${${_var}}' for variable ${_var} is not allowed\nIt must be selected from the set: ${_ENUMOP_VALUES} (DEFAULT: ${_default})\n")
|
||||
else()
|
||||
# - convert to lowercase
|
||||
if(_ENUMOP_CASE_INSENSITIVE)
|
||||
set(${_var} ${_var_tmp} CACHE ${_ENUMOP_TYPE} "${_ENUMOP_DOC} (${_ENUMOP_VALUES})" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GENERAL GEANT4
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_add_feature(<NAME> <DOCSTRING>)
|
||||
# Add a Geant4 feature, whose activation is specified by the
|
||||
# existence of the variable <NAME>, to the list of enabled/disabled
|
||||
# features, plus a docstring describing the feature
|
||||
#
|
||||
function(GEANT4_ADD_FEATURE _var _description)
|
||||
if(${_var})
|
||||
set_property(GLOBAL APPEND PROPERTY GEANT4_ENABLED_FEATURES ${_var})
|
||||
else()
|
||||
set_property(GLOBAL APPEND PROPERTY GEANT4_DISABLED_FEATURES ${_var})
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY ${_var}_DESCRIPTION "${_description}")
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_print_enabled_features()
|
||||
# Print enabled Geant4 features plus their docstrings.
|
||||
#
|
||||
function(geant4_print_enabled_features)
|
||||
set(_currentFeatureText "The following Geant4 features are enabled:")
|
||||
get_property(_enabledFeatures GLOBAL PROPERTY GEANT4_ENABLED_FEATURES)
|
||||
|
||||
foreach(_feature ${_enabledFeatures})
|
||||
set(_currentFeatureText "${_currentFeatureText}\n${_feature}")
|
||||
|
||||
get_property(_desc GLOBAL PROPERTY ${_feature}_DESCRIPTION)
|
||||
|
||||
if(_desc)
|
||||
set(_currentFeatureText "${_currentFeatureText}: ${_desc}")
|
||||
set(_desc NOTFOUND)
|
||||
endif(_desc)
|
||||
endforeach(_feature)
|
||||
|
||||
message(STATUS "${_currentFeatureText}\n")
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GEANT4 DATASETS
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_latest_version(<dir> <name> <output variable>)
|
||||
# Locate latest version of dataset <name> in <dir>, setting value
|
||||
# of output variable to the full path to the dataset
|
||||
#
|
||||
function(geant4_latest_version dir name var)
|
||||
file(GLOB files RELATIVE ${dir} ${dir}/${name}*)
|
||||
set(newer)
|
||||
foreach(file ${files})
|
||||
string(REPLACE ${name} "" version ${file})
|
||||
if("${version}" VERSION_GREATER "${newer}")
|
||||
set(newer ${version})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${var} ${dir}/${name}${newer} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# GEANT4 TESTING
|
||||
#-----------------------------------------------------------------------
|
||||
# function geant4_add_unit_tests(test1 test2 ... [dir1 ...]
|
||||
# INCLUDE_DIRS dir1 dir2 ...
|
||||
# LIBRARIES library1 library2 ...)
|
||||
#
|
||||
function(geant4_add_unit_tests)
|
||||
cmake_parse_arguments(ARG "" "" "INCLUDE_DIRS;LIBRARIES" ${ARGN})
|
||||
|
||||
foreach(incdir ${ARG_INCLUDE_DIRS})
|
||||
if(IS_ABSOLUTE ${incdir})
|
||||
include_directories(${incdir})
|
||||
else()
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/${incdir})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(ARG_UNPARSED_ARGUMENTS)
|
||||
set(tnames ${ARG_UNPARSED_ARGUMENTS})
|
||||
else()
|
||||
set(tnames test*.cc)
|
||||
endif()
|
||||
|
||||
set(alltests)
|
||||
foreach(tname ${tnames})
|
||||
if(tname STREQUAL ".")
|
||||
set(tests ".")
|
||||
else()
|
||||
file(GLOB tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${tname})
|
||||
endif()
|
||||
set(alltests ${alltests} ${tests})
|
||||
endforeach()
|
||||
|
||||
if(NOT TARGET tests)
|
||||
add_custom_target(tests)
|
||||
endif()
|
||||
|
||||
foreach(test ${alltests})
|
||||
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${test})
|
||||
file(GLOB sources ${test}/src/*.cc)
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${test}/include)
|
||||
file(GLOB test ${test}/*.cc)
|
||||
else()
|
||||
set(sources)
|
||||
endif()
|
||||
get_filename_component(name ${test} NAME_WE)
|
||||
add_executable(${name} EXCLUDE_FROM_ALL ${test} ${sources})
|
||||
target_link_libraries(${name} ${ARG_LIBRARIES})
|
||||
set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name})
|
||||
add_dependencies(tests ${name})
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
set_property(TEST ${name} PROPERTY LABELS UnitTests)
|
||||
set_property(TEST ${name} PROPERTY TIMEOUT 60)
|
||||
endforeach()
|
||||
endfunction()
|
||||
@@ -1,895 +0,0 @@
|
||||
# - Set up backward compatible Geant4 GNU make toolchain
|
||||
#
|
||||
# The GNU make based buildsystem for Geant4 provides a toolchain for
|
||||
# users building simple Geant4 applications. The old style build and
|
||||
# install of Geant4 provides a customized set of non-standard install
|
||||
# paths with use of the toolchain dependent on environment variables
|
||||
# pointing to the install paths.
|
||||
#
|
||||
# This script processes information on the CMake install paths, system
|
||||
# and compiler to determine the following variables for backward
|
||||
# compatibility:
|
||||
#
|
||||
# GEANT4_SYSTEM Old style system name, e.g. 'Linux', 'Darwin'
|
||||
# or 'WIN32'
|
||||
#
|
||||
# GEANT4_COMPILER Old system compiler id, e.g. 'g++', 'VC'.
|
||||
#
|
||||
# G4INSTALL Location of 'config' subdirectory which contains
|
||||
# all the GNU make toolchain fragments
|
||||
#
|
||||
# G4INCLUDE Old style path to location of Geant4 headers
|
||||
#
|
||||
# G4LIB Old style library directory path. Rather than
|
||||
# containing the actual libraries, it is expected to
|
||||
# contain subdirectories named
|
||||
# GEANT4_SYSTEM-GEANT4_COMPILER
|
||||
#
|
||||
# These variables are used in a CMake configuration file which is used
|
||||
# to generate shell scripts (C and Bourne flavour) the user can source
|
||||
# to set up their environment for use of the old toolchain.
|
||||
# These replace the old 'env.(c)sh' scripts to allow users to work with
|
||||
# the new CMake built libraries transparently if their application
|
||||
# relies on the old style toolchain.
|
||||
#
|
||||
# The scripts are generated for both the build and install trees so that
|
||||
# developers wishing to write test applications do not have to install
|
||||
# their fresh build of Geant4.
|
||||
#
|
||||
# Compatibility with the library path style:
|
||||
#
|
||||
# <prefix>/lib/G4SYSTEM-G4COMPILER
|
||||
#
|
||||
# is provided by installing a directory 'geant4-<version>' in the
|
||||
# <prefix>/lib directory and creating a symbolic link inside here
|
||||
# pointing up one directory level.
|
||||
# This will not work on Windows however, and here users are recommended
|
||||
# to use Visual Studio directly, or to use CMake for application
|
||||
# configuration.
|
||||
#
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Functions and Macros to help configuration of shell scripts.
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_shell_setup(<shell>)
|
||||
# Set shell parameters such as program, family and common builtins
|
||||
# for supplied shell (e.g. 'bourne' or 'cshell'
|
||||
#
|
||||
macro(_g4tc_shell_setup SHELL_FAMILY)
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
set(GEANT4_TC_SHELL_PROGRAM "/bin/sh")
|
||||
set(GEANT4_TC_SHELL_FAMILY "Bourne shell")
|
||||
set(GEANT4_TC_UNSET_COMMAND "unset")
|
||||
set(GEANT4_TC_SHELL_EXTENSION ".sh")
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(GEANT4_TC_SHELL_PROGRAM "/bin/csh")
|
||||
set(GEANT4_TC_SHELL_FAMILY "C shell")
|
||||
set(GEANT4_TC_UNSET_COMMAND "unsetenv")
|
||||
set(GEANT4_TC_SHELL_EXTENSION ".csh")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported shell '${SHELL_FAMILY}'")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_selflocate(<output> <shell> <script> <variable name>)
|
||||
# Set output to string containing shell commands needed to
|
||||
# locate the directory in which script is located if the
|
||||
# script is sourced. This derived location is set as the
|
||||
# value of the shell variable name.
|
||||
#
|
||||
function(_g4tc_selflocate TEMPLATE_NAME SHELL_FAMILY SCRIPT_NAME LOCATION_VARIABLE)
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
set(${TEMPLATE_NAME}
|
||||
"# Self locate script when sourced
|
||||
if [ -z \"\$BASH_VERSION\" ]; then
|
||||
# Not bash, so rely on sourcing from correct location
|
||||
if [ ! -f ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ]; then
|
||||
echo 'ERROR: ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} could NOT self-locate Geant4 installation'
|
||||
echo 'This is most likely because you are using ksh, zsh or similar'
|
||||
echo 'To fix this issue, cd to the directory containing this script'
|
||||
echo 'and source it in that directory.'
|
||||
return 1
|
||||
fi
|
||||
${LOCATION_VARIABLE}=\$\(pwd\)
|
||||
else
|
||||
g4sls_sourced_dir=\$\(dirname \${BASH_ARGV[0]}\)
|
||||
${LOCATION_VARIABLE}=$\(cd \$g4sls_sourced_dir > /dev/null ; pwd\)
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# For bourne shell, set the values of the guard variables
|
||||
set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
|
||||
set(GEANT4_TC_ENDIF_SELFLOCATED "" PARENT_SCOPE)
|
||||
|
||||
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(${TEMPLATE_NAME}
|
||||
"# Self locate script when sourced
|
||||
# If sourced interactively, we can use $_ as this should be
|
||||
#
|
||||
# source path_to_script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
#
|
||||
unset g4sls_sourced_dir
|
||||
unset ${LOCATION_VARIABLE}
|
||||
|
||||
set ARGS=($_)
|
||||
if (\"$ARGS\" != \"\") then
|
||||
if (\"$ARGS[2]\" =~ */${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}) then
|
||||
set g4sls_sourced_dir=\"`dirname \${ARGS[2]}`\"
|
||||
endif
|
||||
endif
|
||||
|
||||
if (! \$?g4sls_sourced_dir) then
|
||||
# Oh great, we were sourced non-interactively. This means that $_
|
||||
# won't be set, so we need an external source of information on
|
||||
# where the script is located.
|
||||
# We obtain this in one of two ways:
|
||||
# 1) Current directory:
|
||||
# cd script_dir ; source ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
#
|
||||
# 2) Supply the directory as an argument to the script:
|
||||
# source script_dir/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} script_dir
|
||||
#
|
||||
if ( -e ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ) then
|
||||
set g4sls_sourced_dir=\"`pwd`\"
|
||||
else if ( \"\$1\" != \"\" ) then
|
||||
if ( -e \${1}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} ) then
|
||||
set g4sls_sourced_dir=\${1}
|
||||
else
|
||||
echo \"ERROR \${1} does not contain a Geant4 installation\"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if (! \$?g4sls_sourced_dir) then
|
||||
echo \"ERROR: ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} could NOT self-locate Geant4 installation\"
|
||||
echo \"because it was sourced (i.e. embedded) in another script.\"
|
||||
echo \"This is due to limitations of (t)csh but can be worked around by providing\"
|
||||
echo \"the directory where ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} is located\"
|
||||
echo \"to it, either via cd-ing to the directory before sourcing:\"
|
||||
echo \" cd where_script_is ; source ${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}\"
|
||||
echo \"or by supplying the directory as an argument to the script:\"
|
||||
echo \" source where_script_is/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION} where_script_is\"
|
||||
echo \" \"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
set ${LOCATION_VARIABLE}=\"`cd \${g4sls_sourced_dir} > /dev/null ; pwd`\"
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
# For C-shell, set the values of the guard variables
|
||||
set(GEANT4_TC_IF_SELFLOCATED "" PARENT_SCOPE)
|
||||
set(GEANT4_TC_ENDIF_SELFLOCATED "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_setenv_command(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# set an environment variable with name and value
|
||||
#
|
||||
function(_g4tc_setenv_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_VALUE)
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
set(${TEMPLATE_NAME}
|
||||
"export ${VARIABLE_NAME}=${VARIABLE_VALUE}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
set(${TEMPLATE_NAME}
|
||||
"setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_setenv_ifnotset_command(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# set an environment variable with name and value if the
|
||||
# variable is not already set
|
||||
#
|
||||
function(_g4tc_setenv_ifnotset_command TEMPLATE_NAME SHELL_FAMILY VARIABLE_NAME VARIABLE_VALUE)
|
||||
# -- bourne
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
# Have to make this section verbatim to get correct formatting
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if test \"x\$${VARIABLE_NAME}\" = \"x\" ; then
|
||||
export ${VARIABLE_NAME}=${VARIABLE_VALUE}
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# -- cshell
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, verbatim to get correct formatting...
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${VARIABLE_NAME}} ) then
|
||||
setenv ${VARIABLE_NAME} ${VARIABLE_VALUE}
|
||||
endif
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_prepend_path(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# prepend supplied value to the path style environment variable
|
||||
# name (e.g. 'PATH')
|
||||
#
|
||||
function(_g4tc_prepend_path TEMPLATE_NAME SHELL_FAMILY PATH_VARIABLE
|
||||
APPEND_VARIABLE)
|
||||
# -- bourne block
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
# We have to make this section verbatim
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if test \"x\$${PATH_VARIABLE}\" = \"x\" ; then
|
||||
export ${PATH_VARIABLE}=${APPEND_VARIABLE}
|
||||
else
|
||||
export ${PATH_VARIABLE}=${APPEND_VARIABLE}:\${${PATH_VARIABLE}}
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# -- cshell block
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, this is verbatim so final output is formatted correctly
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${PATH_VARIABLE}} ) then
|
||||
setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}
|
||||
else
|
||||
setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}:\${${PATH_VARIABLE}}
|
||||
endif
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# function _g4tc_append_path(<output> <shell> <name> <value>)
|
||||
# Set output to a string whose value is the shell command to
|
||||
# append supplied value to the path style environment variable
|
||||
# name (e.g. 'PATH')
|
||||
#
|
||||
function(_g4tc_append_path TEMPLATE_NAME SHELL_FAMILY PATH_VARIABLE
|
||||
APPEND_VARIABLE)
|
||||
# -- bourne block
|
||||
if(${SHELL_FAMILY} STREQUAL "bourne")
|
||||
# We have to make this section verbatim
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if test \"x\$${PATH_VARIABLE}\" = \"x\" ; then
|
||||
export ${PATH_VARIABLE}=${APPEND_VARIABLE}
|
||||
else
|
||||
export ${PATH_VARIABLE}=\${${PATH_VARIABLE}}:${APPEND_VARIABLE}
|
||||
fi
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
# -- cshell block
|
||||
elseif(${SHELL_FAMILY} STREQUAL "cshell")
|
||||
# Again, this is verbatim so final output is formatted correctly
|
||||
set(${TEMPLATE_NAME}
|
||||
"
|
||||
if ( ! \${?${PATH_VARIABLE}} ) then
|
||||
setenv ${PATH_VARIABLE} ${APPEND_VARIABLE}
|
||||
else
|
||||
setenv ${PATH_VARIABLE} \${${PATH_VARIABLE}}:${APPEND_VARIABLE}
|
||||
endif
|
||||
"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# MACRO(_g4tc_configure_tc_variables)
|
||||
# Macro to perform the actual setting of the low level toolchain variables
|
||||
# which need to be set in the final shell files.
|
||||
# We do this in a separate macro so that we can wrap it in different ways for
|
||||
# the install and build trees.
|
||||
#
|
||||
macro(_g4tc_configure_tc_variables SHELL_FAMILY SCRIPT_NAME)
|
||||
# - Set up the requested shell
|
||||
_g4tc_shell_setup(${SHELL_FAMILY})
|
||||
|
||||
# - Locate self
|
||||
_g4tc_selflocate(GEANT4_TC_LOCATE_SELF_COMMAND ${SHELL_FAMILY} ${SCRIPT_NAME} geant4make_root)
|
||||
|
||||
|
||||
# - Standard Setup and Paths
|
||||
_g4tc_setenv_command(GEANT4_TC_G4SYSTEM ${SHELL_FAMILY} G4SYSTEM ${G4SYSTEM})
|
||||
_g4tc_setenv_command(GEANT4_TC_G4INSTALL ${SHELL_FAMILY} G4INSTALL ${G4INSTALL})
|
||||
_g4tc_setenv_command(GEANT4_TC_G4INCLUDE ${SHELL_FAMILY} G4INCLUDE ${G4INCLUDE})
|
||||
|
||||
_g4tc_prepend_path(GEANT4_TC_G4BIN_PATH_SETUP ${SHELL_FAMILY} PATH ${G4BIN_DIR})
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB ${SHELL_FAMILY} G4LIB ${G4LIB})
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
_g4tc_prepend_path(GEANT4_TC_G4LIB_PATH_SETUP ${SHELL_FAMILY} DYLD_LIBRARY_PATH ${G4LIB_DIR})
|
||||
else()
|
||||
_g4tc_prepend_path(GEANT4_TC_G4LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH ${G4LIB_DIR})
|
||||
endif()
|
||||
|
||||
_g4tc_setenv_ifnotset_command(GEANT4_TC_G4WORKDIR_SETUP ${SHELL_FAMILY} G4WORKDIR ${G4WORKDIR_DEFAULT})
|
||||
_g4tc_prepend_path(GEANT4_TC_G4WORKDIR_PATH_SETUP ${SHELL_FAMILY} PATH
|
||||
\${G4WORKDIR}/bin/\${G4SYSTEM})
|
||||
|
||||
# - Geant4 Library build setup
|
||||
# We prefer shared libs if these are built, otherwise fall back to static
|
||||
# On Win32, we also want DLLs?
|
||||
if(BUILD_SHARED_LIBS)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_BUILD_SHARED ${SHELL_FAMILY} G4LIB_BUILD_SHARED 1)
|
||||
if(WIN32)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_DLL ${SHELL_FAMILY} G4LIB_USE_DLL 1)
|
||||
endif()
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_BUILD_STATIC ${SHELL_FAMILY} G4LIB_BUILD_STATIC 1)
|
||||
endif()
|
||||
|
||||
# - Multithreading
|
||||
if(GEANT4_BUILD_MULTITHREADED)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4MULTITHREADED ${SHELL_FAMILY} G4MULTITHREADED 1)
|
||||
endif()
|
||||
|
||||
# - Resource file paths
|
||||
set(GEANT4_TC_DATASETS )
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
_g4tc_setenv_command(_dssetenvcmd ${SHELL_FAMILY} ${${_ds}_ENVVAR} ${${_ds}_PATH})
|
||||
set(GEANT4_TC_DATASETS "${GEANT4_TC_DATASETS}${_dssetenvcmd}\n")
|
||||
endforeach()
|
||||
|
||||
set(GEANT4_TC_TOOLS_FONT_PATH "# FREETYPE SUPPORT NOT AVAILABLE")
|
||||
if(GEANT4_USE_FREETYPE)
|
||||
_g4tc_prepend_path(GEANT4_TC_TOOLS_FONT_PATH
|
||||
${SHELL_FAMILY}
|
||||
TOOLS_FONT_PATH
|
||||
"${TOOLS_FONT_PATH}"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# - CLHEP...
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
# Have to use detected CLHEP paths to set base dir and others
|
||||
get_filename_component(_CLHEP_INCLUDE_DIR "${CLHEP_INCLUDE_DIR}" REALPATH)
|
||||
get_filename_component(_CLHEP_BASE_DIR "${_CLHEP_INCLUDE_DIR}" DIRECTORY)
|
||||
|
||||
# Handle granular vs singular cases
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::Vector LOCATION)
|
||||
else()
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
|
||||
endif()
|
||||
|
||||
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
|
||||
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
|
||||
|
||||
set(GEANT4_TC_G4LIB_USE_CLHEP "# USING SYSTEM CLHEP")
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_BASE_DIR ${SHELL_FAMILY} CLHEP_BASE_DIR "${_CLHEP_BASE_DIR}")
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_INCLUDE_DIR ${SHELL_FAMILY} CLHEP_INCLUDE_DIR "${_CLHEP_INCLUDE_DIR}")
|
||||
|
||||
# Only need to handle CLHEP_LIB for granular case
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES )
|
||||
foreach(_clhep_lib ${CLHEP_LIBRARIES})
|
||||
get_target_property(_CLHEP_LIB_NAME ${_clhep_lib} LOCATION)
|
||||
get_filename_component(_curlib "${_CLHEP_LIB_NAME}" NAME)
|
||||
string(REGEX REPLACE "^lib(.*)\\.(so|a|dylib|lib|dll)$" "\\1" _curlib "${_curlib}")
|
||||
set(G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES} -l${_curlib}")
|
||||
endforeach()
|
||||
|
||||
# Strip first "-l" as that's prepended by Geant4Make
|
||||
string(REGEX REPLACE "^ *\\-l" "" G4_SYSTEM_CLHEP_LIBRARIES "${G4_SYSTEM_CLHEP_LIBRARIES}")
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_LIB ${SHELL_FAMILY} CLHEP_LIB "\"${G4_SYSTEM_CLHEP_LIBRARIES}\"")
|
||||
endif()
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_CLHEP_LIB_DIR ${SHELL_FAMILY} CLHEP_LIB_DIR ${_CLHEP_LIB_DIR})
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
_g4tc_prepend_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP ${SHELL_FAMILY} DYLD_LIBRARY_PATH \${CLHEP_LIB_DIR})
|
||||
else()
|
||||
_g4tc_prepend_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH \${CLHEP_LIB_DIR})
|
||||
endif()
|
||||
|
||||
else()
|
||||
# We have to configure things to point to the internal CLHEP...
|
||||
# Probably sufficient to do nothing...
|
||||
set(GEANT4_TC_G4LIB_USE_CLHEP "# USING INTERNAL CLHEP")
|
||||
endif()
|
||||
|
||||
# - EXPAT
|
||||
if(GEANT4_USE_SYSTEM_EXPAT)
|
||||
set(GEANT4_TC_G4LIB_USE_EXPAT "# USING SYSTEM EXPAT")
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_EXPAT ${SHELL_FAMILY} G4LIB_USE_EXPAT 1)
|
||||
endif()
|
||||
|
||||
# - ZLIB...
|
||||
if(GEANT4_USE_SYSTEM_ZLIB)
|
||||
set(GEANT4_TC_G4LIB_USE_ZLIB "# USING SYSTEM ZLIB")
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_ZLIB ${SHELL_FAMILY} G4LIB_USE_ZLIB 1)
|
||||
endif()
|
||||
|
||||
# - GDML...
|
||||
if(GEANT4_USE_GDML)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_GDML ${SHELL_FAMILY} G4LIB_USE_GDML 1)
|
||||
# Backward compatibility requires XERCESCROOT to be set
|
||||
# As this is a 'rootdir' determine it from the XERCESC_INCLUDE_DIR
|
||||
# variable...
|
||||
get_filename_component(_xercesc_root ${XERCESC_INCLUDE_DIR} PATH)
|
||||
_g4tc_setenv_command(GEANT4_TC_GDML_PATH_SETUP ${SHELL_FAMILY} XERCESCROOT ${_xercesc_root})
|
||||
else()
|
||||
set(GEANT4_TC_G4LIB_USE_GDML "# NOT BUILT WITH GDML SUPPORT")
|
||||
endif()
|
||||
|
||||
# - G3TOG4...
|
||||
if(GEANT4_USE_G3TOG4)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4LIB_USE_G3TOG4 ${SHELL_FAMILY} G4LIB_USE_G3TOG4 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4LIB_USE_G3TOG4 "# NOT BUILT WITH G3TOG4 SUPPORT")
|
||||
endif()
|
||||
|
||||
# - USolids/VecGeom
|
||||
if(GEANT4_USE_USOLIDS)
|
||||
# Derive base dir from include path, NB, not 100% robust as Geant4GNUmake makes
|
||||
# significant assumptions about how USolids was installed
|
||||
get_filename_component(_USOLIDS_INCLUDE_DIR "${USOLIDS_INCLUDE_DIRS}" REALPATH)
|
||||
get_filename_component(_USOLIDS_BASE_DIR "${_USOLIDS_INCLUDE_DIR}" DIRECTORY)
|
||||
_g4tc_setenv_command(GEANT4_TC_USOLIDS_BASE_DIR ${SHELL_FAMILY} USOLIDS_BASE_DIR "${_USOLIDS_BASE_DIR}")
|
||||
|
||||
if(GEANT4_USE_ALL_USOLIDS)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_USOLIDS ${SHELL_FAMILY} G4GEOM_USE_USOLIDS 1)
|
||||
set(GEANT4_TC_G4GEOM_USE_PARTIAL_USOLIDS "# FULL USOLIDS REPLACEMENT")
|
||||
else()
|
||||
set(GEANT4_TC_G4GEOM_USE_USOLIDS "# PARTIAL USOLIDS REPLACEMENT")
|
||||
_g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_PARTIAL_USOLIDS ${SHELL_FAMILY} G4GEOM_USE_PARTIAL_USOLIDS 1)
|
||||
foreach(__g4_usolid_shape ${GEANT4_USE_PARTIAL_USOLIDS_SHAPE_LIST})
|
||||
_g4tc_setenv_command(GEANT4_TC_G4GEOM_USE_U${__g4_usolid_shape} ${SHELL_FAMILY} G4GEOM_USE_U${__g4_usolid_shape} 1)
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
set(GEANT4_TC_USOLIDS_BASE_DIR "# NOT BUILT WITH USOLIDS SUPPORT")
|
||||
endif()
|
||||
|
||||
# - USER INTERFACE AND VISUALIZATION MODULES...
|
||||
# - Terminals
|
||||
if(NOT WIN32)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_TCSH ${SHELL_FAMILY} G4UI_USE_TCSH 1)
|
||||
set(GEANT4_TC_G4UI_USE_WIN32 "# WIN32 TERMINAL UI NOT AVAILABLE ON ${CMAKE_SYSTEM_NAME}")
|
||||
else()
|
||||
set(GEANT4_TC_G4UI_USE_TCSH "# TCSH TERMINAL UI NOT AVAILABLE ON ${CMAKE_SYSTEM_NAME}")
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_WIN32 ${SHELL_FAMILY} G4UI_USE_WIN32 1)
|
||||
endif()
|
||||
|
||||
# - Qt UI AND VIS
|
||||
if(GEANT4_USE_QT)
|
||||
_g4tc_setenv_command(GEANT4_TC_QTHOME ${SHELL_FAMILY} QTHOME ${G4QTHOME})
|
||||
_g4tc_setenv_command(GEANT4_TC_QTLIBPATH ${SHELL_FAMILY} QTLIBPATH ${G4QTLIBPATH})
|
||||
if(QT4_FOUND)
|
||||
set(GEANT4_TC_QTLIBS "#Geant4Make automatically handles QTLIBS for Qt4")
|
||||
set(GEANT4_TC_GLQTLIBS "#Geant4Make automatically handles GLQTLIBS for Qt4")
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_QTLIBS ${SHELL_FAMILY} QTLIBS "\"-L${G4QTLIBPATH} ${G4QTLIBLIST}\"")
|
||||
_g4tc_setenv_command(GEANT4_TC_GLQTLIBS ${SHELL_FAMILY} GLQTLIBS "\"-L${G4QTLIBPATH} ${G4GLQTLIBLIST}\"")
|
||||
endif()
|
||||
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_QT ${SHELL_FAMILY} G4UI_USE_QT 1)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLQT ${SHELL_FAMILY} G4VIS_USE_OPENGLQT 1)
|
||||
|
||||
# Dynamic loader path (NB Darwin section is obsolete on El Capitan and higher)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
_g4tc_prepend_path(GEANT4_TC_QT_LIB_PATH_SETUP ${SHELL_FAMILY} DYLD_LIBRARY_PATH \${QTLIBPATH})
|
||||
else()
|
||||
_g4tc_prepend_path(GEANT4_TC_QT_LIB_PATH_SETUP ${SHELL_FAMILY} LD_LIBRARY_PATH \${QTLIBPATH})
|
||||
endif()
|
||||
else()
|
||||
set(GEANT4_TC_G4UI_USE_QT "# NOT BUILT WITH QT INTERFACE")
|
||||
endif()
|
||||
|
||||
# - XM UI AND VIS
|
||||
if(GEANT4_USE_XM)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4UI_USE_XM ${SHELL_FAMILY} G4UI_USE_XM 1)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLXM ${SHELL_FAMILY} G4VIS_USE_OPENGLXM 1)
|
||||
|
||||
# Might need library setup, but for now recommend system install....
|
||||
else()
|
||||
set(GEANT4_TC_G4UI_USE_XM "# NOT BUILT WITH XM INTERFACE")
|
||||
endif()
|
||||
|
||||
# - Network DAWN
|
||||
if(GEANT4_USE_NETWORKDAWN)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_DAWN ${SHELL_FAMILY} G4VIS_USE_DAWN 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_DAWN "# NOT BUILT WITH NETWORK DAWN SUPPORT")
|
||||
endif()
|
||||
|
||||
# - Network VRML
|
||||
if(GEANT4_USE_NETWORKVRML)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_VRML ${SHELL_FAMILY} G4VIS_USE_VRML 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_VRML "# NOT BUILT WITH NETWORK VRML SUPPORT")
|
||||
endif()
|
||||
|
||||
# - OpenInventor
|
||||
if(GEANT4_USE_INVENTOR)
|
||||
if(UNIX)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENINVENTOR ${SHELL_FAMILY} G4VIS_USE_OIX 1)
|
||||
else()
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENINVENTOR ${SHELL_FAMILY} G4VIS_USE_OIWIN32 1)
|
||||
endif()
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_OPENINVENTOR "# NOT BUILT WITH INVENTOR SUPPORT")
|
||||
endif()
|
||||
|
||||
|
||||
# - X11 OpenGL
|
||||
if(GEANT4_USE_OPENGL_X11)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENGLX ${SHELL_FAMILY} G4VIS_USE_OPENGLX 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_OPENGLX "# NOT BUILT WITH OPENGL(X11) SUPPORT")
|
||||
endif()
|
||||
|
||||
# - WIN32 OpenGL
|
||||
if(GEANT4_USE_OPENGL_WIN32)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_OPENWIN32 ${SHELL_FAMILY} G4VIS_USE_OPENWIN32 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_OPENGLWIN32 "# NOT BUILT WITH OPENGL(WIN32) SUPPORT")
|
||||
endif()
|
||||
|
||||
# - X11 RayTracer
|
||||
if(GEANT4_USE_RAYTRACER_X11)
|
||||
_g4tc_setenv_command(GEANT4_TC_G4VIS_USE_RAYTRACERX ${SHELL_FAMILY} G4VIS_USE_RAYTRACERX 1)
|
||||
else()
|
||||
set(GEANT4_TC_G4VIS_USE_RAYTRACERX "# NOT BUILT WITH RAYTRACER(X11) SUPPORT")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_configure_build_tree_scripts()
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# build tree
|
||||
#
|
||||
macro(_g4tc_configure_build_tree_scripts SCRIPT_NAME)
|
||||
# Need to process for bourne and cshell families
|
||||
foreach(_shell bourne;cshell)
|
||||
# Generate the variables
|
||||
_g4tc_configure_tc_variables(${_shell} ${SCRIPT_NAME})
|
||||
|
||||
# Configure the file - goes straight into the binary dir
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4make-skeleton.in
|
||||
${PROJECT_BINARY_DIR}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
@ONLY
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro _g4tc_configure_install_tree_script()
|
||||
# Macro to configure toolchain compatibility scripts for the
|
||||
# install tree
|
||||
#
|
||||
macro(_g4tc_configure_install_tree_scripts CONFIGURE_DESTINATION SCRIPT_NAME INSTALL_DESTINATION)
|
||||
# Need to process for bourne and cshell families
|
||||
foreach(_shell bourne;cshell)
|
||||
# Generate the variables
|
||||
_g4tc_configure_tc_variables(${_shell} ${SCRIPT_NAME})
|
||||
|
||||
# Configure the file
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4make-skeleton.in
|
||||
${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install it to the required location
|
||||
install(FILES
|
||||
${CONFIGURE_DESTINATION}/${SCRIPT_NAME}${GEANT4_TC_SHELL_EXTENSION}
|
||||
DESTINATION ${INSTALL_DESTINATION}
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Development
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Implementation section
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure shell scripts for BUILD TREE
|
||||
# This means we have to point to libraries in the build tree, but
|
||||
# includes and resource files will be in the source tree
|
||||
# This script never needs to be relocatable, so we don't need to use the
|
||||
# self location functionality.
|
||||
# N.B. IT WILL NOT WORK when building with VS/Xcode or any multiconfig
|
||||
# buildtool because we cannot reconcile the output paths these use with
|
||||
# those expected by the old toolchain...
|
||||
#
|
||||
set(G4SYSTEM "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
set(G4INSTALL ${PROJECT_SOURCE_DIR})
|
||||
set(G4INCLUDE ${PROJECT_SOURCE_DIR}/this_is_a_deliberate_dummy_path)
|
||||
set(G4BIN_DIR ${PROJECT_BINARY_DIR})
|
||||
set(G4LIB ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(G4LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
|
||||
|
||||
# Resource files
|
||||
# - Data
|
||||
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
|
||||
geant4_get_dataset_property(${_ds} BUILD_DIR ${_ds}_PATH)
|
||||
endforeach()
|
||||
|
||||
# - Fonts
|
||||
set(TOOLS_FONT_PATH "${PROJECT_SOURCE_DIR}/source/analysis/fonts")
|
||||
|
||||
# - Configure the shell scripts for the BUILD TREE
|
||||
_g4tc_configure_build_tree_scripts(geant4make)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure shell scripts for INSTALL TREE
|
||||
# This means we have to point things to their final location when
|
||||
# installed. These paths are all determined by the CMAKE_INSTALL_FULL
|
||||
# directories and others.
|
||||
# If we are relocatable, then the structure we will have is
|
||||
# +- CMAKE_INSTALL_PREFIX
|
||||
# +- LIBDIR/Geant4-VERSION (G4LIB)
|
||||
# +- INCLUDEDIR/Geant4 (G4INCLUDE)
|
||||
# +- DATAROOTDIR/Geant4-VERSION/
|
||||
# +- geant4make (THIS IS G4INSTALL!)
|
||||
# +- geant4make.(c)sh
|
||||
# +- config/
|
||||
|
||||
# - Construct universal backward compatible INSTALL TREE PATHS.
|
||||
set(G4SYSTEM "${GEANT4_SYSTEM}-${GEANT4_COMPILER}")
|
||||
set(G4INSTALL "\"\$geant4make_root\"")
|
||||
|
||||
# - Now need relative paths between 'G4INSTALL' and include/bin/lib dirs
|
||||
# - Include dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_INCLUDEDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${CMAKE_INSTALL_FULL_INCLUDEDIR}/${PROJECT_NAME}
|
||||
)
|
||||
set(G4INCLUDE "\"`cd \$geant4make_root/${G4MAKE_TO_INCLUDEDIR} > /dev/null \; pwd`\"")
|
||||
|
||||
# - Bin dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_BINDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${CMAKE_INSTALL_FULL_BINDIR}
|
||||
)
|
||||
set(G4BIN_DIR "\"`cd \$geant4make_root/${G4MAKE_TO_BINDIR} > /dev/null \; pwd`\"")
|
||||
|
||||
# - Lib dir
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_LIBDIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${CMAKE_INSTALL_FULL_LIBDIR}
|
||||
)
|
||||
set(G4LIB "\"`cd \$geant4make_root/${G4MAKE_TO_LIBDIR}/Geant4-${Geant4_VERSION} > /dev/null \; pwd`\"")
|
||||
set(G4LIB_DIR "\"`cd \$geant4make_root/${G4MAKE_TO_LIBDIR} > /dev/null \; pwd`\"")
|
||||
|
||||
set(G4WORKDIR_DEFAULT "\$HOME/geant4_workdir")
|
||||
|
||||
# Resource files
|
||||
# - Data
|
||||
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
|
||||
geant4_get_dataset_property(${_ds} INSTALL_DIR ${_ds}_PATH)
|
||||
|
||||
file(RELATIVE_PATH
|
||||
G4MAKE_TO_DATADIR
|
||||
${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
${${_ds}_PATH}
|
||||
)
|
||||
set(${_ds}_PATH "\"`cd \$geant4make_root/${G4MAKE_TO_DATADIR} > /dev/null \; pwd`\"")
|
||||
endforeach()
|
||||
|
||||
# - Fonts
|
||||
set(TOOLS_FONT_PATH "\"`cd \$geant4make_root/../fonts > /dev/null ; pwd`\"")
|
||||
|
||||
# - Configure the shell scripts for the INSTALL TREE
|
||||
_g4tc_configure_install_tree_scripts(
|
||||
${CMAKE_BINARY_DIR}/InstallTreeFiles
|
||||
geant4make
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
)
|
||||
|
||||
|
||||
# - For install tree, we also need to install the config directory
|
||||
# which contains all the old toolchain scripts, and to create a
|
||||
# softlink to the G4SYSTEM directory.
|
||||
#
|
||||
install(DIRECTORY config
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Geant4-${Geant4_VERSION}/geant4make
|
||||
COMPONENT Development
|
||||
FILES_MATCHING PATTERN "*.gmk"
|
||||
PATTERN "CVS" EXCLUDE
|
||||
PATTERN ".svn" EXCLUDE
|
||||
PATTERN "scripts/" EXCLUDE
|
||||
)
|
||||
|
||||
# Compatibility softlink to library directory, we do this on all
|
||||
# platforms, but it does nothing on Windows (well, at least the
|
||||
# attempted symlink creation does not)
|
||||
# Take care to quote the path names to avoid issues with spaces
|
||||
install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E make_directory \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/Geant4-${Geant4_VERSION}\")")
|
||||
|
||||
install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink .. ${GEANT4_SYSTEM}-${GEANT4_COMPILER} WORKING_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/Geant4-${Geant4_VERSION}\")")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# TEMPORARY
|
||||
# Configure environment setup script for install of Geant4
|
||||
# Temporarily here to keep all shell setup in one place.
|
||||
# Later, should be refactored into its own module, with module containing
|
||||
# all the shell tools above.
|
||||
#
|
||||
# - Script base name (without extension
|
||||
set(_scriptbasename geant4)
|
||||
|
||||
# - Relative path between bindir (where script is) and library directory
|
||||
file(RELATIVE_PATH
|
||||
G4ENV_BINDIR_TO_LIBDIR
|
||||
${CMAKE_INSTALL_FULL_BINDIR}
|
||||
${CMAKE_INSTALL_FULL_LIBDIR}
|
||||
)
|
||||
|
||||
# Resource Files
|
||||
# - Data
|
||||
geant4_get_datasetnames(GEANT4_EXPORTED_DATASETS)
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR ${_ds}_ENVVAR)
|
||||
geant4_get_dataset_property(${_ds} INSTALL_DIR ${_ds}_PATH)
|
||||
|
||||
file(RELATIVE_PATH
|
||||
G4ENV_BINDIR_TO_DATADIR
|
||||
${CMAKE_INSTALL_FULL_BINDIR}
|
||||
${${_ds}_PATH}
|
||||
)
|
||||
set(${_ds}_PATH "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATADIR} > /dev/null \; pwd`\"")
|
||||
endforeach()
|
||||
|
||||
# - Fonts
|
||||
file(RELATIVE_PATH
|
||||
G4ENV_BINDIR_TO_DATAROOTDIR
|
||||
"${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
"${CMAKE_INSTALL_FULL_DATAROOTDIR}/Geant4-${Geant4_VERSION}"
|
||||
)
|
||||
set(TOOLS_FONT_PATH "\"`cd \$geant4_envbindir/${G4ENV_BINDIR_TO_DATAROOTDIR}/fonts > /dev/null ; pwd`\"")
|
||||
|
||||
|
||||
# - Configure for each shell
|
||||
foreach(_shell bourne;cshell)
|
||||
# Setup the shell
|
||||
_g4tc_shell_setup(${_shell})
|
||||
|
||||
# Set script full name
|
||||
set(_scriptfullname ${_scriptbasename}${GEANT4_TC_SHELL_EXTENSION})
|
||||
|
||||
# Set locate self command
|
||||
_g4tc_selflocate(GEANT4_ENV_SELFLOCATE_COMMAND
|
||||
${_shell}
|
||||
${_scriptbasename}
|
||||
geant4_envbindir
|
||||
)
|
||||
|
||||
# Set path, which should be where the script itself is installed
|
||||
_g4tc_prepend_path(GEANT4_ENV_BINPATH_SETUP
|
||||
${_shell}
|
||||
PATH
|
||||
"\"\$geant4_envbindir\""
|
||||
)
|
||||
|
||||
# Set library path, based on relative paths between bindir and libdir
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
set(_libpathname DYLD_LIBRARY_PATH)
|
||||
else()
|
||||
set(_libpathname LD_LIBRARY_PATH)
|
||||
endif()
|
||||
|
||||
_g4tc_prepend_path(GEANT4_ENV_LIBPATH_SETUP
|
||||
${_shell}
|
||||
${_libpathname}
|
||||
"\"`cd $geant4_envbindir/${G4ENV_BINDIR_TO_LIBDIR} > /dev/null ; pwd`\""
|
||||
)
|
||||
|
||||
# Third party lib paths
|
||||
# - CLHEP, if system
|
||||
set(GEANT4_TC_CLHEP_LIB_PATH_SETUP "# - Builtin CLHEP used")
|
||||
if(GEANT4_USE_SYSTEM_CLHEP)
|
||||
# Handle granular vs singular cases
|
||||
if(GEANT4_USE_SYSTEM_CLHEP_GRANULAR)
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::Vector LOCATION)
|
||||
else()
|
||||
get_target_property(_CLHEP_LIB_DIR CLHEP::CLHEP LOCATION)
|
||||
endif()
|
||||
|
||||
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" REALPATH)
|
||||
get_filename_component(_CLHEP_LIB_DIR "${_CLHEP_LIB_DIR}" DIRECTORY)
|
||||
|
||||
_g4tc_append_path(GEANT4_TC_CLHEP_LIB_PATH_SETUP
|
||||
${_shell}
|
||||
${_libpathname}
|
||||
"${_CLHEP_LIB_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# - XercesC
|
||||
set(GEANT4_TC_XERCESC_LIB_PATH_SETUP "# GDML SUPPORT NOT AVAILABLE")
|
||||
if(GEANT4_USE_GDML)
|
||||
get_filename_component(_XERCESC_LIB_DIR "${XERCESC_LIBRARY}" REALPATH)
|
||||
get_filename_component(_XERCESC_LIB_DIR "${XERCESC_LIBRARY}" DIRECTORY)
|
||||
_g4tc_append_path(GEANT4_TC_XERCESC_LIB_PATH_SETUP
|
||||
${_shell}
|
||||
${_libpathname}
|
||||
"${_XERCESC_LIB_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# - Set data paths
|
||||
set(GEANT4_ENV_DATASETS )
|
||||
foreach(_ds ${GEANT4_EXPORTED_DATASETS})
|
||||
_g4tc_setenv_command(_dssetenvcmd ${_shell} ${${_ds}_ENVVAR} ${${_ds}_PATH})
|
||||
set(GEANT4_ENV_DATASETS "${GEANT4_ENV_DATASETS}${_dssetenvcmd}\n")
|
||||
endforeach()
|
||||
|
||||
# - Set Font Path
|
||||
set(GEANT4_ENV_TOOLS_FONT_PATH "# FREETYPE SUPPORT NOT AVAILABLE")
|
||||
if(GEANT4_USE_FREETYPE)
|
||||
_g4tc_append_path(GEANT4_ENV_TOOLS_FONT_PATH
|
||||
${_shell}
|
||||
TOOLS_FONT_PATH
|
||||
"${TOOLS_FONT_PATH}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Configure the file
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/cmake/Templates/geant4-env-skeleton.in
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install it to the required location
|
||||
install(FILES
|
||||
${PROJECT_BINARY_DIR}/InstallTreeFiles/${_scriptfullname}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Runtime
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# - TEMP hack to get modulefile support in
|
||||
include(Geant4ConfigureModulefile)
|
||||
geant4_configure_modulefile()
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# - Provide a custom target for validating sources.cmake and on-disk files
|
||||
# As sources.cmake lists source files of Geant4 explicitely, we can often
|
||||
# get a mismatch between this list and what's actually on disk.
|
||||
#
|
||||
# This module provides a custom target which executes a CMake script to
|
||||
# check for these errors and report mismatches. It fails with FATAL_ERROR
|
||||
# if any mismatch is found, but will not do so until it has reported
|
||||
# all errors.
|
||||
#
|
||||
|
||||
# Configure the script
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Templates/geant4_validate_sources.cmake.in
|
||||
${PROJECT_BINARY_DIR}/geant4_validate_sources.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Create the target
|
||||
add_custom_target(validate_sources
|
||||
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/geant4_validate_sources.cmake
|
||||
COMMENT "Validating Geant4 Module Source Lists"
|
||||
)
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
# This file defines the following macros for developers to use in ensuring
|
||||
# that installed software is of the right version:
|
||||
#
|
||||
# MACRO_ENSURE_VERSION - test that a version number is greater than
|
||||
# or equal to some minimum
|
||||
# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than
|
||||
# or equal to some minimum and less than some
|
||||
# maximum
|
||||
# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code
|
||||
#
|
||||
# MACRO_VERIFY_VERSION - test that a version number satisfies a given
|
||||
# set of requirements, such as an exact match,
|
||||
# greater than or equal to a minimum, less
|
||||
# than or equal to some maximum, or between
|
||||
# a minimum and maximum.
|
||||
#
|
||||
# MACRO_ENSURE_VERSION
|
||||
# This macro compares version numbers of the form "a.b.c.d" or "a.b.c"
|
||||
# or "a.b"
|
||||
#
|
||||
# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK)
|
||||
# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION
|
||||
# Leading and trailing text is ok, e.g.
|
||||
# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK)
|
||||
# which means 2.5.31 is required and "flex 2.5.4a" is what was found on
|
||||
# the system
|
||||
|
||||
# Copyright (c) 2006, David Faure, <faure@kde.org>
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# MACRO_VERIFY_VERSION
|
||||
# This macro compares version numbers of the form "a.b.c.d" or "a.b.c" or "a.b"
|
||||
#
|
||||
# MACRO_VERIFY_VERSION(VERSION_OK
|
||||
# MIN_VERSION "a.b.c.d"
|
||||
# MAX_VERSION "p.q.r"
|
||||
# FOUND_VERSION "x.y.z"
|
||||
# [FIND_EXACT True|False])
|
||||
#
|
||||
# The macro uses the following logic to verify version checking
|
||||
#
|
||||
# 1) MIN_VERSION a.b.c, FOUND_VERSION x.y.z supplied, FIND_EXACT set:
|
||||
# Check and require that x.y.z == a.b.c
|
||||
# MAX_VERSION ignored.
|
||||
#
|
||||
# 2) MIN_VERSION a.b.c, FOUND_VERSION x.y.z supplied
|
||||
# i) If MAX_VERSION not set, check and require that x.y.z >= a.b.c
|
||||
# ii) If MAX_VERSION p.q.r set, check and require a.b.c <= x.y.z < p.q.r
|
||||
#
|
||||
# 3) MIN_VERSION a.b.c NOT supplied, FOUND_VERSION x.y.z supplied
|
||||
# i) If MAX_VERSION not set, version assumed to be verified.
|
||||
# ii) If MAX_VERSION p.q.r set, check and require x.y.z < p.q.r
|
||||
#
|
||||
# Copyright (c) 2009, Ben Morgan, <Ben.Morgan@warwick.ac.uk>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# MACRO_ENSURE_VERSION_RANGE
|
||||
# This macro ensures that a version number of the form
|
||||
# "a.b.c.d" or "a.b.c" or "a.b" falls within a range defined by
|
||||
# min_version <= found_version < max_version.
|
||||
# If this expression holds, FOO_VERSION_OK will be set TRUE
|
||||
#
|
||||
# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK )
|
||||
#
|
||||
# This macro will break silently if any of a,b,c or d are greater than 100.
|
||||
#
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# NORMALIZE_VERSION
|
||||
# Helper macro to convert version numbers of the form "a.b.c.d"
|
||||
# to an integer equal to 10^6 * a + 10^4 * b + 10^2 * c + d
|
||||
#
|
||||
# This macro will break silently if any of a,b,c,d are greater than 100.
|
||||
#
|
||||
# Copyright (c) 2006, David Faure, <faure@kde.org>
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Modifications Copyright (c) 2008, Ben Morgan <Ben.Morgan@warwick.ac.uk>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# CHECK_RANGE_INCLUSIVE_LOWER
|
||||
# Helper macro to check whether x <= y < z
|
||||
#
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# MACRO_
|
||||
|
||||
# - Include guard
|
||||
if(__macroensureversion_isloaded)
|
||||
return()
|
||||
endif()
|
||||
set(__macroensureversion_isloaded YES)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro normalize_version()
|
||||
#
|
||||
macro(normalize_version _requested_version _normalized_version)
|
||||
# Do we have a.b.c.d in _requested_version?
|
||||
string(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9].*" _fourPartMatch "${_requested_version}")
|
||||
string(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}")
|
||||
|
||||
if(_fourPartMatch)
|
||||
# We certainly have a.b.c.d so split out the components as needed
|
||||
string(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
|
||||
string(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
|
||||
string(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
|
||||
string(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _tweak_vers "${_requested_version}")
|
||||
elseif(_threePartMatch)
|
||||
# parse the parts of the version string
|
||||
string(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
|
||||
string(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
|
||||
string(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
|
||||
set(_tweak_vers "0")
|
||||
else(_threePartMatch)
|
||||
string(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}")
|
||||
string(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}")
|
||||
set(_patch_vers "0")
|
||||
set(_tweak_vers "0")
|
||||
endif()
|
||||
|
||||
# compute an overall version number which can be compared at once
|
||||
math(EXPR ${_normalized_version} "${_major_vers}*1000000 + ${_minor_vers}*10000 + ${_patch_vers}*100 + ${_tweak_vers}")
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro macro_check_range_inclusive_lower()
|
||||
#
|
||||
macro(macro_check_range_inclusive_lower _lower_limit _value _upper_limit _ok)
|
||||
if(${_value} LESS ${_lower_limit})
|
||||
set(${_ok} FALSE)
|
||||
elseif(${_value} EQUAL ${_lower_limit})
|
||||
set(${_ok} TRUE)
|
||||
elseif(${_value} EQUAL ${_upper_limit})
|
||||
set(${_ok} FALSE)
|
||||
elseif(${_value} GREATER ${_upper_limit})
|
||||
set(${_ok} FALSE)
|
||||
else()
|
||||
set(${_ok} TRUE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro macro_ensure_version()
|
||||
#
|
||||
macro(macro_ensure_version requested_version found_version var_too_old)
|
||||
normalize_version(${requested_version} req_vers_num)
|
||||
normalize_version(${found_version} found_vers_num)
|
||||
|
||||
if(found_vers_num LESS req_vers_num)
|
||||
set(${var_too_old} FALSE)
|
||||
else()
|
||||
set(${var_too_old} TRUE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro macro_ensure_version2()
|
||||
#
|
||||
macro(macro_ensure_version2 requested_version2 found_version2 var_too_old2)
|
||||
macro_ensure_version(${requested_version2} ${found_version2} ${var_too_old2})
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro macro_ensure_version_range()
|
||||
#
|
||||
macro(macro_ensure_version_range min_version found_version max_version var_ok)
|
||||
normalize_version(${min_version} req_vers_num)
|
||||
normalize_version(${found_version} found_vers_num)
|
||||
normalize_version(${max_version} max_vers_num)
|
||||
|
||||
macro_check_range_inclusive_lower(${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok})
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# For parsing...
|
||||
include(CMakeMacroParseArguments)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro macro_verify_version()
|
||||
#
|
||||
macro(macro_verify_version)
|
||||
cmake_parse_arguments(MVV
|
||||
""
|
||||
"MIN_VERSION;MAX_VERSION;FOUND_VERSION;FIND_EXACT"
|
||||
""
|
||||
${ARGN})
|
||||
|
||||
set(MVV_VAR_OK ${ARGV0})
|
||||
message("var to set: ${ARGV0}")
|
||||
message("min_version = ${MVV_MIN_VERSION}")
|
||||
message("max_version = ${MVV_MAX_VERSION}")
|
||||
message("found_version = ${MVV_FOUND_VERSION}")
|
||||
message("find_exact = ${MVV_FIND_EXACT}")
|
||||
|
||||
# If MIN_VERSION NOT supplied, must set it to absolute minimum
|
||||
if(NOT DEFINED ${MVV_MIN_VERSION})
|
||||
set(MVV_MIN_VERSION "0.0.0.0")
|
||||
endif()
|
||||
|
||||
if(MVV_FOUND_VERSION AND MVV_FIND_EXACT)
|
||||
if(${MVV_MIN_VERSION} MATCHES ${MVV_FOUND_VERSION})
|
||||
set(${MVV_VAR_OK} TRUE)
|
||||
else(${MVV_MIN_VERSION} MATCHES ${MVV_FOUND_VERSION})
|
||||
set(${MVV_VAR_OK} FALSE)
|
||||
endif()
|
||||
elseif(MVV_FOUND_VERSION AND NOT MVV_FIND_EXACT)
|
||||
if(MVV_MAX_VERSION)
|
||||
macro_ensure_version_range(${MVV_MIN_VERSION}
|
||||
${MVV_FOUND_VERSION}
|
||||
${MVV_MAX_VERSION}
|
||||
${MVV_VAR_OK})
|
||||
else()
|
||||
macro_ensure_version(${MVV_MIN_VERSION}
|
||||
${MVV_FOUND_VERSION}
|
||||
${MVV_VAR_OK})
|
||||
endif()
|
||||
else()
|
||||
if(MVV_MAX_VERSION)
|
||||
macro_ensure_version_range("0.0.0.0"
|
||||
${MVV_FOUND_VERSION}
|
||||
${MVV_MAX_VERSION}
|
||||
${MVV_VAR_OK})
|
||||
else()
|
||||
set(${MVV_VAR_OK} TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endmacro(macro_verify_version)
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
# ResolveCompilerPaths - this module defines two macros
|
||||
#
|
||||
# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE)
|
||||
# This macro is intended to be used by FindXXX.cmake modules.
|
||||
# It parses a compiler link line and resolves all libraries
|
||||
# (-lfoo) using the library path contexts (-L/path) in scope.
|
||||
# The result in XXX_LIBRARIES is the list of fully resolved libs.
|
||||
# Example:
|
||||
#
|
||||
# RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld")
|
||||
#
|
||||
# will be resolved to
|
||||
#
|
||||
# FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so"
|
||||
#
|
||||
# if the filesystem looks like
|
||||
#
|
||||
# /A: liba.so libc.so
|
||||
# /B: liba.so libb.so
|
||||
# /usr/lib: liba.so libb.so libc.so libd.so
|
||||
#
|
||||
# and /usr/lib is a system directory.
|
||||
#
|
||||
# Note: If RESOLVE_LIBRARIES() resolves a link line differently from
|
||||
# the native linker, there is a bug in this macro (please report it).
|
||||
#
|
||||
# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE)
|
||||
# This macro is intended to be used by FindXXX.cmake modules.
|
||||
# It parses a compile line and resolves all includes
|
||||
# (-I/path/to/include) to a list of directories. Other flags are ignored.
|
||||
# Example:
|
||||
#
|
||||
# RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B")
|
||||
#
|
||||
# will be resolved to
|
||||
#
|
||||
# FOO_INCLUDES:STRING="/A;/B"
|
||||
#
|
||||
# assuming both directories exist.
|
||||
# Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry)
|
||||
|
||||
# Code from Jed Brown:
|
||||
# https://github.com/jedbrown/cmake-modules/blob/master/ResolveCompilerPaths.cmake
|
||||
# See COPYING-CMAKE-SCRIPTS for licensing information (BSD)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro resolve_libraries()
|
||||
#
|
||||
macro(resolve_libraries LIBS LINK_LINE)
|
||||
string(REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|/[^\" ]+(a|so|dll))" _all_tokens "${LINK_LINE}")
|
||||
set(_libs_found)
|
||||
set(_directory_list)
|
||||
foreach(token ${_all_tokens})
|
||||
if(token MATCHES "-L([^\" ]+|\"[^\"]+\")")
|
||||
# If it's a library path, add it to the list
|
||||
string (REGEX REPLACE "^-L" "" token ${token})
|
||||
string (REGEX REPLACE "//" "/" token ${token})
|
||||
list (APPEND _directory_list ${token})
|
||||
elseif(token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|/[^\" ]+(a|so|dll))")
|
||||
# It's a library, resolve the path by looking in the list and then (by default) in system directories
|
||||
string(REGEX REPLACE "^-l" "" token ${token})
|
||||
set(_root)
|
||||
if(token MATCHES "^/")
|
||||
# We have an absolute path, add root to the search path
|
||||
set(_root "/")
|
||||
endif()
|
||||
set(_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
|
||||
find_library(_lib ${token} HINTS ${_directory_list} ${_root})
|
||||
if(_lib)
|
||||
string(REPLACE "//" "/" _lib ${_lib})
|
||||
list(APPEND _libs_found ${_lib})
|
||||
else()
|
||||
message(STATUS "Unable to find library ${token}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE)
|
||||
# only the LAST occurence of each library is required since there should be no circular dependencies
|
||||
if(_libs_found)
|
||||
list(REVERSE _libs_found)
|
||||
list(REMOVE_DUPLICATES _libs_found)
|
||||
list(REVERSE _libs_found)
|
||||
endif()
|
||||
set(${LIBS} "${_libs_found}")
|
||||
endmacro()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# macro resolve_includes()
|
||||
#
|
||||
macro(resolve_includes INCS COMPILE_LINE)
|
||||
string(REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}")
|
||||
set(_incs_found)
|
||||
foreach(token ${_all_tokens})
|
||||
string(REGEX REPLACE "^-I" "" token ${token})
|
||||
string(REGEX REPLACE "//" "/" token ${token})
|
||||
# - Remove any residual quotes (from Fabian Kislat: Bug #1357)
|
||||
string(REGEX REPLACE "(^\"|\"$)" "" token ${token})
|
||||
if(EXISTS ${token})
|
||||
list(APPEND _incs_found ${token})
|
||||
else()
|
||||
message(STATUS "Include directory ${token} does not exist")
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES _incs_found)
|
||||
set(${INCS} "${_incs_found}")
|
||||
endmacro()
|
||||
|
||||
Reference in New Issue
Block a user