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.
This commit is contained in:
Chris Thrasher 2022-08-11 10:40:47 -06:00
parent fc61f2469d
commit 3d02d490bd

View File

@ -2,12 +2,16 @@ include(FetchContent)
set(DOCTEST_NO_INSTALL ON) set(DOCTEST_NO_INSTALL ON)
FetchContent_Declare(doctest FetchContent_Declare(doctest
GIT_REPOSITORY "https://github.com/doctest/doctest.git" GIT_REPOSITORY https://github.com/doctest/doctest.git
GIT_TAG v2.4.9 GIT_TAG v2.4.9
) )
FetchContent_MakeAvailable(doctest) FetchContent_MakeAvailable(doctest)
list(APPEND CMAKE_MODULE_PATH ${doctest_SOURCE_DIR}/scripts/cmake) include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
include(doctest)
# 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) add_subdirectory(install)