diff --git a/CMakeLists.txt b/CMakeLists.txt index ba1ed98646d3c9c7fe52115ced1c018d5cdbc716..72410085a9ee8570c387cadeb48c4dd07a9af15c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,7 @@ If(BUILD_UNITTESTS) Include(external/InstallGtest.cmake) endif() + ### Subdirectories to be compiled ##### ### Externals included and build from several sources @@ -238,6 +239,21 @@ endif() # following targets add_subdirectory (external) +option(BUILD_FOR_TIDY "Create compile commands database needed by clang-tidy" OFF) +# Add the default compiler include paths needed for our static standalone clang-tidy +# binary. The paths are only added to the compilation units in the generated file +# compile_commands.json which is used as input for clang-tidy. Without the +# paths clang-tidy can't find the standard C and C++ header files. +# Also add special compile options to use the scalar version of VC. +# Otherwise hardware and compiler dependent header files may not be found. +# Since we want to check our code and not some system headers this is +# acceptable. +if(BUILD_FOR_TIDY) + ADD_DEFINITIONS(-DVc_IMPL=Scalar) + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES + ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} + ) +endif() ### Base directories add_subdirectory (core) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index e6743c009e8bb769ebe50a749803518fc9a5a9ee..5935eef5c8e9c98fd1ebbcb9bc733256f50399fc 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -72,14 +72,17 @@ if(DOWNLOAD_EXTERNALS) Include(InstallAnalysisTree.cmake) Include(InstallAnalysisTreeQA.cmake) - Include(InstallParameter.cmake) - Include(InstallInput.cmake) - Include(InstallGeometry.cmake) Include(InstallYamlCpp.cmake) Include(InstallBBA.cmake) + if(NOT BUILD_FOR_TIDY) + Include(InstallParameter.cmake) + Include(InstallInput.cmake) + Include(InstallGeometry.cmake) + endif() + else() # Define targets which are needed by CbmRoot but are not available # whithout the external packages diff --git a/external/InstallKFParticle.cmake b/external/InstallKFParticle.cmake index d95717419bcd33b48de86f427f872dcc2e53effb..df7073ed309cb5dcbf385c353fdff73643281d80 100644 --- a/external/InstallKFParticle.cmake +++ b/external/InstallKFParticle.cmake @@ -14,12 +14,22 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES arm64 PATCH_COMMAND "patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/KFParticle_applem1.patch" ) else() - download_project_if_needed(PROJECT kfparticle_source - GIT_REPOSITORY ${KFPARTICLE_SRC_URL} - GIT_TAG ${KFPARTICLE_TAG} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/KFParticle - TEST_FILE CMakeLists.txt - ) + if(BUILD_FOR_TIDY) + download_project_if_needed(PROJECT kfparticle_source + GIT_REPOSITORY ${KFPARTICLE_SRC_URL} + GIT_TAG ${KFPARTICLE_TAG} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/KFParticle + TEST_FILE CMakeLists.txt + PATCH_COMMAND "patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/KFParticle_clang_tidy.patch" + ) + else() + download_project_if_needed(PROJECT kfparticle_source + GIT_REPOSITORY ${KFPARTICLE_SRC_URL} + GIT_TAG ${KFPARTICLE_TAG} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/KFParticle + TEST_FILE CMakeLists.txt + ) + endif() endif() If(ProjectUpdated) diff --git a/external/KFParticle_clang_tidy.patch b/external/KFParticle_clang_tidy.patch new file mode 100644 index 0000000000000000000000000000000000000000..86300f0cdbdadd645b69d55ee8efc53851b0c65e --- /dev/null +++ b/external/KFParticle_clang_tidy.patch @@ -0,0 +1,13 @@ +diff --git a/KFParticle/KFPSimdAllocator.h b/KFParticle/KFPSimdAllocator.h +index 20a13c4..704423f 100644 +--- a/KFParticle/KFPSimdAllocator.h ++++ b/KFParticle/KFPSimdAllocator.h +@@ -24,6 +24,8 @@ + + #include <Vc/Vc> + ++#include <mm_malloc.h> ++ + /** @class KFPSimdAllocator + ** @brief Allocator which is needed to allocate memory in std::vector aligned by the size of SIMD vectors. + ** @author M.Zyzak, I.Kisel