From 483e8770013b78cd0a5b76b709d5a1495f2437a6 Mon Sep 17 00:00:00 2001 From: Castor215 <132155746+Castor215@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:32:43 +0100 Subject: [PATCH] externals: allow users to use system JSON headers (nlohmann-json3) (#7042) --- CMakeLists.txt | 1 + externals/CMakeLists.txt | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e27b1caf..67f380bc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ option(USE_SYSTEM_LIBUSB "Use the system libusb (instead of the bundled libusb)" option(USE_SYSTEM_CPP_JWT "Use the system cpp-jwt (instead of the bundled one)" OFF) option(USE_SYSTEM_SOUNDTOUCH "Use the system SoundTouch (instead of the bundled one)" OFF) option(USE_SYSTEM_CPP_HTTPLIB "Use the system cpp-httplib (instead of the bundled one)" OFF) +option(USE_SYSTEM_JSON "Use the system JSON (nlohmann-json3) package (instead of the bundled one)" OFF) if (CITRA_USE_PRECOMPILED_HEADERS) message(STATUS "Using Precompiled Headers.") diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 7e3a0e7d7..5a2548bca 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -175,7 +175,16 @@ endif() # JSON add_library(json-headers INTERFACE) -target_include_directories(json-headers INTERFACE ./json) +if (USE_SYSTEM_JSON) + find_package(nlohmann_json REQUIRED) + target_link_libraries(json-headers INTERFACE nlohmann_json::nlohmann_json) + get_target_property(NLOHMANN_PREFIX nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES) + # The nlohmann-json3 package expects "#include " + # Citra uses "#include " so we have to add this manually + target_include_directories(json-headers SYSTEM INTERFACE "${NLOHMANN_PREFIX}/nlohmann") +else() + target_include_directories(json-headers SYSTEM INTERFACE ./json) +endif() # OpenSSL if (USE_SYSTEM_OPENSSL)