From e42cde3405cbef54702668de42e0814a62f70fe2 Mon Sep 17 00:00:00 2001 From: Tyler Yankee Date: Wed, 12 Aug 2026 17:16:27 -0400 Subject: [PATCH] cmBuildDatabase: Use cmJSONState to read mcdb's This approach will be more portable. --- Source/cmBuildDatabase.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/cmBuildDatabase.cxx b/Source/cmBuildDatabase.cxx index f5ddafaf80..576fb72833 100644 --- a/Source/cmBuildDatabase.cxx +++ b/Source/cmBuildDatabase.cxx @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -22,6 +21,7 @@ #include "cmGeneratorFileSet.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmJSONState.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmSourceFile.h" @@ -179,12 +179,11 @@ std::unique_ptr cmBuildDatabase::Load(std::string const& path) { Json::Value mcdb; { - cmsys::ifstream mcdbf(path.c_str(), std::ios::in | std::ios::binary); - Json::Reader reader; - if (!reader.parse(mcdbf, mcdb, false)) { + cmJSONState parseState(path, &mcdb); + if (!parseState.errors.empty()) { cmSystemTools::Error( cmStrCat("-E cmake_module_compile_db failed to parse ", path, - reader.getFormattedErrorMessages())); + parseState.GetErrorMessage())); return {}; } }