summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-16 20:35:36 (GMT)
committerBrad King <brad.king@kitware.com>2015-01-20 14:31:11 (GMT)
commit0238d0c397e52a82f20a0b7bf5aad9a07f36133c (patch)
tree1e63a6ae56817eb5808dfdd501d2fef67db9db63 /Source/cmGlobalGenerator.cxx
parentbda4f0b661018b32aefdb14887d8137e7a4fd118 (diff)
downloadCMake-0238d0c397e52a82f20a0b7bf5aad9a07f36133c.zip
CMake-0238d0c397e52a82f20a0b7bf5aad9a07f36133c.tar.gz
CMake-0238d0c397e52a82f20a0b7bf5aad9a07f36133c.tar.bz2
cmake: Generate an internal 'Labels.json' file next to 'Labels.txt'
In each internal target directory we generate a "Labels.txt" file containing labels for that target and its sources, but it uses an internal format. In order to make the list of labels easier to publish, use a json format and call it "Labels.json". Since we now use jsoncpp headers, link CMakeLib to the jsoncpp library.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx26
1 files changed, 25 insertions, 1 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 1745d9a..dd3b1ec 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -38,6 +38,8 @@
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include <cmsys/MD5.h>
+# include "cm_jsoncpp_value.h"
+# include "cm_jsoncpp_writer.h"
#endif
#include <stdlib.h> // required for atof
@@ -2911,10 +2913,21 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
std::string dir = target->GetSupportDirectory();
std::string file = dir;
file += "/Labels.txt";
+ std::string json_file = dir + "/Labels.json";
+#ifdef CMAKE_BUILD_WITH_CMAKE
// Check whether labels are enabled for this target.
if(const char* value = target->GetProperty("LABELS"))
{
+ Json::Value lj_root(Json::objectValue);
+ Json::Value& lj_target =
+ lj_root["target"] = Json::objectValue;
+ lj_target["name"] = target->GetName();
+ Json::Value& lj_target_labels =
+ lj_target["labels"] = Json::arrayValue;
+ Json::Value& lj_sources =
+ lj_root["sources"] = Json::arrayValue;
+
cmSystemTools::MakeDirectory(dir.c_str());
cmGeneratedFileStream fout(file.c_str());
@@ -2929,6 +2942,7 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
li != labels.end(); ++li)
{
fout << " " << *li << "\n";
+ lj_target_labels.append(*li);
}
}
@@ -2954,23 +2968,33 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
{
continue;
}
+ Json::Value& lj_source = lj_sources.append(Json::objectValue);
cmSourceFile* sf = *si;
- fout << sf->GetFullPath() << "\n";
+ std::string const& sfp = sf->GetFullPath();
+ fout << sfp << "\n";
+ lj_source["file"] = sfp;
if(const char* svalue = sf->GetProperty("LABELS"))
{
labels.clear();
+ Json::Value& lj_source_labels =
+ lj_source["labels"] = Json::arrayValue;
cmSystemTools::ExpandListArgument(svalue, labels);
for(std::vector<std::string>::const_iterator li = labels.begin();
li != labels.end(); ++li)
{
fout << " " << *li << "\n";
+ lj_source_labels.append(*li);
}
}
}
+ cmGeneratedFileStream json_fout(json_file.c_str());
+ json_fout << lj_root;
}
else
+#endif
{
cmSystemTools::RemoveFile(file);
+ cmSystemTools::RemoveFile(json_file);
}
}