Page MenuHomeHEPForge

No OneTemporary

diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..128117f
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,32 @@
+Checks: '
+ -clang-analyzer-optin.cplusplus.VirtualCall,
+ -cppcoreguidelines-avoid-magic-numbers,
+ -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+ -cppcoreguidelines-pro-bounds-constant-array-index,
+ -fuchsia*,
+ -google-build-using-namespace,
+ -google-readability*,
+ -google-runtime-int,
+ -google-runtime-references,
+ -hicpp*,
+ -llvm-header-guard,
+ -modernize-use-trailing-return-type,
+ -readability-braces-around-statements,
+ '
+CheckOptions:
+ - key: readability-identifier-naming.PrivateMemberSuffix
+ value: '_'
+ - key: readability-identifier-naming.GlobalConstantCase
+ value: UPPER_CASE
+ - key: readability-identifier-naming.GlobalVariableCase
+ value: UPPER_CASE
+ - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
+ value: '1'
+ - key: llvm-namespace-comment.ShortNamespaceLines
+ value: '10'
+ - key: readability-magic-numbers.IgnoreAllFloatingPointValues
+ value: '1'
+ - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+ value: '1'
+ - key: performance-move-const-arg.CheckTriviallyCopyableMove
+ value: '0'
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3489c9d..d7e4a23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,257 +1,274 @@
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)
## 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)
## find dependencies
find_package(fastjet REQUIRED)
find_package(CLHEP 2.3 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()

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 4:52 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3805254
Default Alt Text
(10 KB)

Event Timeline