Skip to content

Commit 5ca18c7

Browse files
guitargeekanigamova
authored andcommitted
Update CMake standalone compilation instructions
1 parent 763c733 commit 5ca18c7

File tree

2 files changed

+43
-52
lines changed

2 files changed

+43
-52
lines changed

docs/index.md

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -116,52 +116,57 @@ scramv1 b clean; scramv1 b -j$(nproc --ignore=2) # always make a clean build, wi
116116

117117
#### Standalone compilation
118118

119-
The standalone version can be easily compiled using
120-
[cvmfs](https://cernvm.cern.ch/fs/) as it relies on dependencies that are
121-
already installed at `/cvmfs/cms.cern.ch/`. Access to `/cvmfs/cms.cern.ch/` can
122-
be obtained from lxplus machines or via `CernVM`. See [CernVM](CernVM.md) for
123-
further details on the latter. In case you do not want to use the `cvmfs`
124-
area, you will need to adapt the locations of the dependencies listed in both
125-
the `Makefile` and `env_standalone.sh` files.
119+
Combine can be built as a CMake project. It has four required dependencies on the C++ side:
126120

127-
```
128-
git clone https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit
129-
cd HiggsAnalysis/CombinedLimit/
130-
# git checkout <some release>
131-
. env_standalone.sh
132-
make -j 4
133-
```
121+
1. [ROOT](https://root.cern), mostly for RooFit
122+
2. The [boost](https://www.boost.org) library, for command line options parsing
123+
3. [Eigen](https://eigen.tuxfamily.org) for linear algebra, used in the `CMSInterferenceFunc` and `RooSplineND`
134124

135-
You will need to source `env_standalone.sh` each time you want to use the package, or add it to your login environment.
125+
There are two more optional dependencies:
136126

137-
##### Compilation of slc7 compatible versions
127+
1. The [vdt](https://github.com/dpiparo/vdt) library for fast vectorized math (can be disabled with the CMake configuration option `-DUSE_VDT=FALSE`)
128+
2. The [gtest](https://github.com/google/googletest) library for unit tests, if you build with `-DBUILD_TESTS=TRUE`
138129

139-
For <span style="font-variant:small-caps;">Combine</span> versions before v10 release you will need to do the compilation in an slc7 environment using apptainer. You can then source the standalone script outside of the apptainer.
140-
On lxplus this can be done as follows:
130+
Any environment that provides the dependencies can be used to build combine.
141131

132+
To build, run the following commands inside the cloned repository:
133+
```bash
134+
mkdir build
135+
cd build
136+
cmake .. # additional CMake configuration options like -DUSE_VDT=FALSE go here
137+
cmake --build . -j8
138+
cd ..
142139
```
143-
git clone https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit
144-
cd HiggsAnalysis/CombinedLimit/
145-
# git checkout <some release>
146-
cmssw-el7
147-
. env_standalone.sh
148-
make -j 4
149-
exit
150-
source . env_standalone.sh
140+
141+
To use your build of Combine, you have to append to the following environment variables:
142+
```bash
143+
export PATH=$PWD/build/bin:$PATH
144+
export LD_LIBRARY_PATH=$PWD/build/lib:$LD_LIBRARY_PATH
145+
export PYTHONPATH=$PWD/build/python:$PYTHONPATH
151146
```
152147

148+
For advanced users or packagers who want to install the build, there are some more relevant options to steer the CMake installation step:
149+
150+
* `CMAKE_INSTALL_BINDIR`: the binary directory inside the install prefix for `combine` and Python scripts like `text2workspace.py` (`bin/` by default)
151+
* `CMAKE_INSTALL_LIBDIR`: shared library directory (`lib/` by default)
152+
* `CMAKE_INSTALL_PYTHONDIR`: python module directory (`python/` by default)
153+
* `CMAKE_INSTALL_INCLUDEDIR`: header file directory (`include/` by default)
154+
153155
##### Standalone compilation with LCG
154-
For compilation outside of CMSSW, for example to use ROOT versions not yet available in CMSSW, one can compile against LCG releases:
155-
```sh
156-
git clone https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit
157-
cd HiggsAnalysis/CombinedLimit
158-
source env_lcg.sh
159-
mkdir build
160-
cd build
161-
cmake ..
162-
make -j8
156+
157+
A typical environment that can be used on `lxplus` is the [LCG software stack](https://lcginfo.cern.ch/).
158+
159+
It can be activated as follows
160+
```bash
161+
LCG_RELEASE=LCG_106 # includes ROOT 6.32, like CMSSW_14_1_0_pre4
162+
# LCG_RELEASE=dev3/latest # includes nightly build of ROOT master, useful for development
163+
LCG_PATH=/cvmfs/sft.cern.ch/lcg/views/$LCG_RELEASE/x86_64-el9-gcc13-opt
164+
165+
source $LCG_PATH/setup.sh
166+
source $LCG_PATH/bin/thisroot.sh
163167
```
164-
To change the LCG version, edit `env_lcg.sh`.
168+
169+
After activating the environment, you can follow the usual CMake build procedure explained above.
165170

166171
##### Standalone compilation with `conda` (CMake-based)
167172
This recipe mirrors the setup used in our GitHub Actions builds and works on both Linux and macOS (Intel or Apple silicon):
@@ -179,9 +184,8 @@ conda create -n combine python=3.12 root=6.34 gsl boost-cpp vdt eigen tbb cmake
179184
conda activate combine
180185
181186
# configure and build with CMake
182-
PYTHON_SITELIB=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))")
183-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DPython_SITELIB=${PYTHON_SITELIB}
184-
cmake --build build -j$(python -c "import multiprocessing; print(max(1, multiprocessing.cpu_count()))")
187+
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_INSTALL_PYTHONDIR=lib/python3.12/site-packages -DUSE_VDT=OFF
188+
cmake --build build -j$(nproc --ignore=2)
185189
cmake --install build
186190
```
187191

env_lcg.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)