On Thu, Jan 8, 2015 at 5:42 PM, Anton Makeev <anton.mak...@jetbrains.com> wrote:
> Aleix Pol <aleixpol@...> writes:
>
>>....
>>
>> I'd really appreciate your feedback on the patch I provided, I'll be
>> happy to provide the information you miss.
>> Aleix
>
> Aleix, could you please point me to the most recent patch version?
>
>
>
>
>
>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers

I'll attach it in this e-mail, to make sure it reaches.

Aleix

PS: there's no changes system for cmake  like reviewboard, is there?
From 806d6788ca93b5dbd0dc6e25947c07f149f64a38 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleix...@kde.org>
Date: Mon, 6 Oct 2014 17:35:31 +0200
Subject: [PATCH] cmake: Add option to generate target metadata for IDEs

Create a CMAKE_EXPORT_PROJECT_METADATA option that can be used to enable
generation of a 'ProjectTargets.json' file.  Write into the file a JSON
description of the build targets that an IDE might load.
---
 Modules/CMakeGenericSystem.cmake |   5 ++
 Source/cmGlobalGenerator.cxx     | 133 ++++++++++++++++++++++++++++++++++++++-
 Source/cmGlobalGenerator.h       |   1 +
 3 files changed, 137 insertions(+), 2 deletions(-)

diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 8a14aea..0e7f48a 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -67,6 +67,11 @@ if(CMAKE_GENERATOR MATCHES "Ninja")
   mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
 endif()
 
+set(CMAKE_EXPORT_PROJECT_METADATA "" CACHE STRING
+    "Enables the output of a ProjectTargets.json file during generation when a version is provided."
+)
+mark_as_advanced(CMAKE_EXPORT_PROJECT_METADATA)
+
 # GetDefaultWindowsPrefixBase
 #
 # Compute the base directory for CMAKE_INSTALL_PREFIX based on:
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index dd7fbc8..7fef858 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2899,6 +2899,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
 }
 
 //----------------------------------------------------------------------------
+
 void cmGlobalGenerator::WriteSummary()
 {
   cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
@@ -2908,8 +2909,6 @@ void cmGlobalGenerator::WriteSummary()
   fname += cmake::GetCMakeFilesDirectory();
   fname += "/TargetDirectories.txt";
   cmGeneratedFileStream fout(fname.c_str());
-
-  // Generate summary information files for each target.
   for(TargetMap::const_iterator ti =
         this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
     {
@@ -2920,6 +2919,136 @@ void cmGlobalGenerator::WriteSummary()
     this->WriteSummary(ti->second);
     fout << ti->second->GetSupportDirectory() << "\n";
     }
+
+  const char* version = mf->GetDefinition("CMAKE_EXPORT_PROJECT_METADATA");
+  if(version && *version)
+    {
+      if (std::string(version) == "1.0")
+        WriteProjectTargetsJson();
+      else
+        cmSystemTools::Error(
+          "Generator implementation error, "
+          "Unknown export metadata version.");
+    }
+}
+
+void printBacktraceJson(const cmListFileBacktrace& bt, cmGeneratedFileStream& stream)
+{
+  stream << '[';
+  for(cmListFileBacktrace::const_iterator it = bt.begin(); it!=bt.end(); ++it)
+    {
+      const cmListFileContext& ctx = *it;
+
+      if(it!=bt.begin())
+            stream << ", ";
+
+      stream << '\"';
+      stream << ctx.FilePath;
+      stream << ':';
+      stream << ctx.Line;
+      stream << '\"';
+    }
+  stream << ']';
+}
+
+void cmGlobalGenerator::WriteProjectTargetsJson()
+{
+  cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
+  std::string projectTargetsPath = mf->GetHomeOutputDirectory();
+  projectTargetsPath += "/ProjectTargets.json";
+  cmGeneratedFileStream aout(projectTargetsPath.c_str());
+  aout <<
+    "{\n"
+    "  \"version\": \"" << cmVersion::GetCMakeVersion() << "\",\n"
+    "  \"dependencies\": [\n"
+    ;
+
+  for(std::vector<cmLocalGenerator*>::const_iterator i =
+        this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i)
+    {
+    std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
+    for(std::vector<std::string>::const_iterator fi = lf.begin();
+        fi != lf.end(); ++fi)
+      {
+      bool last = (fi+1) == lf.end() && (i+1) == this->LocalGenerators.end();
+      aout << "    \"" << *fi << (last ? "\"\n" : "\",\n");
+      }
+    }
+  aout <<
+    "  ],\n"
+    "  \"targets\": [\n"
+    ;
+
+  // Generate summary information files for each target.
+  for(TargetMap::const_iterator ti =
+        this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
+    {
+    if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
+
+    cmTarget* t = ti->second;
+    aout <<
+      "    {\n"
+      "      \"name\": \"" << ti->first << "\",\n"
+      "      \"type\": \"" << cmTarget::GetTargetTypeName(t->GetType()) << "\",\n"
+      ;
+
+    std::vector<std::string> configs;
+    t->GetMakefile()->GetConfigurations(configs);
+
+    aout << "      \"configs\": [\n";
+    for (unsigned int i = 0; i<configs.size(); ++i)
+      {
+      std::vector<cmSourceFile*> sources;
+      t->GetSourceFiles(sources, configs[i]);
+      aout << "        {\n"
+              "          \"name\": \"" << configs[i] << "\",\n"
+              "          \"sources\": [\n";
+      for (unsigned int j = 0; j<sources.size(); ++j)
+        {
+        aout << "            \""<< sources[j]->GetFullPath();
+        if ((j+1)>=sources.size())
+          aout << "\"\n";
+        else
+          aout << "\",\n";
+        }
+      aout << "          ]\n";
+      if ((i+1)>=configs.size())
+        aout << "        }\n";
+      else
+        aout << "        },\n";
+      }
+    aout << "      ],\n";
+
+    if(t->GetType() != cmTarget::UTILITY)
+      {
+      aout <<
+        "      \"directory\": \"" << t->GetDirectory() << "\",\n"
+        "      \"location\": \"" << t->GetLocationForBuild() << "\",\n"
+        "      \"backtrace\": "
+        ;
+      printBacktraceJson(t->GetBacktrace(), aout);
+      aout << ",\n";
+      }
+    aout <<
+      "      \"installed\": "
+      << (t->GetHaveInstallRule() ? "true" : "false") << "\n"
+      ;
+
+    TargetMap::const_iterator ti1 = ti;
+    if((++ti1) == this->TotalTargets.end())
+      {
+      aout << "    }\n";
+      }
+    else
+      {
+      aout << "    },\n";
+      }
+    }
+  aout << "  ]\n";
+  aout << "}\n";
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 08f061a..bb02df9 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -457,6 +457,7 @@ private:
 
   void WriteSummary();
   void WriteSummary(cmTarget* target);
+  void WriteProjectTargetsJson();
   void FinalizeTargetCompileInfo();
 
   virtual void ForceLinkerLanguages();
-- 
2.2.1

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to