From 8d05fc44fb92f7095f77aa9977106aef8903ccec Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Tue, 23 Apr 2024 14:27:09 -0400 Subject: [PATCH] Support using the system rapidjson to build We have a bundled copy of rapidjson in runtime, but some Linux distributions also ship with another version of that library. Support using that too, optionally. This does not change the default behaviour - the bundled copy of rapidjson is used. A cmake argument of CLR_CMAKE_USE_SYSTEM_RAPIDJSON=true needs to be set to use the system version of rapidjson. --- src/native/corehost/CMakeLists.txt | 4 ++++ src/native/corehost/apphost/static/CMakeLists.txt | 4 ++++ src/native/corehost/json_parser.cpp | 2 +- src/native/corehost/json_parser.h | 4 ++-- src/native/corehost/runtime_config.cpp | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index a7b2c82de668d..c03885d5b349e 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -83,6 +83,10 @@ add_library(fxr_resolver INTERFACE) target_sources(fxr_resolver INTERFACE fxr_resolver.cpp) target_include_directories(fxr_resolver INTERFACE fxr) +if ((NOT DEFINED CLR_CMAKE_USE_SYSTEM_RAPIDJSON) OR (NOT CLR_CMAKE_USE_SYSTEM_RAPIDJSON)) + include_directories(${CLR_SRC_NATIVE_DIR}/external/) +endif() + add_subdirectory(hostcommon) add_subdirectory(hostmisc) add_subdirectory(fxr) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index b3d6766c03dca..3ea4d5d043ca3 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -27,6 +27,10 @@ add_subdirectory(../../hostmisc hostmisc) configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) target_include_directories(hostmisc PUBLIC ${GENERATED_INCLUDE_DIR}/corehost) +if ((NOT DEFINED CLR_CMAKE_USE_SYSTEM_RAPIDJSON) OR (NOT CLR_CMAKE_USE_SYSTEM_RAPIDJSON)) + include_directories(${CLR_SRC_NATIVE_DIR}/external/) +endif() + set(SOURCES ../bundle_marker.cpp ./hostfxr_resolver.cpp diff --git a/src/native/corehost/json_parser.cpp b/src/native/corehost/json_parser.cpp index ca4968786eb60..6ea3cdc24f548 100644 --- a/src/native/corehost/json_parser.cpp +++ b/src/native/corehost/json_parser.cpp @@ -10,7 +10,7 @@ #define RAPIDJSON_ERROR_STRING(x) _X(x) #include -#include +#include #include "utils.h" #include #include diff --git a/src/native/corehost/json_parser.h b/src/native/corehost/json_parser.h index d7393b0ae678d..e57bfa9e2fd7f 100644 --- a/src/native/corehost/json_parser.h +++ b/src/native/corehost/json_parser.h @@ -17,8 +17,8 @@ #endif #include "pal.h" -#include -#include +#include +#include #include #include "bundle/info.h" diff --git a/src/native/corehost/runtime_config.cpp b/src/native/corehost/runtime_config.cpp index 08e75fd61e016..d79a610f588b0 100644 --- a/src/native/corehost/runtime_config.cpp +++ b/src/native/corehost/runtime_config.cpp @@ -3,7 +3,7 @@ #include "json_parser.h" #include "pal.h" -#include +#include #include "roll_fwd_on_no_candidate_fx_option.h" #include "runtime_config.h" #include "trace.h"