From ffff6576b4754fec467e01039df6eb8149e11bed Mon Sep 17 00:00:00 2001 From: Martin Duffy Date: Tue, 3 Feb 2026 09:15:49 -0500 Subject: [PATCH] instrumentation: Add project field to cmake content files --- Help/manual/cmake-instrumentation.7.rst | 3 +++ Source/cmInstrumentation.cxx | 3 +++ Tests/RunCMake/Instrumentation/check-custom-content.cmake | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Help/manual/cmake-instrumentation.7.rst b/Help/manual/cmake-instrumentation.7.rst index 9523e45902..d69d7b7c4d 100644 --- a/Help/manual/cmake-instrumentation.7.rst +++ b/Help/manual/cmake-instrumentation.7.rst @@ -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 diff --git a/Source/cmInstrumentation.cxx b/Source/cmInstrumentation.cxx index d19dae0bf9..e9b398739f 100644 --- a/Source/cmInstrumentation.cxx +++ b/Source/cmInstrumentation.cxx @@ -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")); diff --git a/Tests/RunCMake/Instrumentation/check-custom-content.cmake b/Tests/RunCMake/Instrumentation/check-custom-content.cmake index 3912445ca1..d527b2223f 100644 --- a/Tests/RunCMake/Instrumentation/check-custom-content.cmake +++ b/Tests/RunCMake/Instrumentation/check-custom-content.cmake @@ -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")