Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309083
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Subscribers
None
View Options
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b40d944..73f6dc2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,274 +1,305 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project("HEJ" VERSION 2.0.6 LANGUAGES C CXX)
## User settings
include(CMakeDependentOption)
option(EXCLUDE_QCDloop "Do not include QCDloop" FALSE)
option(EXCLUDE_HighFive "Do not include HighFive" FALSE)
option(EXCLUDE_HepMC "Do not include HepMC version 2" FALSE)
option(EXCLUDE_HepMC3 "Do not include HepMC version 3" FALSE)
option(EXCLUDE_ROOT "Do not include ROOT" TRUE)
# Only skip rivet if we both HepMC 2 & 3 are excluded, since we don't know which
# HepMC version rivet needs
CMAKE_DEPENDENT_OPTION(EXCLUDE_rivet "Do not include rivet" FALSE
"NOT EXCLUDE_HepMC OR NOT EXCLUDE_HepMC3" TRUE)
option(BUILD_EXAMPLES "Build examples" FALSE)
option(TEST_ALL "Run additional (longer) tests" FALSE)
option(TEST_COVERAGE "Generate test coverage with \"gcovr\"" FALSE)
option(RUN_CLANG_TIDY "Run clang tidy" FALSE)
# Set a default build type if none was specified
set(default_build_type "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
## Global flags for the compiler (all warnings)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
+## Check if this is a git folder
+find_package(Git QUIET)
+if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
+ set(_is_git TRUE)
+endif()
+
+## download FORM submodule
+# from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
+if(_is_git)
+ option(GIT_SUBMODULE "Check submodules during build" ON)
+ if(GIT_SUBMODULE
+ AND NOT EXISTS "${PROJECT_SOURCE_DIR}/current_generator/form/Makefile.am")
+ message(STATUS "Submodule update")
+ execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE GIT_SUBMOD_RESULT)
+ if(NOT GIT_SUBMOD_RESULT EQUAL "0")
+ message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
+ endif()
+ endif()
+endif()
+
+if(NOT EXISTS "${PROJECT_SOURCE_DIR}/current_generator/form/Makefile.am")
+ message(FATAL_ERROR "FORM was not downloaded! Please update git-submodules and try again.")
+endif()
+
## Create Version
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Get the latest abbreviated commit hash of the working branch
-execute_process(
- COMMAND git rev-parse HEAD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE PROJECT_GIT_REVISION
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-# Get the current working branch
-execute_process(
- COMMAND git rev-parse --abbrev-ref HEAD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE PROJECT_GIT_BRANCH
- OUTPUT_STRIP_TRAILING_WHITESPACE
+if(_is_git)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE PROJECT_GIT_REVISION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
)
+ # Get the current working branch
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE PROJECT_GIT_BRANCH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+else()
+ set(PROJECT_GIT_REVISION "UNKNOWN")
+ set(PROJECT_GIT_BRANCH "UNKNOWN")
+endif()
## target directories for install
set(INSTALL_INCLUDE_DIR_BASE include)
set(INSTALL_INCLUDE_DIR ${INSTALL_INCLUDE_DIR_BASE}/HEJ)
set(INSTALL_BIN_DIR bin)
set(INSTALL_LIB_DIR lib)
set(INSTALL_CONFIG_DIR lib/cmake/HEJ)
## find dependencies
find_package(CLHEP 2.3 REQUIRED)
find_package(fastjet REQUIRED)
find_package(LHAPDF 6 REQUIRED)
## Amend unintuitive behaviour of FindBoost.cmake
## Priority of BOOST_ROOT over BOOSTROOT matches FindBoost.cmake
## at least for cmake 3.12
if(DEFINED BOOST_ROOT)
message("BOOST_ROOT set - only looking for Boost in ${BOOST_ROOT}")
set(Boost_NO_BOOST_CMAKE ON)
elseif(DEFINED BOOSTROOT)
message("BOOSTROOT set - only looking for Boost in ${BOOSTROOT}")
set(Boost_NO_BOOST_CMAKE ON)
endif()
find_package(Boost REQUIRED COMPONENTS iostreams)
find_package(yaml-cpp) # requiring yaml does not work with fedora
if(EXCLUDE_HepMC)
message(STATUS "Skipping HepMC")
else()
find_package(HepMC 2 EXACT)
endif()
if(EXCLUDE_HepMC3)
message(STATUS "Skipping HepMC3")
else()
## version 3.1: Finding version not possible in 3.1.1, see HepMC3 git 29e7a6c3
find_package(HepMC3 QUIET) # suppress CMake warning if HepMC3 not available
## print standard message
find_package_handle_standard_args( HepMC3
FOUND_VAR
HepMC3_FOUND
REQUIRED_VARS
HEPMC3_INCLUDE_DIR
HEPMC3_LIBRARIES
# VERSION_VAR
# HEPMC3_VERSION
)
endif()
if(EXCLUDE_rivet)
message(STATUS "Skipping rivet")
else()
find_package(rivet)
if(rivet_FOUND)
if(rivet_USE_HEPMC3 AND NOT HepMC3_FOUND)
message(FATAL_ERROR "Rivet was compiled with HepMC version 3, "
"but HepMC3 was not found!")
elseif(NOT rivet_USE_HEPMC3 AND NOT HepMC_FOUND)
message(FATAL_ERROR "Rivet was compiled with HepMC version 2, "
"but HepMC2 was not found!")
endif()
endif()
endif()
if(EXCLUDE_QCDloop)
message(STATUS "Skipping QCDloop")
else()
find_package(QCDloop 2)
endif()
if(NOT EXCLUDE_ROOT)
# Don't print "Skipping ROOT" for default option (EXCLUDE_ROOT=TRUE)
find_package(ROOT 6.14) # root targets are broken before 6.14
find_package_handle_standard_args( ROOT
FOUND_VAR
ROOT_FOUND
REQUIRED_VARS
ROOT_INCLUDE_DIRS
ROOT_LIBRARIES
VERSION_VAR
ROOT_VERSION
)
endif()
if(EXCLUDE_HighFive)
message(STATUS "Skipping HighFive")
else()
find_package(HighFive QUIET)
find_package_handle_standard_args( HighFive CONFIG_MODE )
endif()
include(RepairTargets) # more reliable cmake targets
## Save dependencies for templates
set(HEJ_BUILD_WITH_HepMC2 ${HepMC_FOUND})
set(HEJ_BUILD_WITH_HepMC3 ${HepMC3_FOUND})
set(HEJ_BUILD_WITH_RIVET ${rivet_FOUND})
if(rivet_FOUND AND rivet_VERSION VERSION_LESS 3)
set(HEJ_USE_RIVET2 TRUE)
endif()
set(HEJ_BUILD_WITH_QCDLOOP ${QCDloop_FOUND})
set(HEJ_BUILD_WITH_HDF5 ${HighFive_FOUND})
## Template files
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in
include/HEJ/Version.hh @ONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/ConfigFlags.hh.in
include/HEJ/ConfigFlags.hh @ONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/HEJ-config.cc.in
src/bin/HEJ-config.cc @ONLY )
# Generate CMake config file
include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/Templates/hej-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config.cmake
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
PATH_VARS INSTALL_INCLUDE_DIR_BASE INSTALL_LIB_DIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config-version.cmake
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config-version.cmake
DESTINATION ${INSTALL_CONFIG_DIR})
## shortcut for HEJ specific includes
set(HEJ_INCLUDE_DIR
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
if (TEST_COVERAGE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) )
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
set(COVERAGE_GCOVR_EXCLUDES "${PROJECT_SOURCE_DIR}/include/LHEF/*"
"${PROJECT_SOURCE_DIR}/include/cxxopts.hpp"
"${PROJECT_SOURCE_DIR}/t/*"
"${PROJECT_BINARY_DIR}/*")
SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML(
NAME ctest_coverage
EXECUTABLE ctest
)
endif()
add_subdirectory(current_generator)
## create main HEJ library
add_subdirectory(src)
## define executable
add_executable(HEJ_main src/bin/HEJ.cc)
set_target_properties(HEJ_main PROPERTIES OUTPUT_NAME "HEJ")
## link libraries
target_link_libraries(HEJ_main HEJ)
add_executable(HEJ-config src/bin/HEJ-config.cc)
target_include_directories(HEJ-config PRIVATE ${HEJ_INCLUDE_DIR})
file(GLOB hej_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/HEJ/*.hh
${PROJECT_BINARY_DIR}/include/HEJ/*.hh
)
file(GLOB hej_detail_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/HEJ/detail/*.hh)
file(GLOB lhef_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/LHEF/*.h)
install(FILES ${hej_headers} DESTINATION ${INSTALL_INCLUDE_DIR})
install(FILES ${hej_detail_headers} DESTINATION ${INSTALL_INCLUDE_DIR}/detail/)
install(FILES ${lhef_headers} DESTINATION ${INSTALL_INCLUDE_DIR_BASE}/LHEF/)
install(TARGETS HEJ_main HEJ-config DESTINATION ${INSTALL_BIN_DIR})
## tests (prevent testing if current project is a subproject)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
## advanced version of enable_testing()
## adds "BUILD_TESTING" option to deactivate testing
include(CTest)
if(BUILD_TESTING)
set(BUILD_EXAMPLES TRUE) # examples needed for testing
set(include_tests TRUE)
endif()
endif()
## build examples
if(BUILD_EXAMPLES)
message(STATUS "Adding examples")
add_subdirectory(examples)
endif()
## build tests
if(include_tests)
message(STATUS "Adding tests")
add_subdirectory(t)
endif()
add_subdirectory(doc)
## Clang-tidy
if(RUN_CLANG_TIDY)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable" )
if(NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy not found, but requested. Please deactivate RUN_CLANG_TIDY" )
else()
set_target_properties(
HEJ
PROPERTIES CXX_CLANG_TIDY
"${CLANG_TIDY_EXE};-header-filter=${CMAKE_SOURCE_DIR}/include/HEJ;-fix;--fix-errors" )
endif()
endif()
diff --git a/current_generator/CMakeLists.txt b/current_generator/CMakeLists.txt
index 654b53e..ee03585 100644
--- a/current_generator/CMakeLists.txt
+++ b/current_generator/CMakeLists.txt
@@ -1,35 +1,34 @@
set(form_folder ${CMAKE_CURRENT_SOURCE_DIR}/form)
include(ExternalProject)
ExternalProject_Add(
FORM
- GIT_SUBMODULES ${form_folder}
SOURCE_DIR ${form_folder}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
CONFIGURE_COMMAND autoreconf -i ${form_folder}
COMMAND CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
${form_folder}/configure --without-gmp --disable-native
--without-zlib --disable-threaded --prefix=<INSTALL_DIR> -q
# we only run FORM once, don't spend time on optimising it
COMPILEFLAGS="-O0"
)
set(form_binary ${CMAKE_CURRENT_BINARY_DIR}/bin/form)
file(GLOB form_headers include/*.frm)
file(GLOB current_files *.frm)
foreach(current ${current_files})
get_filename_component(header_name ${current} NAME_WE)
set(header ${PROJECT_BINARY_DIR}/include/HEJ/currents/${header_name}.hh)
list(APPEND current_headers ${header})
add_custom_command(
OUTPUT ${header}
COMMAND ./gen_current.sh ${form_binary} ${current} ${header}
${CMAKE_CURRENT_BINARY_DIR}/${header_name}.log
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${current} ${form_headers} gen_current.sh FORM
)
endforeach()
add_custom_target(currents DEPENDS ${current_headers})
diff --git a/doc/sphinx/installation.rst b/doc/sphinx/installation.rst
index c225964..008bf02 100644
--- a/doc/sphinx/installation.rst
+++ b/doc/sphinx/installation.rst
@@ -1,103 +1,102 @@
.. _Installation:
Installation
============
Download
--------
A tar archive of the HEJ 2 source code can be downloaded and
decompressed with the command::
curl https://hej.web.cern.ch/HEJ/downloads/HEJ_2.0.tar.gz | tar -xz
To obtain the latest stable HEJ version, `HEJ_2.0.tar.gz` should be
replaced by `HEJ.tar.gz`.
Alternatively, the HEJ source code can be obtained by installing the
`git version control system <https://git-scm.com/>`_. and running:
.. code-block:: sh
git clone https://phab.hepforge.org/source/hej.git
- git submodule update --init # downloads FORM
We also provide a `Docker image <https://hub.docker.com/r/hejdock/hej>`_
containing a HEJ 2 installation. This image can be pulled with::
docker pull hejdock/hej
When using the Docker image the remaining installation steps can be
skipped.
Prerequisites
-------------
Before installing HEJ 2, you need the following programs and
libraries:
- `CMake <https://cmake.org/>`_ version 3.1
- A compiler supporting the C++14 standard, for example
`gcc <https://gcc.gnu.org/>`_ 5 or later
- `FastJet <http://fastjet.fr/>`_
- `CLHEP <https://gitlab.cern.ch/CLHEP/CLHEP>`_ version 2.3
- `LHAPDF <https://lhapdf.hepforge.org/>`_ version 6
- The `IOStreams` and `uBLAS` `boost <https://www.boost.org>`_ libraries
- `yaml-cpp <https://github.com/jbeder/yaml-cpp>`_
- `autoconf` and `automake` for `FORM <https://github.com/vermaseren/form>`_
In addition, some optional features have additional dependencies:
- `Version 2 of QCDLoop <https://github.com/scarrazza/qcdloop>`_ is
required to include finite top mass corrections in Higgs boson + jets
production.
- `HepMC versions 2 and 3 <https://hepmc.web.cern.ch/hepmc/>`_ enable
event output in the respective format.
- `Rivet <https://rivet.hepforge.org/>`_ together with HepMC 2 or 3 allow
using Rivet analyses.
- `HighFive <https://github.com/BlueBrain/HighFive>`_ has to be
installed in order to read and write event files in the
`HDF5 <https://www.hdfgroup.org/>`_-based format suggested in
`arXiv:1905.05120 <https://arxiv.org/abs/1905.05120>`_.
Compilation
-----------
To compile and install HEJ 2 run::
cmake source/directory -DCMAKE_INSTALL_PREFIX=target/directory
make install
:file:`source/directory` is the directory containing the file
:file:`CMakeLists.txt`. If you omit
:code:`-DCMAKE_INSTALL_PREFIX=target/directory` HEJ 2 will be
installed to some default location.
In case some of the aforementioned prerequisites are not found by
:code:`cmake` you can give a hint by adding an additional argument
:code:`-Dlibname_ROOT_DIR=/directory/with/library`, where
:code:`libname` should be replaced by the name of the library in
question. If :code:`cmake` fails to find (the correct) boost path,
try setting :code:`-DBOOST_ROOT=/path/to/boost`, this will force
:code:`cmake` to search for boost only in :code:`/path/to/boost`.
To not include specific packages one can add
:code:`-DEXCLUDE_packagename=TRUE` to :code:`cmake`, e.g. by
setting :code:`-DEXCLUDE_rivet=TRUE` HEJ 2 will not be interfaced
to Rivet even if it is available on the system.
Testing
-------
To test your installation, download the NNPDF 2.3 PDF set with::
lhapdf install NNPDF23_nlo_as_0119
and run::
make test
The test data of HEJ are stored in a
`Git Large File Storage <https://git-lfs.github.com/>`_ format.
:code:`git clone` therefore requires :code:`git-lfs` to download the data
correctly.
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Dec 21, 2:15 PM (12 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4015775
Default Alt Text
(15 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment