CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
|
At this time, the cmake build system only supports building CLHEP as a complete package, starting from the top level directory. Note, however, that individual package libraries will still be build.
Unwind the source code tar ball in some relevant directory. Determine a prefix under which CLHEP should be installed. Create a build directory that is NOT in the source code directory tree (i.e. the tree rooted where this README resides).
The above will configure the build, compile CLHEP libraries with optimization and debugging symbols, run the test suite and finally install the CLHEP binaries and headers under the chosen install prefix.
The following arguments may be passed to CMake at the configuration stage either via the command line or the cmake-gui
and ccmake
interfaces.
-DCMAKE_INSTALL_PREFIX=/install/path
/usr/local
on UNIX platforms-DCLHEP_BUILD_CXXSTD=-std=c++NM
NM
11
NM
can be chosen from 11
, 1y
or 14
.-DLIB_SUFFIX=<S>
lib<S>
subdirectory of the install prefix-DCLHEP_BUILD_DOCS=ON
The compiler discovered and used by CMake to build CLHEP may be selected either by setting the CC
and CXX
shell/environment variables to point to the required compilers, or by the CMake variables CMAKE_C_COMPILER
and CMAKE_CXX_COMPILER
. Note that you should not change the discovered compiler after initial configuration. If you require concurrent builds against different compilers, use separate build directories for each compiler.
To work with the head:
To work with a tag:
Now continue with the build instructions as if you unpacked a source code tarball.
CLHEP builds libraries for each package in addition to a single CLHEP library. This alllows you to link with only the necessary parts of CLHEP. We provide a set of <package>-config scripts which give the list of libraries to link, in the correct order.
The script can be embedded in a makefile.
If your project uses CMake as its buildtool, CLHEP installs a CMake "Package Config" file that can be used by CMake's find_package
command. When found, this file will set up CMake imported targets for the CLHEP libraries which may then be linked to. For example, to create an executable that uses CLHEP headers and libraries, your CMake script would do
Here CLHEP::CLHEP
is the imported target for the full CLHEP shared library. CMake will handle setting up header and library paths for you. The static variant of the library may also be linked using the CLHEP::CLHEPS
imported target:
Imported targets also exist for the CLHEP component libraries:
You only need to list the components you need as CMake will resolve and ensure linking on any additional components required by those you have selected. Static variants, e.g. CLHEP::VectorS
, also exist for the components.
If you installed CLHEP to a non-standard prefix, you may need to add this location to the CMAKE_PREFIX_PATH
in order for CMake to locate CLHEP. This may be done either by passing CMAKE_PREFIX_PATH
with the location as a command line argument to cmake
or by setting CMAKE_PREFIX_PATH
in the environment (as a PATH style variable).
pkg-config
If your project uses pkg-config
to locate build dependencies, CLHEP installs .pc
files for both the full and component CLHEP libraries. The standard pkg-config
commands may be used to discover required compiler and liker flags, for example
or for component libraries
If you installed CLHEP to a non-standard location, you may need to add the directory holding the .pc
files (<CMAKE_INSTALL_PREFIX>/lib<LIB_SUFFIX>/pkgconfig
) to the PKG_CONFIG_PATH
environment variable.