From afbb84b2c8d698d825ef00630520d351ea08427c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lemieux Date: Wed, 5 May 2021 16:19:24 -0400 Subject: [PATCH] Add a cmake option to use SYSTEM in target_include_directories Without SYSTEM static analysis like clang-tidy raise warnings on json.hpp. This is not desirable for projects embedding nlohmann_json Tests: - Validated that without the option OFF the warnings are raised as before - Validated that with the option ON the warnings are silenced --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1636575594..d8612029d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF) option(JSON_ImplicitConversions "Enable implicit conversions." ON) option(JSON_Diagnostics "Enable better diagnostic messages." OFF) option(JSON_CI "Enable CI build targets." OFF) +option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)" OFF) if (JSON_CI) include(cmake/ci.cmake) @@ -73,6 +74,10 @@ if (JSON_Diagnostics) message(STATUS "Diagnostics enabled") endif() +if (JSON_SystemInclude) + set(NLOHMANN_JSON_SYSTEM_INCLUDE "SYSTEM") +endif() + ## ## TARGET ## create target and add include path @@ -94,7 +99,7 @@ target_compile_definitions( target_include_directories( ${NLOHMANN_JSON_TARGET_NAME} - INTERFACE + ${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE $ $ )