CLHEP  2.4.7.2
C++ Class Library for High Energy Physics
README.md
Go to the documentation of this file.
1 CLHEP C++ Class Library for High Energy Physics
2 ===============================================
3 
4 - [CLHEP Home Page](http://proj-clhep.web.cern.ch/proj-clhep/)
5 - [Git Repository] (https://gitlab.cern.ch/CLHEP/CLHEP.git)
6 - [Bug Reports and Feature Requests](https://its.cern.ch/jira/browse/CLHEP/)
7 
8 Installing CLHEP
9 ================
10 Prerequisites
11 -------------
12 - Linux/OS X/BSD/Windows OS
13 - C++11 compliant compiler (GCC >= 4.8, Clang >= 3.3, Intel >= 15, MSVC >= 19)
14  - If the Intel compiler is used with GCC compatibility, it should be configured
15  to use GCC 4.8 or higher
16 - [CMake](http://www.cmake.org) >= 3.2
17 
18 Building CLHEP with CMake
19 -------------------------
20 At this time, the cmake build system only supports building CLHEP as a
21 complete package, starting from the top level directory. Note, however,
22 that individual package libraries will still be build.
23 
24 Unwind the source code tar ball in some relevant directory. Determine a prefix
25 under which CLHEP should be installed. Create a build directory that is
26 NOT in the source code directory tree (i.e. the tree rooted where this README
27 resides).
28 
29 ```
30 $ cd <build_directory>
31 $ cmake -DCMAKE_INSTALL_PREFIX=<install_dir> <source_code_dir>
32 $ cmake --build . --config RelWithDebInfo
33 $ ctest
34 $ cmake --build . --target install
35 ```
36 
37 The above will configure the build, compile CLHEP libraries with optimization and
38 debugging symbols, run the test suite and finally install the CLHEP binaries and
39 headers under the chosen install prefix.
40 
41 Additional CMake Options
42 ------------------------
43 The following arguments may be passed to CMake at the configuration stage either
44 via the command line or the `cmake-gui` and `ccmake` interfaces.
45 
46 - `-DCMAKE_INSTALL_PREFIX=/install/path`
47  - Change prefix under which to install CLHEP
48  - Defaults to `/usr/local` on UNIX platforms
49 - `-DCLHEP_BUILD_CXXSTD=-std=c++NM`
50  - Compile CLHEP against C++ Standard `NM`
51  - Defaults to `11`
52  - `NM` can be chosen from `11`, `1y` or `14`.
53 - `-DLIB_SUFFIX=<S>`
54  - installs the libraries in a `lib<S>` subdirectory of the
55  install prefix
56 - `-DCLHEP_BUILD_DOCS=ON`
57  - Build and install CLHEP documentation
58  - Requires [Doxygen](http://www.doxygen.org) and a LaTeX compiler
59 
60 The compiler discovered and used by CMake to build CLHEP may be
61 selected either by setting the `CC` and `CXX` shell/environment variables
62 to point to the required compilers, or by the CMake variables
63 `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`. Note that you *should not*
64 change the discovered compiler after initial configuration. If you
65 require concurrent builds against different compilers, use separate
66 build directories for each compiler.
67 
68 Building CLHEP from Git
69 -----------------------
70 To work with the head:
71 
72 ```
73 $ git clone https://gitlab.cern.ch/CLHEP/CLHEP.git
74 ```
75 
76 To work with a tag:
77 
78 ```
79 $ git clone https://gitlab.cern.ch/CLHEP/CLHEP.git
80 ... Use "git tag" to see the available tags.
81 $ git co <tag>
82 ```
83 
84 Now continue with the build instructions as if you unpacked a source code tarball.
85 
86 
87 Building Projects using CLHEP
88 =============================
89 About Linking
90 -------------
91 CLHEP builds libraries for each package in addition to a single CLHEP library.
92 This alllows you to link with only the necessary parts of CLHEP.
93 We provide a set of <package>-config scripts which give the list of
94 libraries to link, in the correct order.
95 The script can be embedded in a makefile.
96 ```
97  clhep-config --libs - link list of ALL CLHEP libraries
98  <package>-config --libs - link list of ONLY those libraries
99  needed to use <package>
100 ```
101 Using CMake
102 -----------
103 If your project uses CMake as its buildtool, CLHEP installs a CMake
104 "Package Config" file that can be used by CMake's `find_package` command.
105 When found, this file will set up CMake imported targets for the CLHEP
106 libraries which may then be linked to. For example, to create an
107 executable that uses CLHEP headers and libraries, your CMake script
108 would do
109 
110 ```cmake
111 ...
112 find_package(CLHEP REQUIRED)
113 
114 add_executable(MyProgram MyProgram.cc)
115 target_link_libraries(MyProgram CLHEP::CLHEP)
116 ```
117 
118 Here `CLHEP::CLHEP` is the imported target for the full CLHEP shared library.
119 CMake will handle setting up header and library paths for you. The static
120 variant of the library may also be linked using the `CLHEP::CLHEPS` imported
121 target:
122 
123 ```cmake
124 ...
125 find_package(CLHEP REQUIRED)
126 
127 add_executable(MyProgram MyProgram.cc)
128 target_link_libraries(MyProgram CLHEP::CLHEPS)
129 ```
130 
131 Imported targets also exist for the CLHEP component libraries:
132 
133 ```cmake
134 ...
135 target_link_libraries(MyProgram CLHEP::Vector CLHEP::Random)
136 ```
137 
138 You only need to list the components you need as CMake will resolve and
139 ensure linking on any additional components required by those you have selected.
140 Static variants, e.g. `CLHEP::VectorS`, also exist for the components.
141 
142 If you installed CLHEP to a non-standard prefix, you may need to
143 add this location to the `CMAKE_PREFIX_PATH` in order for CMake to locate CLHEP.
144 This may be done either by passing `CMAKE_PREFIX_PATH` with the location as a
145 command line argument to `cmake` or by setting `CMAKE_PREFIX_PATH` in the
146 environment (as a PATH style variable).
147 
148 Using `pkg-config`
149 ------------------
150 If your project uses `pkg-config` to locate build dependencies, CLHEP installs
151 `.pc` files for both the full and component CLHEP libraries. The standard
152 `pkg-config` commands may be used to discover required compiler and liker
153 flags, for example
154 
155 ```
156 $ pkg-config --cflags --libs clhep
157 ```
158 
159 or for component libraries
160 
161 ```
162 $ pkg-config --cflags --libs clhep-vector clhep-random
163 ```
164 
165 If you installed CLHEP to a non-standard location, you may need to add the
166 directory holding the `.pc` files (`<CMAKE_INSTALL_PREFIX>/lib<LIB_SUFFIX>/pkgconfig`)
167 to the `PKG_CONFIG_PATH` environment variable.
168