Page MenuHomeHEPForge

No OneTemporary

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e99c8b4..4796bfd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,206 +1,200 @@
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)
CMAKE_DEPENDENT_OPTION(EXCLUDE_rivet "Do not include rivet" FALSE
"NOT EXCLUDE_HepMC" TRUE)
option(TEST_ALL "Run additional (longer) tests" FALSE)
option(TEST_COVERAGE "Generate test coverage with \"gcovr\"" 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")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
## 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
)
## 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)
## Template files
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in
${PROJECT_BINARY_DIR}/include/HEJ/Version.hh @ONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/HEJ-config.cc.in
${PROJECT_BINARY_DIR}/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})
## find dependencies
find_package(fastjet REQUIRED)
find_package(CLHEP 2.3 REQUIRED)
find_package(LHAPDF 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
-# target yaml-cpp might miss include directory, fixed in (release of 0.6.3)
-# https://github.com/jbeder/yaml-cpp/commit/ab5f9259a4e67d3fe0e4832bd407a9e596e2d884
-if(NOT $<TARGET_PROPERTY:yaml-cpp,INTERFACE_INCLUDE_DIRECTORIES>
- AND EXISTS ${YAML_CPP_INCLUDE_DIR} )
- # if folder doesn't exist it has to be in some standard location
- target_include_directories(yaml-cpp INTERFACE ${YAML_CPP_INCLUDE_DIR})
-endif()
if(${EXCLUDE_HepMC})
message(STATUS "Skipping HepMC")
else()
find_package(HepMC 2 EXACT)
endif()
if(${HepMC_FOUND})
if(${EXCLUDE_rivet})
message(STATUS "Skipping rivet")
else()
find_package(rivet)
endif()
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_QCDloop})
message(STATUS "Skipping QCDloop")
else()
find_package(QCDloop 2)
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
## 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/*")
SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML(
NAME ctest_coverage # New target name
EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
)
endif()
## 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)
add_subdirectory(t)
endif()
endif()
diff --git a/FixedOrderGen/CMakeLists.txt b/FixedOrderGen/CMakeLists.txt
index b0d4389..826b1dd 100644
--- a/FixedOrderGen/CMakeLists.txt
+++ b/FixedOrderGen/CMakeLists.txt
@@ -1,108 +1,102 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project("HEJ Fixed Order Generation" VERSION 2.0.6 LANGUAGES C CXX)
# 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")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
## 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
)
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in
${PROJECT_BINARY_DIR}/include/Version.hh @ONLY )
## Use cmake modules from HEJ src
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake/Modules/")
-## Find HEJ (only dependencies)
+## Find HEJ (only dependency)
## HEJ includes all sub dependencies (fastjet, lhapdf, ...)
find_package(HEJ 2 REQUIRED)
-# target yaml-cpp might miss include directory, fixed in (release of 0.6.3)
-# https://github.com/jbeder/yaml-cpp/commit/ab5f9259a4e67d3fe0e4832bd407a9e596e2d884
-if(NOT $<TARGET_PROPERTY:yaml-cpp,INTERFACE_INCLUDE_DIRECTORIES>
- AND EXISTS ${YAML_CPP_INCLUDE_DIR} )
- # if folder doesn't exist it has to be in some standard location
- target_include_directories(yaml-cpp INTERFACE ${YAML_CPP_INCLUDE_DIR})
-endif()
+include(RepairTargets) # more reliable cmake targets
## define executable
file(GLOB HEJFOG_source ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)
list(REMOVE_ITEM HEJFOG_source ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc)
add_library(hejfog_lib STATIC ${HEJFOG_source})
target_include_directories(hejfog_lib
PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include
)
add_executable(HEJFOG ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc)
## link libraries
set(libraries ${CMAKE_DL_LIBS})
target_link_libraries(hejfog_lib ${libraries} HEJ::HEJ)
target_link_libraries(HEJFOG hejfog_lib)
install(TARGETS HEJFOG DESTINATION bin)
## tests
enable_testing()
set(tst_dir "${CMAKE_CURRENT_SOURCE_DIR}/t")
foreach(tst h_2j h_3j h_5j h_3j_uno1 h_3j_uno2 h_2j_decay 2j 4j W_reconstruct_enu
W_2j_classify W_nj_classify)
add_executable(test_${tst} ${tst_dir}/${tst}.cc)
target_link_libraries(test_${tst} hejfog_lib)
add_test(NAME t_${tst} COMMAND test_${tst} WORKING_DIRECTORY ${tst_dir})
endforeach()
# this only tests if the runcard actually works, not if the result is correct
add_test(
NAME t_main_2j
COMMAND HEJFOG ${tst_dir}/config_2j.yml
)
add_test(
NAME t_main_h2j
COMMAND HEJFOG ${tst_dir}/config_h_2j.yml
)
add_test(
NAME t_main_h2j_decay
COMMAND HEJFOG ${tst_dir}/config_h_2j_decay.yml
)
add_test(
NAME t_peakpt
COMMAND HEJFOG ${tst_dir}/config_2j_peak.yml
)
diff --git a/cmake/Modules/RepairTargets.cmake b/cmake/Modules/RepairTargets.cmake
new file mode 100644
index 0000000..bc150b2
--- /dev/null
+++ b/cmake/Modules/RepairTargets.cmake
@@ -0,0 +1,36 @@
+## Various small fixes to repair broken/unreliable cmake targets
+
+## Boost target seems to be unreliable and might requires specific versions of
+## cmake to work see e.g. https://stackoverflow.com/a/42124857
+## Workaround from:
+## https://cliutils.gitlab.io/modern-cmake/chapters/packages/Boost.html
+if(NOT TARGET Boost::boost)
+ message("Setting up boost target \"Boost::boost\"")
+ add_library(Boost::boost IMPORTED INTERFACE)
+ set_property(TARGET Boost::boost PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR})
+endif()
+if(NOT TARGET Boost::iostreams)
+ message("Setting up boost target \"Boost::iostreams\"")
+ add_library(Boost::iostreams IMPORTED INTERFACE)
+ set_property(TARGET Boost::iostreams PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR})
+ set_property(TARGET Boost::iostreams PROPERTY
+ INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES})
+endif()
+## Boost is stupid: regex is implicitly required for some iostreams headers,
+## but CMake can not know which one see https://gitlab.kitware.com/cmake/cmake/issues/18763
+## => Create a dummy target to make everyone happy
+get_target_property(iostreams_links Boost::iostreams INTERFACE_LINK_LIBRARIES)
+if( (NOT TARGET Boost::regex)
+ AND (${iostreams_links} MATCHES ".*Boost::regex.*" ))
+ add_library(Boost::regex IMPORTED INTERFACE)
+endif()
+
+# target yaml-cpp might miss include directory, fixed in (release of 0.6.3)
+# https://github.com/jbeder/yaml-cpp/commit/ab5f9259a4e67d3fe0e4832bd407a9e596e2d884
+if(NOT $<TARGET_PROPERTY:yaml-cpp,INTERFACE_INCLUDE_DIRECTORIES>
+ AND EXISTS ${YAML_CPP_INCLUDE_DIR} )
+ # if folder doesn't exist it has to be in some standard location
+ target_include_directories(yaml-cpp INTERFACE ${YAML_CPP_INCLUDE_DIR})
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d515c79..9222044 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,65 +1,56 @@
file(GLOB src_files *.cc)
## hej source
add_library(HEJ SHARED ${src_files})
set_target_properties(HEJ PROPERTIES OUTPUT_NAME "HEJ")
target_include_directories(HEJ PUBLIC ${HEJ_INCLUDE_DIR})
set(libraries ${CMAKE_DL_LIBS})
target_link_libraries(HEJ PRIVATE ${libraries})
## Dependencies
target_link_libraries(HEJ
PUBLIC
fastjet::fastjet
LHAPDF::LHAPDF
CLHEP::CLHEP
yaml-cpp
+ Boost::boost
+ Boost::iostreams
)
-# Boost target seems to be unreliable and might requires specific versions of
-# cmake to work see e.g. https://stackoverflow.com/a/42124857
-# target_link_libraries(HEJ
-# PUBLIC
-# Boost::boost
-# Boost::iostreams
-# )
-# link explicitly instead
-target_include_directories(HEJ PUBLIC ${Boost_INCLUDE_DIRS})
-target_link_libraries(HEJ PUBLIC ${Boost_LIBRARIES})
-
if(${QCDloop_FOUND})
target_link_libraries(HEJ PRIVATE QCDloop::qcdloop quadmath)
- target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_QCDLOOP" )
+ target_compile_options(HEJ PUBLIC "-DHEJ_BUILD_WITH_QCDLOOP" )
endif()
if(${HepMC_FOUND})
target_link_libraries(HEJ PRIVATE HepMC::HepMC)
- target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_HepMC2" )
+ target_compile_options(HEJ PUBLIC "-DHEJ_BUILD_WITH_HepMC2" )
if(${rivet_FOUND})
target_link_libraries(HEJ PRIVATE rivet::rivet)
- target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_RIVET" )
+ target_compile_options(HEJ PUBLIC "-DHEJ_BUILD_WITH_RIVET" )
endif()
endif()
if(${HepMC3_FOUND})
# HepMC 3 doesn't export a target
target_link_libraries(HEJ PRIVATE ${HEPMC3_LIBRARIES})
target_include_directories(HEJ PRIVATE ${HEPMC3_INCLUDE_DIR})
- target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_HepMC3" )
+ target_compile_options(HEJ PUBLIC "-DHEJ_BUILD_WITH_HepMC3" )
endif()
if(${HighFive_FOUND})
target_link_libraries(HEJ PRIVATE HighFive)
- target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_HDF5" )
+ target_compile_options(HEJ PUBLIC "-DHEJ_BUILD_WITH_HDF5" )
endif()
## install & export target
install(TARGETS HEJ
EXPORT HEJ-export
DESTINATION ${INSTALL_LIB_DIR}
)
install(EXPORT HEJ-export
FILE
hejTargets.cmake
NAMESPACE
HEJ::
DESTINATION
${INSTALL_CONFIG_DIR}
)

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 3:49 PM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3791817
Default Alt Text
(15 KB)

Event Timeline