instrumentation: Add project field to cmake content files

This commit is contained in:
Martin Duffy
2026-02-03 09:15:49 -05:00
parent ddc80953dd
commit ffff6576b4
3 changed files with 9 additions and 0 deletions
+3
View File
@@ -563,6 +563,9 @@ corresponding to the CMake invocation responsible for generating its command.
Each CMake content file contains the following:
``project``
The value of :variable:`CMAKE_PROJECT_NAME`.
``custom``
An object containing arbitrary JSON data specified by the user with the
:ref:`cmake_instrumentation CUSTOM_CONTENT` functionality of the
+3
View File
@@ -40,6 +40,7 @@
#include "cmTimestamp.h"
#include "cmUVProcessChain.h"
#include "cmValue.h"
#include "cmake.h"
using LoadQueriesAfter = cmInstrumentation::LoadQueriesAfter;
@@ -234,6 +235,8 @@ void cmInstrumentation::WriteCMakeContent(
Json::Value root;
root["targets"] = this->DumpTargets(gg);
root["custom"] = this->customContent;
root["project"] =
gg->GetCMakeInstance()->GetCacheDefinition("CMAKE_PROJECT_NAME").GetCStr();
this->WriteInstrumentationJson(
root, "data/content",
cmStrCat("cmake-", this->ComputeSuffixTime(), ".json"));
@@ -15,6 +15,9 @@ set(firstFile "")
foreach(content_file IN LISTS content_files)
read_json("${content_file}" contents)
# Check project name
json_assert_key("${content_file}" "${contents}" project "instrumentation")
# Check custom content
string(JSON custom GET "${contents}" custom)
json_assert_key("${content_file}" "${custom}" myString "string")