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 {}; } }