Back to home page

EIC code displayed by LXR

 
 

    


Warning, /jana2/docs/install.md is written in an unsupported language. File is not indexed.

0001 
0002 
0003 ### Building JANA
0004 
0005 First, set your `$JANA_HOME` environment variable. This is where the executables, libraries, headers, and plugins
0006 get installed. (It is also where we will clone the source). CMake will install to `$JANA_HOME` if it is set (it
0007 will install to `${CMAKE_BINARY_DIR}/install` if not). Be aware that although CMake usually defaults
0008 `CMAKE_INSTALL_PREFIX` to `/usr/local`, we have disabled this because we rarely want this in practice, and we
0009 don't want the build system picking up outdated headers and libraries we installed to `/usr/local` by accident.
0010 If you want to set `JANA_HOME=/usr/local`, you are free to do so, but you must do so deliberately.
0011 
0012 Next, set your build directory. This is where CMake's caches, logs, intermediate build artifacts, etc go. The convention
0013 is to name it `build` and put it in the project's root directory. If you are using CLion, it will automatically create 
0014 a `cmake-build-debug` directory which works just fine. 
0015 
0016 Finally, you can cd into your build directory and build and install everything the usual CMake way.
0017 
0018 ```bash
0019 git clone https://github.com/JeffersonLab/JANA2
0020 
0021 cd JANA2
0022 mkdir build                                         # Create build dir
0023 cmake -S . -B build -DCMAKE_INSTALL_PREFIX=`pwd`    # Generate make scripts
0024 cmake --build build --target install -j 8           # Build and install (using 8 threads)
0025 
0026 source ${JANA_HOME}/bin/jana-this.sh                # Set PATH (and other envars)
0027 jana -Pplugins=JTest                                # Run JTest plugin to verify successful install
0028 ```
0029 
0030 Note: If you want to use a compiler other than the default one on your system, it is not enough to modify your
0031 `$PATH`, as CMake ignores this by design. You either need to set the `CXX` environment variable or the 
0032 `CMAKE_CXX_COMPILER` CMake variable.
0033 
0034 By default, JANA will look for plugins under `$JANA_HOME/plugins`. For your plugins to propagate here, you have to `install`
0035 them. If you don't want to do that, you can also set the environment variable `$JANA_PLUGIN_PATH` to point to the build
0036 directory of your project. JANA will report where exactly it went looking for your plugins and what happened when it tried
0037 to load them if you set the JANA config `jana:debug_plugin_loading=1`.
0038 
0039 ```bash
0040 jana -Pplugins=JTest -Pjana:debug_plugin_loading=1
0041 ```
0042 
0043 ### Using JANA in a CMake project
0044 
0045 To use JANA in a CMake project, simply add `$JANA_HOME/lib/cmake/JANA` to your `CMAKE_PREFIX_PATH`,
0046 or alternatively, set the CMake variable `JANA_DIR=$JANA_HOME/lib/cmake/JANA`.
0047 
0048 ### Using JANA in a non-CMake project
0049 
0050 To use JANA in a non-CMake project:
0051 1. Source `$JANA_HOME/bin/jana-this.sh` to set the environment variables needed for JANA's dependencies
0052 2. Use `$JANA_HOME/bin/jana-config --cflags` to obtain JANA's compiler flags
0053 3. Use `$JANA_HOME/bin/jana_config --libs` to obtain JANA's linker flags
0054 
0055 
0056 ### Using non standard system compiler
0057 
0058 CMake by design won't use `$PATH` to find the compiler. You either need to set the `CXX` environment variable or 
0059 the `CMAKE_CXX_COMPILER` CMake variable. 
0060 
0061 Another option is use <a href="https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html" target="_blank">CMakePresets.json</a>,
0062 a file that has to be placed in CMake root directory and that may contain additional options.