From 3d02d490bd091003d137d89d06e8c40dd2970406 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Thu, 11 Aug 2022 10:40:47 -0600 Subject: [PATCH] Hide doctest sources from compile commands database This ensure that tools like run-clang-tidy don't try to analyze them and better mimmicks how Doctest would behave if we were depending on Doctest via find_package instead. --- test/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bd0a42c1c..4f53a8e42 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,12 +2,16 @@ include(FetchContent) set(DOCTEST_NO_INSTALL ON) FetchContent_Declare(doctest - GIT_REPOSITORY "https://github.com/doctest/doctest.git" + GIT_REPOSITORY https://github.com/doctest/doctest.git GIT_TAG v2.4.9 ) FetchContent_MakeAvailable(doctest) -list(APPEND CMAKE_MODULE_PATH ${doctest_SOURCE_DIR}/scripts/cmake) -include(doctest) +include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) + +# Ensure that doctest sources and headers are not analyzed by any tools +set_target_properties(doctest_with_main PROPERTIES COMPILE_OPTIONS "" EXPORT_COMPILE_COMMANDS OFF) +get_target_property(DOCTEST_INCLUDE_DIRS doctest INTERFACE_INCLUDE_DIRECTORIES) +target_include_directories(doctest SYSTEM INTERFACE ${DOCTEST_INCLUDE_DIRS}) add_subdirectory(install)