Merge topic 'cmake-labels-json'

0238d0c3 cmake: Generate an internal 'Labels.json' file next to 'Labels.txt'
bda4f0b6 jsoncpp: Add headers to help CMake include in-source jsoncpp headers
a02fbec5 jsoncpp: Drop doxygen comments that cause Clang warnings
This commit is contained in:
Brad King 2015-01-20 09:31:59 -05:00 committed by CMake Topic Stage
commit 17cfa09eb2
6 changed files with 64 additions and 5 deletions

View File

@ -502,7 +502,9 @@ add_library(CMakeLib ${SRCS})
target_link_libraries(CMakeLib cmsys
${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
${CMAKE_CURL_LIBRARIES} )
${CMAKE_CURL_LIBRARIES}
cmjsoncpp
)
# On Apple we need CoreFoundation
if(APPLE)

View File

@ -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);
}
}

View File

@ -0,0 +1,18 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cm_jsoncpp_value_h
#define cm_jsoncpp_value_h
/* Use the jsoncpp library configured for CMake. */
#include <cmjsoncpp/include/json/value.h>
#endif

View File

@ -0,0 +1,18 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cm_jsoncpp_writer_h
#define cm_jsoncpp_writer_h
/* Use the jsoncpp library configured for CMake. */
#include <cmjsoncpp/include/json/writer.h>
#endif

View File

@ -106,9 +106,7 @@ public:
* the parsed document. An empty string is returned if no error
* occurred
* during parsing.
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
*/
JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead")
std::string getFormatedErrorMessages() const;
/** \brief Returns a user friendly string that list errors in the parsed

View File

@ -150,7 +150,6 @@ private:
* If the Value have comments then they are outputed according to their
#CommentPlacement.
*
* \param indentation Each level will be indented by this amount extra.
* \sa Reader, Value, Value::setComment()
*/
class JSON_API StyledStreamWriter {