I am building a C++ project with the JUCE framework using CMake. I want to set up CMake to run clang-tidy on builds, and I have set up my CMakeLists.txt to look like this:
cmake_minimum_required(VERSION 3.15)
project(myProject VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(JUCE CONFIG REQUIRED)
juce_add_gui_app(myProject
VERSION 1.0.0
PRODUCT_NAME myProject)
file(GLOB_RECURSE SRC_FILES
"src/SourceFile1.cpp"
"src/SourceFile2.cpp"
"src/Header.h"
)
target_sources(myProject PRIVATE ${SRC_FILES})
set_target_properties(myProject PROPERTIES
CXX_CLANG_TIDY "clang-tidy;-header-filter=^(!?${CMAKE_SOURCE_DIR}\\Builds|${CMAKE_PREFIX_PATH})"
)
target_link_libraries(myProject
PRIVATE
juce::juce_audio_basics
juce::juce_audio_devices
juce::juce_audio_formats
juce::juce_audio_processors
juce::juce_audio_utils
juce::juce_core
juce::juce_data_structures
juce::juce_dsp
juce::juce_events
juce::juce_graphics
juce::juce_gui_basics
juce::juce_gui_extra
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
)
juce_generate_juce_header(myProject)
I also have a .clang-tidy file:
---
Checks: >
-*
# All my checks here...
WarningsAsErrors: '*'
CheckOptions:
# Options here...
When running CMake I set the CMAKE_PREFIX_PATH to the path of my JUCE modules. The problem is that these files in CMAKE_PREFIX_PATH are always included in the clang-tidy check and triggers a huge amount of warnings and errors. As you can see I've tried filtering them out using the --header-filter but to no effect. I think one problem might be that the JUCE modules are not built library files that is linked, but rather source files that's pulled in on build. How do I go about solving this?