From 654796ec0cce476f0a1bf18a51b4113a154c8cbd Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Mon, 9 Mar 2026 08:53:41 -0500 Subject: [PATCH] feat: permit use of system rapidyaml Signed-off-by: Pat Riehecky --- CMakeLists.txt | 22 +++++++++++++++++----- core/vm.cpp | 4 ++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a508d0d4..b2efedf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ option(BUILD_SHARED_BINARIES "Link binaries to the shared libjsonnet instead of option(BUILD_MAN_PAGES "Build manpages." ON) option(USE_SYSTEM_GTEST "Use system-provided gtest library" OFF) option(USE_SYSTEM_JSON "Use the system-provided json library" OFF) -# TODO: Support using a system Rapid YAML install. +option(USE_SYSTEM_RAPIDYAML "Use the system-provided rapidyaml library" OFF) #### Compute derived values from user-configurable state. # @@ -69,6 +69,10 @@ if(USE_SYSTEM_JSON) find_package(nlohmann_json 3.6.1 REQUIRED) endif() +if(USE_SYSTEM_RAPIDYAML) + find_package(ryml REQUIRED VERSION 0.10.0) +endif() + #### Utility function to configure a target with our preferred C and C++ compilation flags. # @@ -108,9 +112,6 @@ function(configure_jsonnet_obj_target LIB_TARGET_NAME) third_party/md5/md5.h third_party/md5/md5.cpp - third_party/rapidyaml/rapidyaml-0.10.0.hpp - third_party/rapidyaml/rapidyaml.cpp - core/static_error.h core/desugarer.h core/unicode.h @@ -155,13 +156,24 @@ function(configure_jsonnet_obj_target LIB_TARGET_NAME) SYSTEM PRIVATE third_party/json) endif() + if(USE_SYSTEM_RAPIDYAML) + target_link_libraries(${LIB_TARGET_NAME} PRIVATE ryml::ryml) + target_compile_definitions(${LIB_TARGET_NAME} PRIVATE USE_SYSTEM_RAPIDYAML) + else() + target_sources(${LIB_TARGET_NAME} + PRIVATE + third_party/rapidyaml/rapidyaml-0.10.0.hpp + third_party/rapidyaml/rapidyaml.cpp + ) + endif() + target_include_directories(${LIB_TARGET_NAME} PUBLIC $ $ PRIVATE third_party/md5 - third_party/rapidyaml + $<$>:${CMAKE_CURRENT_SOURCE_DIR}/third_party/rapidyaml> ) endfunction() diff --git a/core/vm.cpp b/core/vm.cpp index ce6fa941..18788a05 100644 --- a/core/vm.cpp +++ b/core/vm.cpp @@ -29,7 +29,11 @@ limitations under the License. #include #include "md5.h" #include "parser.h" +#ifdef USE_SYSTEM_RAPIDYAML +#include +#else #include "rapidyaml-0.10.0.hpp" +#endif #include "state.h" #include "static_analysis.h" #include "static_error.h"