Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
31a872f9
Commit
31a872f9
authored
Dec 16, 2011
by
Lynn Garren
Browse files
cmake improvements from Ben Morgan
parent
4fafb349
Changes
10
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
31a872f9
...
...
@@ -12,15 +12,21 @@
# which matches the default CLHEP autoconf flags
#------------------------------------------------------------------------------
# Ensure out of source build before anything else
include
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/Modules/ClhepOutOfSourceBuild.cmake
)
clhep_ensure_out_of_source_build
()
# use cmake 2.6 or later
cmake_minimum_required
(
VERSION 2.6
)
cmake_minimum_required
(
VERSION 2.6
)
# project name
project
(
CLHEP
)
set
(
VERSION 2.1.1.0
)
set
(
CMAKE_MODULE_PATH
"
${
CMAKE_ROOT
}
/Modules"
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/Modules
${
CMAKE_MODULE_PATH
}
)
message
(
STATUS
"module path is
${
CMAKE_MODULE_PATH
}
"
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/Modules
${
CMAKE_MODULE_PATH
}
)
# CLHEP_BUILD_DOCS is OFF (false) by default
option
(
CLHEP_BUILD_DOCS
"Build and install CLHEP documentation"
OFF
)
...
...
@@ -30,20 +36,20 @@ if(CLHEP_BUILD_DOCS)
message
(
STATUS
"Enabled build and install of documents"
)
endif
()
# various handy macros
include
(
ClhepOutOfSourceBuild
)
# CLHEP custom modules
include
(
ClhepCopyHeaders
)
include
(
ClhepBuildTest
)
include
(
ClhepBuildLibrary
)
include
(
ClhepVariables
)
include
(
CheckFunctionExists
)
include
(
ClhepToolchain
)
#
make sure we are not building in source
clhep_ensure_out_of_source_build
(
)
#
Custom Packaging
include
(
ClhepPackaging
)
# because we want to move these libraries about,
# do not embed full path in shared libraries or executables
set
(
CMAKE_SKIP_RPATH
)
set
(
CMAKE_SKIP_RPATH
)
ENABLE_TESTING
()
...
...
@@ -52,24 +58,52 @@ include_directories ("${PROJECT_BINARY_DIR}")
# add CLHEP/Random to search path so we find gaussTables.cdat
include_directories
(
"
${
CMAKE_SOURCE_DIR
}
/Random"
)
#build all libraries in a single directory to facilitate testing
SET
(
LIBRARY_OUTPUT_PATH
${
PROJECT_BINARY_DIR
}
/lib
)
# Put all library build products in standard locations under build tree
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${
PROJECT_BINARY_DIR
}
/lib
)
set
(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
${
PROJECT_BINARY_DIR
}
/lib
)
# define common flags
set
(
CMAKE_INCLUDE_PATH
${
CLHEP_BINARY_DIR
}
)
# set our preferred compiler flags
clhep_set_compiler_flags
()
# the main CLHEP config script
clhep_config
()
# check for required functions
CHECK_FUNCTION_EXISTS
(
drand48 found_drand48
)
# all the packages
set
(
CLHEP_subdirs Units Utility Vector Evaluator GenericFunctions Geometry
Random Matrix RandomObjects Cast RefCount Exceptions
)
set
(
CLHEP_subdirs
Units
Utility
Vector
Evaluator
GenericFunctions
Geometry
Random
Matrix
RandomObjects
Cast
RefCount
Exceptions
)
# The Units and Utility packages are just headers.
set
(
CLHEP_libraries Vector Evaluator GenericFunctions Geometry
Random Matrix RandomObjects Cast RefCount Exceptions
)
set
(
CLHEP_libraries
Vector
Evaluator
GenericFunctions
Geometry
Random
Matrix
RandomObjects
Cast
RefCount
Exceptions
)
clhep_copy_headers
(
${
CLHEP_subdirs
}
)
add_subdirectory
(
Units
)
...
...
@@ -85,4 +119,8 @@ add_subdirectory(Cast)
add_subdirectory
(
RefCount
)
add_subdirectory
(
Exceptions
)
# libCLHEP.a and libCLHEP.so
clhep_build_libclhep
(
${
CLHEP_libraries
}
)
# provide tools for other packages to include CLHEP easily
clhep_toolchain
()
ChangeLog
View file @
31a872f9
2011-12-15 Lynn Garren <garren@fnal.gov>
* cmake is now the preferred build option
* building with autotools and configure is deprecated
* you MUST use cmake when building with clang and other exotic compilers
* various improvements to the cmake build from Ben Morgan (Warwick)
* to build documents, call cmake with -DCLHEP_BUILD_DOCS=ON
* lib/CLHEP-<version> contains cmake files for use by find_package
* lib/pkgconfig contains clhep.pc
==============================
29.07.11 Release CLHEP-2.1.1.0
==============================
...
...
INSTALL
View file @
31a872f9
...
...
@@ -5,8 +5,11 @@
You may build CLHEP as a complete package, starting from this
top level directory, or you may build any package separately.
These instructions are for the autoconf/automake build system.
If you wish to use cmake, look at cmake/INSTALL.
Cmake is now the preferred build option - see cmake/INSTALL.
Building with autotools and configure is deprecated.
You MUST use cmake when building with clang and other exotic compilers.
The instructions below are for the autoconf/automake build system.
#-------------------------------------------------------------
# platform specific issues
...
...
cmake/Modules/ClhepBuildLibrary.cmake
View file @
31a872f9
...
...
@@ -5,62 +5,78 @@
# clhep_build_library( <package> <source code files> )
#
macro
(
clhep_build_library package
)
set
(
CLHEP_
${
package
}
_SOURCES
${
ARGN
}
)
macro
(
clhep_build_library package
)
set
(
CLHEP_
${
package
}
_SOURCES
${
ARGN
}
)
# build up the source list for CLHEP
set
(
CLHEP_
${
package
}
_list CACHE INTERNAL
"
${
package
}
sources"
FORCE
)
foreach
(
file
${
ARGN
}
)
set
(
CLHEP_
${
package
}
_list
${
CLHEP_
${
package
}
_list
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
file
}
CACHE INTERNAL
"
${
package
}
sources"
)
set
(
CLHEP_
${
package
}
_list
${
CLHEP_
${
package
}
_list
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
file
}
CACHE INTERNAL
"
${
package
}
sources"
)
endforeach
(
file
)
##message( STATUS "in ${package}, clheplib source list ${CLHEP_${package}_list}" )
# check for dependencies
set
(
package_library_list
)
set
(
package_library_list
)
if
(
${
PACKAGE
}
_DEPS
)
foreach
(
dep
${${
PACKAGE
}
_DEPS
}
)
##message( STATUS "clhep_build_library ${package} will use ${dep}")
list
(
APPEND package_library_list
${
dep
}
)
list
(
APPEND package_library_list
${
dep
}
)
endforeach
()
endif
()
ADD_LIBRARY
(
${
package
}
SHARED
${
CLHEP_
${
package
}
_SOURCES
}
)
ADD_LIBRARY
(
${
package
}
S STATIC
${
CLHEP_
${
package
}
_SOURCES
}
)
# Add the libraries and set properties
ADD_LIBRARY
(
${
package
}
SHARED
${
CLHEP_
${
package
}
_SOURCES
}
)
ADD_LIBRARY
(
${
package
}
S STATIC
${
CLHEP_
${
package
}
_SOURCES
}
)
SET_TARGET_PROPERTIES
(
${
package
}
PROPERTIES OUTPUT_NAME CLHEP-
${
package
}
-
${
VERSION
}
PROPERTIES
OUTPUT_NAME CLHEP-
${
package
}
-
${
VERSION
}
CLEAN_DIRECT_OUTPUT 1
)
SET_TARGET_PROPERTIES
(
${
package
}
S
PROPERTIES OUTPUT_NAME CLHEP-
${
package
}
-
${
VERSION
}
SET_TARGET_PROPERTIES
(
${
package
}
S
PROPERTIES
OUTPUT_NAME CLHEP-
${
package
}
-
${
VERSION
}
CLEAN_DIRECT_OUTPUT 1
)
SET_TARGET_PROPERTIES
(
${
package
}
PROPERTIES CLEAN_DIRECT_OUTPUT 1
)
SET_TARGET_PROPERTIES
(
${
package
}
S PROPERTIES CLEAN_DIRECT_OUTPUT 1
)
target_link_libraries
(
${
package
}
${
package_library_list
}
)
target_link_libraries
(
${
package
}
S
${
package_library_list
}
)
# Install the libraries
INSTALL
(
TARGETS
${
package
}
${
package
}
S
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endmacro
(
clhep_build_library
)
endmacro
(
clhep_build_library
)
macro
(
clhep_build_libclhep
)
macro
(
clhep_build_libclhep
)
foreach
(
pkg
${
ARGN
}
)
##message( STATUS "${pkg} sources are ${CLHEP_${pkg}_list}" )
list
(
APPEND CLHEP_DEPS
${
LIBRARY_OUTPUT_PATH
}
/
${
CMAKE_STATIC_LIBRARY_PREFIX
}
CLHEP-
${
pkg
}
-
${
VERSION
}${
CMAKE_STATIC_LIBRARY_SUFFIX
}
)
list
(
APPEND clhep_sources
${
CLHEP_
${
pkg
}
_list
}
)
endforeach
()
##message( STATUS "clheplib source list ${clhep_sources}" )
ADD_LIBRARY
(
CLHEP SHARED
${
clhep_sources
}
)
ADD_LIBRARY
(
CLHEPS STATIC
${
clhep_sources
}
)
SET_TARGET_PROPERTIES
(
CLHEP
PROPERTIES OUTPUT_NAME CLHEP-
${
VERSION
}
CLEAN_DIRECT_OUTPUT 1
SET_TARGET_PROPERTIES
(
CLHEP
PROPERTIES
OUTPUT_NAME CLHEP-
${
VERSION
}
CLEAN_DIRECT_OUTPUT 1
)
SET_TARGET_PROPERTIES
(
CLHEPS
PROPERTIES OUTPUT_NAME CLHEP-
${
VERSION
}
CLEAN_DIRECT_OUTPUT 1
SET_TARGET_PROPERTIES
(
CLHEPS
PROPERTIES
OUTPUT_NAME CLHEP-
${
VERSION
}
CLEAN_DIRECT_OUTPUT 1
)
INSTALL
(
TARGETS CLHEP CLHEPS
# export creates library dependency files for CLHEPConfig.cmake
INSTALL
(
TARGETS CLHEP CLHEPS
EXPORT CLHEPLibraryDepends
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
...
...
@@ -79,7 +95,8 @@ macro (clhep_build_libclhep )
file
(
WRITE
${
CMAKE_CURRENT_BINARY_DIR
}
/clhep_shared_symlink
"exec_program(
${
CMAKE_COMMAND
}
ARGS -E chdir
${
CMAKE_INSTALL_PREFIX
}
/lib;
${
CMAKE_COMMAND
}
ARGS -E create_symlink
${
CMAKE_SHARED_LIBRARY_PREFIX
}
CLHEP-
${
VERSION
}${
CMAKE_SHARED_LIBRARY_SUFFIX
}
${
CMAKE_SHARED_LIBRARY_PREFIX
}
CLHEP
${
CMAKE_SHARED_LIBRARY_SUFFIX
}
)"
)
endif
()
INSTALL
(
SCRIPT
${
CMAKE_CURRENT_BINARY_DIR
}
/clhep_static_symlink
)
INSTALL
(
SCRIPT
${
CMAKE_CURRENT_BINARY_DIR
}
/clhep_shared_symlink
)
endmacro
(
clhep_build_libclhep
)
endmacro
(
clhep_build_libclhep
)
cmake/Modules/ClhepBuildTest.cmake
View file @
31a872f9
...
...
@@ -9,23 +9,31 @@ include(ClhepParseArgs)
macro
(
clhep_test testname
)
clhep_parse_args
(
CTST
"LIBS"
"SIMPLE;FAIL;NOLIB"
${
ARGN
}
)
# automake/autoconf variables for ${testname}.sh.in
set
(
srcdir
${
CMAKE_CURRENT_SOURCE_DIR
}
)
set
(
builddir
${
CMAKE_CURRENT_BINARY_DIR
}
)
set
(
srcdir
${
CMAKE_CURRENT_SOURCE_DIR
}
)
set
(
builddir
${
CMAKE_CURRENT_BINARY_DIR
}
)
if
(
CTST_NOLIB
)
set
(
package_library_list
)
set
(
package_library_list
)
else
()
set
(
package_library_list
${
PROJECT_BINARY_DIR
}
/lib/
${
CMAKE_STATIC_LIBRARY_PREFIX
}
CLHEP-
${
PACKAGE
}
-
${
VERSION
}${
CMAKE_STATIC_LIBRARY_SUFFIX
}
)
set
(
package_library_list
${
PACKAGE
}
S
)
#set( package_library_list ${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP-${PACKAGE}-${VERSION}${CMAKE_STATIC_LIBRARY_SUFFIX} )
endif
()
if
(
${
PACKAGE
}
_DEPS
)
foreach
(
dep
${${
PACKAGE
}
_DEPS
}
)
##message( STATUS "clhep_test ${testname} will use ${dep}")
list
(
APPEND package_library_list
${
PROJECT_BINARY_DIR
}
/lib/
${
CMAKE_STATIC_LIBRARY_PREFIX
}
CLHEP-
${
dep
}
-
${
VERSION
}${
CMAKE_STATIC_LIBRARY_SUFFIX
}
)
list
(
APPEND package_library_list
${
PACKAGE
}
S
)
#list(APPEND package_library_list ${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP-${dep}-${VERSION}${CMAKE_STATIC_LIBRARY_SUFFIX} )
endforeach
()
endif
()
link_libraries
(
${
package_library_list
}
)
##message( STATUS "building ${testname} from ${CMAKE_CURRENT_SOURCE_DIR} in ${CMAKE_CURRENT_BINARY_DIR}" )
ADD_EXECUTABLE
(
${
testname
}
${
testname
}
.cc
)
if
(
CTST_SIMPLE
)
add_test
(
${
testname
}
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
testname
}
)
if
(
CTST_FAIL
)
...
...
cmake/Modules/ClhepPackaging.cmake
0 → 100644
View file @
31a872f9
# - ClhepPackaging
#
# This module provides CPack configuration for CLHEP
#
# original code supplied by Ben Morgan Ben.Morgan@warwick.ac.uk
#----------------------------------------------------------------------------
# Package up needed system libraries - seems to only be needed on Windows
#
include
(
InstallRequiredSystemLibraries
)
#----------------------------------------------------------------------------
# General packaging setup - variables relevant to all package formats
# CLHEP use of version variables isn't optimal.
set
(
CPACK_PACKAGE_VERSION
${
VERSION
}
)
#set(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR})
#set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR})
#set(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH})
# We can't completely set the resource files yet - they need to be .txt,
# and the default GPL text isn't always handled correctly by self extracting
# sh files...
set
(
CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Class Library for High Energy Physics"
)
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.txt")
set
(
CPACK_PACKAGE_VENDOR
"CLHEP Project"
)
#set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.txt")
# We don't put the license in yet because the GPL text has quotes which make
# sh barf. We need to fix that, but at present I don't want to edit the GPL!
#set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
#----------------------------------------------------------------------------
# Source package settings
# Exclude VCS and standard temporary files from the source package.
# This is not perfected yet!
set
(
CPACK_SOURCE_IGNORE_FILES
${
CMAKE_BINARY_DIR
}
"~$"
"/CVS/"
"/.svn/"
"/
\\\\\\\\
.svn/"
"/.git/"
"/
\\\\\\\\
.git/"
"
\\\\\\\\
.swp$"
"
\\\\\\\\
.swp$"
"
\\\\
.swp"
"
\\\\\\\\
.#"
"/#"
)
# - Limit source packages to the three main types
set
(
CPACK_SOURCE_GENERATOR
"TGZ;TBZ2;ZIP"
)
#----------------------------------------------------------------------------
# Set name of CPACK_SYSTEM_NAME based on platform and architecture where
# needed. We do this because we may want to produce packages for, say,
# 32 and 64 bit arches on linux.
#
# N.B. This is all UNTESTED for the cross-compile case!!!
#
if
(
NOT DEFINED CPACK_SYSTEM_NAME
)
# Cygwin is always Cygwin...
if
(
"
${
CMAKE_SYSTEM_NAME
}
"
STREQUAL
"CYGWIN"
)
set
(
CPACK_SYSTEM_NAME Cygwin
)
else
()
if
(
UNIX AND NOT APPLE
)
# On Linux, try and find lsb_release
find_program
(
LSB_RELEASE_PROGRAM lsb_release DOC
"The Linux Standard Base system query tool"
)
if
(
LSB_RELEASE_PROGRAM
)
# We have linux, so incorporate Vendor info into package name
# - Distributor ID
exec_program
(
${
LSB_RELEASE_PROGRAM
}
ARGS -s -i OUTPUT_VARIABLE LSB_VENDOR
)
string
(
REGEX REPLACE
" "
"-"
LSB_VENDOR
${
LSB_VENDOR
}
)
string
(
TOLOWER
${
LSB_VENDOR
}
LSB_VENDOR
)
# - Distributor release
exec_program
(
${
LSB_RELEASE_PROGRAM
}
ARGS -s -r OUTPUT_VARIABLE LSB_RELEASE
)
string
(
TOLOWER
${
LSB_RELEASE
}
LSB_RELEASE
)
# Cache the vendor tag, because users might want to edit it
set
(
LSB_VENDOR_TAG
${
LSB_VENDOR
}
-
${
LSB_RELEASE
}
CACHE STRING
"LSB vendor tag for use in packaging"
)
set
(
CPACK_SYSTEM_NAME
${
CMAKE_SYSTEM_NAME
}
-
${
LSB_VENDOR_TAG
}
-
${
CMAKE_SYSTEM_PROCESSOR
}
)
mark_as_advanced
(
LSB_RELEASE_PROGRAM LSB_VENDOR_TAG
)
else
()
# Fallback to using NAME-ARCH on other UNICES other than Apple
set
(
CPACK_SYSTEM_NAME
${
CMAKE_SYSTEM_NAME
}
-
${
CMAKE_SYSTEM_PROCESSOR
}
)
endif
()
else
()
# On Mac, we use NAME-ARCH, but ARCH is 'Universal' if more than
# one arch is built for. Note that falling back to use
# CMAKE_SYSTEM_PROCESSOR may *not* be 100% reliable.
list
(
LENGTH CMAKE_OSX_ARCHITECTURES _number_of_arches
)
if
(
NOT _number_of_arches
)
# - Default
set
(
CPACK_SYSTEM_NAME
${
CMAKE_SYSTEM_NAME
}
-
${
CMAKE_SYSTEM_PROCESSOR
}
)
elseif
(
_number_of_arches GREATER 1
)
# - Universal
set
(
CPACK_SYSTEM_NAME
${
CMAKE_SYSTEM_NAME
}
-Universal
)
else
()
# - Use what the user specified
set
(
CPACK_SYSTEM_NAME
${
CMAKE_SYSTEM_NAME
}
-
${
CMAKE_OSX_ARCHITECTURES
}
)
endif
()
endif
()
endif
()
endif
()
# On Windows, distinguish x64 and x86 - not sure this is really needed yet!!!
if
(
"
${
CPACK_SYSTEM_NAME
}
"
MATCHES Windows
)
if
(
CMAKE_CL_64
)
set
(
CPACK_SYSTEM_NAME win64-x64
)
else
()
set
(
CPACK_SYSTEM_NAME win32-x86
)
endif
()
endif
()
#----------------------------------------------------------------------------
# Finally, include the base CPack configuration
#
include
(
CPack
)
cmake/Modules/ClhepToolchain.cmake
0 → 100644
View file @
31a872f9
#----------------------------------------------------------------------------
# Finally, we can configure the toolchain files for build and install
# directories.
#
# Toolchains:
# - CMake via use of 'CLHEPConfig.cmake'
# - pkgconfig via 'clhep.pc'
#
# We only do this for the main CLHEP library to illustrate the basic
# pattern. It can be extended to handle the component packages, but this
# is more complex and would hide the basic concepts.
#
# Both are fully relocatable, like clhep-config, so can be distributed in
# relocatable binary packages.
# code supplied by Ben Morgan Ben.Morgan@warwick.ac.uk
macro
(
clhep_toolchain
)
#----------------------------------------------------------------------------
# - First we handle the build tree
# This setup allows a build of CLHEP to be used directly *without* installing
# it. This allows several useful development patterns, such as checking an
# application using CLHEP works with different versions/tag sets.
#
# First we set the needed variables
set
(
CLHEP_VERSION
${
VERSION
}
)
set
(
CLHEP_DEFINITIONS
)
set
(
CLHEP_INCLUDE_DIR
${
PROJECT_BINARY_DIR
}
)
# Now we configure the CLHEPConfig and CLHEPConfigVersion file templates,
# outputting to the top level of the build tree.
# This allows users to 'point' CMake to the build by something like
#
# # Some CMakeLists.txt
# ...
# find_package(CLHEP 2.1.0.1 REQUIRED)
#
# in their buildscript, and then pointing cmake to the build directory via
#
# cmake -DCLHEP_DIR=/path/to/clhep/build /path/to/source/of/app
#
configure_file
(
${
PROJECT_SOURCE_DIR
}
/cmake/Templates/CLHEPConfigVersion.cmake.in
${
PROJECT_BINARY_DIR
}
/CLHEPConfigVersion.cmake
@ONLY
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/cmake/Templates/CLHEPConfig.cmake.in
${
PROJECT_BINARY_DIR
}
/CLHEPConfig.cmake
@ONLY
)
# We 'export' the main CLHEP library targets from the build tree.
# This file is include()d by CLHEPConfig.cmake
export
(
TARGETS CLHEP CLHEPS
FILE
${
PROJECT_BINARY_DIR
}
/CLHEPLibraryDepends.cmake
)
# Now we configure clhep.pc.
# In the build tree we hardcode all paths, as we never need to relocate
# a build tree
#
set
(
CLHEP_PKGCONFIG_PREFIX
${
PROJECT_BINARY_DIR
}
)
set
(
CLHEP_PKGCONFIG_INCLUDEDIR
${
CLHEP_INCLUDE_DIR
}
)
set
(
CLHEP_PKGCONFIG_LIBDIR
${
PROJECT_BINARY_DIR
}
/lib
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/cmake/Templates/clhep.pc.in
${
PROJECT_BINARY_DIR
}
/clhep.pc
@ONLY
)
#----------------------------------------------------------------------------
# - Now we handle the installation tree
#
# Again we set the needed variable first. Not all have actually changed,
# but we set again for clarity and just to be sure.
set
(
CLHEP_VERSION
${
VERSION
}
)
set
(
CLHEP_DEFINITIONS
)
# The setup of the include dir is slightly different because we want
# to make the install relocatable (Current CLHEP setup *is* relocatable).
# We use a relative path from the directory where the CLHEPConfig.cmake
# file is installed to the actual include dir.
file
(
RELATIVE_PATH _relincpath
${
CMAKE_INSTALL_PREFIX
}
/lib/CLHEP-
${
VERSION
}
${
CMAKE_INSTALL_PREFIX
}
/include
)
set
(
CLHEP_INCLUDE_DIR
"
\$
{_thisdir}/
${
_relincpath
}
"
)
# Now we configure the CLHEPConfig and CLHEPConfigVersion file templates,
# outputting to a directory in the build directory. This is simply a
# placeholder to store them until we install later.
configure_file
(
${
PROJECT_SOURCE_DIR
}
/cmake/Templates/CLHEPConfigVersion.cmake.in
${
PROJECT_BINARY_DIR
}
/InstallTreeFiles/CLHEPConfigVersion.cmake
@ONLY
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/cmake/Templates/CLHEPConfig.cmake.in
${
PROJECT_BINARY_DIR
}
/InstallTreeFiles/CLHEPConfig.cmake
@ONLY
)
# Also configure the pkgconfig file, again outputting to a directory under
# the build directory ready for installation
# Now we use the 'pcfiledir' variable of pkg-config - this tells us the
# directory where clhep.pc is located. Since we know we'll install clhep.pc
# in CMAKE_INSTALL_PREFIX/lib/pkgconfig, we can calculate relative paths
# to the include and lib dirs.... This make the pc file fully relocatable!!
# If you later use GNUInstallDirs.cmake, this would need more work to
# ensure accurate calculation of the relative path.
set
(
CLHEP_PKGCONFIG_PREFIX
"
\$
{pcfiledir}/../.."
)
set
(
CLHEP_PKGCONFIG_LIBDIR
"
\$
{prefix}/lib"
)
set
(
CLHEP_PKGCONFIG_INCLUDEDIR
"
\$
{prefix}/include"
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/cmake/Templates/clhep.pc.in
${
PROJECT_BINARY_DIR
}
/InstallTreeFiles/clhep.pc
@ONLY
)
# - Install the config files, and 'install export' the library depends file
# The choice of 'lib/CLHEP-<VERSION>' is based on the recommendations
# in the CMake documentation for find_package on UNIX so that
# CMake can potentially find the Config file automatically. We don't
# consider the Apple case because we don't (yet) build CLHEP as a Framework.
# The Windows case can be easily added later.
# The location can of course be modified if you wish.
install
(
FILES
${
PROJECT_BINARY_DIR
}
/InstallTreeFiles/CLHEPConfigVersion.cmake
${
PROJECT_BINARY_DIR
}
/InstallTreeFiles/CLHEPConfig.cmake
DESTINATION lib/CLHEP-
${
VERSION
}
)
install
(
EXPORT CLHEPLibraryDepends DESTINATION lib/CLHEP-
${
VERSION
}
)
# Install the pkg-config file. The choice of 'lib/pkgconfig' for the
# installation seems fairly standard.
install
(
FILES
${
PROJECT_BINARY_DIR
}
/InstallTreeFiles/clhep.pc
DESTINATION lib/pkgconfig
)
# - And we should be done...
endmacro
(
clhep_toolchain
)
cmake/Templates/CLHEPConfig.cmake.in
0 → 100644
View file @
31a872f9
# - Config file for the CLHEP package
# It defines the following variables
# CLHEP_INCLUDE_DIRS - include directories for CLHEP
# CLHEP_DEFINITIONS - compile definitions needed to use CLHEP
# CLHEP_LIBRARIES - libraries to link against
#
# CLHEP is built concurrently as a single library and as a set of component
# libraries. At present, this config file is only designed to configure
# the single main library in static or shared mode.
#
# The following per-component variables are set:
#
# CLHEP_${COMPONENT}_FOUND True if CLHEP library mode "component"
# was found
#
# CLHEP_${COMPONENT}_LIBRARY Contains the library for specified mode
# "component"
#
# CLHEP current only supports two components: static and shared, which
# represent the two possible library modes that the main CLHEP library
# is built in.
#
# You can call find_package with 'static' or 'shared' as component arguments
# to pick a particular library mode of CLHEP. For example
#
# find_package(CLHEP REQUIRED static)
#
# will set CLHEP_LIBRARIES to the CLHEP static library.
#
# If you do not specify a shared or static component argument, shared
# libraries will be selected by default.
#
# ===========================================================================
# Variables used by this module which can change the default behaviour of
# this module. They need to be set prior to the call to find_package
#
# CLHEP_CONFIG_DEBUG - If set, this will enable some output from this module
# to help in debugging it behaviour
#
#----------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Print out values of the variables that we expect find_package to have passed
# to us. This is useful for developers of CLHEPConfig!
#
if(CLHEP_CONFIG_DEBUG)
message(STATUS "CLHEPDebug : CLHEP_VERSION = ${CLHEP_VERSION}")
message(STATUS "CLHEPDebug : CLHEP_FIND_VERSION = ${CLHEP_FIND_VERSION}")
message(STATUS "CLHEPDebug : CLHEP_FIND_REQUIRED = ${CLHEP_FIND_REQUIRED}")
message(STATUS "CLHEPDebug : CLHEP_FIND_QUIETLY = ${CLHEP_FIND_QUIETLY}")
message(STATUS "CLHEPDebug : CLHEP_FIND_COMPONENTS = ${CLHEP_FIND_COMPONENTS}")
foreach(_cpt ${CLHEP_FIND_COMPONENTS})
message(STATUS "CLHEPDebug : CLHEP_FIND_REQUIRED_${_cpt} = ${CLHEP_FIND_REQUIRED_${_cpt}}")