summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-11-01 14:37:53 (GMT)
committerBrad King <brad.king@kitware.com>2018-12-12 11:40:10 (GMT)
commitb83fe27d8d3f25ed6e229270966b8323f5fc3ae5 (patch)
treeec345eec5c2d84087dabff361888d463d7ce41d0
parent7ee0abbde1656b07eb28ddacca3d22bb7aafdbd8 (diff)
downloadCMake-b83fe27d8d3f25ed6e229270966b8323f5fc3ae5.zip
CMake-b83fe27d8d3f25ed6e229270966b8323f5fc3ae5.tar.gz
CMake-b83fe27d8d3f25ed6e229270966b8323f5fc3ae5.tar.bz2
fileapi: Report cmake generator in reply index file
-rw-r--r--Help/manual/cmake-file-api.7.rst13
-rw-r--r--Source/cmFileAPI.cxx2
-rw-r--r--Source/cmGlobalGenerator.cxx9
-rw-r--r--Source/cmGlobalGenerator.h6
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx9
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h4
-rw-r--r--Tests/RunCMake/FileAPI/check_index.py13
7 files changed, 55 insertions, 1 deletions
diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst
index f5e4eeb..a1b4830 100644
--- a/Help/manual/cmake-file-api.7.rst
+++ b/Help/manual/cmake-file-api.7.rst
@@ -197,6 +197,9 @@ The reply index file contains a JSON object:
"ctest": "/prefix/bin/ctest",
"cpack": "/prefix/bin/cpack",
"root": "/prefix/share/cmake-3.14"
+ },
+ "generator": {
+ "name": "Unix Makefiles"
}
},
"objects": [
@@ -260,6 +263,16 @@ The members are:
the absolute path to the directory containing CMake resources like the
``Modules/`` directory (see :variable:`CMAKE_ROOT`).
+ ``generator``
+ A JSON object describing the CMake generator used for the build.
+ It has members:
+
+ ``name``
+ A string specifying the name of the generator.
+ ``platform``
+ If the generator supports :variable:`CMAKE_GENERATOR_PLATFORM`,
+ this is a string specifying the generator platform name.
+
``objects``
A JSON array listing all versions of all `Object Kinds`_ generated
as part of the reply. Each array entry is a
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx
index 2fa5495..1a41370 100644
--- a/Source/cmFileAPI.cxx
+++ b/Source/cmFileAPI.cxx
@@ -4,6 +4,7 @@
#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
+#include "cmGlobalGenerator.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmake.h"
@@ -311,6 +312,7 @@ Json::Value cmFileAPI::BuildCMake()
cmake_paths["ctest"] = cmSystemTools::GetCTestCommand();
cmake_paths["cpack"] = cmSystemTools::GetCPackCommand();
cmake_paths["root"] = cmSystemTools::GetCMakeRoot();
+ cmake["generator"] = this->CMakeInstance->GetGlobalGenerator()->GetJson();
return cmake;
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 8b20db6..35d716c 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -112,6 +112,15 @@ cmGlobalGenerator::~cmGlobalGenerator()
delete this->ExtraGenerator;
}
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+Json::Value cmGlobalGenerator::GetJson() const
+{
+ Json::Value generator = Json::objectValue;
+ generator["name"] = this->GetName();
+ return generator;
+}
+#endif
+
bool cmGlobalGenerator::SetGeneratorInstance(std::string const& i,
cmMakefile* mf)
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 1ea2d24..4e6b6de 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -24,6 +24,7 @@
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include "cmFileLockPool.h"
+# include "cm_jsoncpp_value.h"
#endif
#define CMAKE_DIRECTORY_ID_SEP "::@"
@@ -70,6 +71,11 @@ public:
return codecvt::None;
}
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ /** Get a JSON object describing the generator. */
+ virtual Json::Value GetJson() const;
+#endif
+
/** Tell the generator about the target system. */
virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; }
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 21121f2..1be80ac 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -254,6 +254,15 @@ cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator(
return lg;
}
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+Json::Value cmGlobalVisualStudio7Generator::GetJson() const
+{
+ Json::Value generator = this->cmGlobalVisualStudioGenerator::GetJson();
+ generator["platform"] = this->GetPlatformName();
+ return generator;
+}
+#endif
+
std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const
{
if (!this->GeneratorPlatform.empty()) {
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 251478d..59e7a98 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -28,6 +28,10 @@ public:
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ Json::Value GetJson() const override;
+#endif
+
bool SetSystemName(std::string const& s, cmMakefile* mf) override;
bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
diff --git a/Tests/RunCMake/FileAPI/check_index.py b/Tests/RunCMake/FileAPI/check_index.py
index 4d90d59..d8eaecb 100644
--- a/Tests/RunCMake/FileAPI/check_index.py
+++ b/Tests/RunCMake/FileAPI/check_index.py
@@ -23,9 +23,10 @@ def is_string(x):
def check_cmake(cmake):
assert is_dict(cmake)
- assert sorted(cmake.keys()) == ["paths", "version"]
+ assert sorted(cmake.keys()) == ["generator", "paths", "version"]
check_cmake_version(cmake["version"])
check_cmake_paths(cmake["paths"])
+ check_cmake_generator(cmake["generator"])
def check_cmake_version(v):
assert is_dict(v)
@@ -45,6 +46,16 @@ def check_cmake_paths(v):
assert is_string(v["ctest"])
assert is_string(v["root"])
+def check_cmake_generator(g):
+ assert is_dict(g)
+ name = g.get("name", None)
+ assert is_string(name)
+ if name.startswith("Visual Studio"):
+ assert sorted(g.keys()) == ["name", "platform"]
+ assert is_string(g["platform"])
+ else:
+ assert sorted(g.keys()) == ["name"]
+
def check_index_object(indexEntry, kind, major, minor, check):
assert is_dict(indexEntry)
assert sorted(indexEntry.keys()) == ["jsonFile", "kind", "version"]