This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  3cd8011d1576a9fb028d34b2789178d2326f6b5b (commit)
       via  84946c735cc6d2b8f8e014f4772dd602b4a83a16 (commit)
       via  9c6fa684e7681417f5e75f25034f28212e22b229 (commit)
      from  b58bed802af3c9036296688a2987c9a2d5dcd0ff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3cd8011d1576a9fb028d34b2789178d2326f6b5b
commit 3cd8011d1576a9fb028d34b2789178d2326f6b5b
Merge: b58bed8 84946c7
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Fri Apr 22 08:57:05 2016 -0400
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Fri Apr 22 08:57:05 2016 -0400

    Merge topic 'autogen-updates' into next
    
    84946c73 Tests: QtAutogen: Same source name in different directories test
    9c6fa684 Autogen: Generate qrc_NAME.cpp files in subdirectories


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=84946c735cc6d2b8f8e014f4772dd602b4a83a16
commit 84946c735cc6d2b8f8e014f4772dd602b4a83a16
Author:     Sebastian Holtermann <sebh...@xwmw.org>
AuthorDate: Wed Apr 13 18:36:39 2016 +0200
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Fri Apr 22 08:55:44 2016 -0400

    Tests: QtAutogen: Same source name in different directories test
    
    The test features multiple .cpp and .qrc files with the same name
    in different subdirectories. This requires AUTOMOC and AUTORCC to
    generate files with names that respect the path information of
    the source files.

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index d5aca55..4875165 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -110,6 +110,10 @@ set_target_properties(
   AUTOMOC TRUE
 )
 
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+add_subdirectory(same_name)
+
 include(GenerateExportHeader)
 # The order is relevant here. B depends on A, and B headers depend on A
 # headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
diff --git a/Tests/QtAutogen/same_name/CMakeLists.txt 
b/Tests/QtAutogen/same_name/CMakeLists.txt
new file mode 100644
index 0000000..54bf048
--- /dev/null
+++ b/Tests/QtAutogen/same_name/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+
+add_executable(same_name
+  aaa/bbb/item.cpp
+  aaa/bbb/data.qrc
+  aaa/item.cpp
+  aaa/data.qrc
+  bbb/aaa/item.cpp
+  bbb/aaa/data.qrc
+  bbb/item.cpp
+  bbb/data.qrc
+  ccc/item.cpp
+  ccc/data.qrc
+  main.cpp
+  data.qrc
+)
+target_include_directories(same_name PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(same_name ${QT_LIBRARIES})
+set_target_properties( same_name PROPERTIES AUTOMOC TRUE AUTORCC TRUE )
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/data.qrc 
b/Tests/QtAutogen/same_name/aaa/bbb/data.qrc
new file mode 100644
index 0000000..0ea3537
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/bbb">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.cpp 
b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp
new file mode 100644
index 0000000..d715116
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp
@@ -0,0 +1,12 @@
+#include "item.hpp"
+
+namespace aaa {
+namespace bbb {
+
+void
+Item::go ( )
+{
+}
+
+}
+}
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.hpp 
b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp
new file mode 100644
index 0000000..c82309d
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp
@@ -0,0 +1,19 @@
+#ifndef SDA_SDB_ITEM_HPP
+#define SDA_SDB_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+namespace bbb {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go ( );
+};
+
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/aaa/data.qrc 
b/Tests/QtAutogen/same_name/aaa/data.qrc
new file mode 100644
index 0000000..379af60
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/aaa/item.cpp 
b/Tests/QtAutogen/same_name/aaa/item.cpp
new file mode 100644
index 0000000..7887d76
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/item.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+namespace aaa {
+
+void
+Item::go ( )
+{
+}
+
+}
diff --git a/Tests/QtAutogen/same_name/aaa/item.hpp 
b/Tests/QtAutogen/same_name/aaa/item.hpp
new file mode 100644
index 0000000..3c24275
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/item.hpp
@@ -0,0 +1,17 @@
+#ifndef SDA_ITEM_HPP
+#define SDA_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go ( );
+};
+
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/data.qrc 
b/Tests/QtAutogen/same_name/bbb/aaa/data.qrc
new file mode 100644
index 0000000..da98009
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/aaa/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.cpp 
b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp
new file mode 100644
index 0000000..36d5b6d
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp
@@ -0,0 +1,12 @@
+#include "item.hpp"
+
+namespace bbb {
+namespace aaa {
+
+void
+Item::go ( )
+{
+}
+
+}
+}
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.hpp 
b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp
new file mode 100644
index 0000000..35a3686
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp
@@ -0,0 +1,19 @@
+#ifndef SDB_SDA_ITEM_HPP
+#define SDB_SDA_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+namespace aaa {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go ( );
+};
+
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/bbb/data.qrc 
b/Tests/QtAutogen/same_name/bbb/data.qrc
new file mode 100644
index 0000000..5b080f5
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/bbb/item.cpp 
b/Tests/QtAutogen/same_name/bbb/item.cpp
new file mode 100644
index 0000000..064295b
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/item.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+namespace bbb {
+
+void
+Item::go ( )
+{
+}
+
+}
diff --git a/Tests/QtAutogen/same_name/bbb/item.hpp 
b/Tests/QtAutogen/same_name/bbb/item.hpp
new file mode 100644
index 0000000..eda84a2
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/item.hpp
@@ -0,0 +1,17 @@
+#ifndef SDB_ITEM_HPP
+#define SDB_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go ( );
+};
+
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/ccc/data.qrc 
b/Tests/QtAutogen/same_name/ccc/data.qrc
new file mode 100644
index 0000000..f934c39
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="ccc/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/ccc/item.cpp 
b/Tests/QtAutogen/same_name/ccc/item.cpp
new file mode 100644
index 0000000..2584881
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/item.cpp
@@ -0,0 +1,26 @@
+#include "item.hpp"
+
+namespace ccc {
+
+void
+Item::go ( )
+{
+}
+
+class MocTest : public QObject
+{
+  Q_OBJECT;
+  Q_SLOT
+  void go ( );
+};
+
+void
+MocTest::go()
+{
+}
+
+}
+
+// Include own moc files
+#include "moc_item.cpp"
+#include "item.moc"
diff --git a/Tests/QtAutogen/same_name/ccc/item.hpp 
b/Tests/QtAutogen/same_name/ccc/item.hpp
new file mode 100644
index 0000000..6386dc6
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/item.hpp
@@ -0,0 +1,17 @@
+#ifndef SDC_ITEM_HPP
+#define SDC_ITEM_HPP
+
+#include <QObject>
+
+namespace ccc {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go ( );
+};
+
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/data.qrc 
b/Tests/QtAutogen/same_name/data.qrc
new file mode 100644
index 0000000..4ce0b4e
--- /dev/null
+++ b/Tests/QtAutogen/same_name/data.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+  <file>main.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/main.cpp 
b/Tests/QtAutogen/same_name/main.cpp
new file mode 100644
index 0000000..166466e
--- /dev/null
+++ b/Tests/QtAutogen/same_name/main.cpp
@@ -0,0 +1,16 @@
+#include "aaa/item.hpp"
+#include "aaa/bbb/item.hpp"
+#include "bbb/item.hpp"
+#include "bbb/aaa/item.hpp"
+#include "ccc/item.hpp"
+
+int main(int argv, char **args)
+{
+  // Object instances
+  ::aaa::Item aaa_item;
+  ::aaa::bbb::Item aaa_bbb_item;
+  ::bbb::Item bbb_item;
+  ::bbb::aaa::Item bbb_aaa_item;
+  ::ccc::Item ccc_item;
+  return 0;
+}

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c6fa684e7681417f5e75f25034f28212e22b229
commit 9c6fa684e7681417f5e75f25034f28212e22b229
Author:     Sebastian Holtermann <sebh...@xwmw.org>
AuthorDate: Tue Apr 19 11:02:48 2016 +0200
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Fri Apr 22 08:54:25 2016 -0400

    Autogen: Generate qrc_NAME.cpp files in subdirectories
    
    A qrc_NAME.cpp file generated from NAME.qrc in the directory
    CMAKE_CURRENT_SOURCE_DIR/SUBDIR
    will be generated in the directory
    CMAKE_CURRENT_BINARY_DIR/TARGETNAME_automoc.dir/SUBDIR

diff --git a/Source/cmQtAutoGeneratorInitializer.cxx 
b/Source/cmQtAutoGeneratorInitializer.cxx
index 4cab81f..ea9ea7c 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -25,6 +25,87 @@
 # include "cmGlobalVisualStudioGenerator.h"
 #endif
 
+static std::string GetAutogenTargetName(
+    cmGeneratorTarget const* target)
+{
+  std::string autogenTargetName = target->GetName();
+  autogenTargetName += "_automoc";
+  return autogenTargetName;
+}
+
+static std::string GetAutogenTargetDir(
+    cmGeneratorTarget const* target)
+{
+  cmMakefile* makefile = target->Target->GetMakefile();
+  std::string targetDir = makefile->GetCurrentBinaryDirectory();
+  targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
+  targetDir += "/";
+  targetDir += GetAutogenTargetName(target);
+  targetDir += ".dir/";
+  return targetDir;
+}
+
+static std::string GetAutogenTargetBuildDir(
+    cmGeneratorTarget const* target)
+{
+  cmMakefile* makefile = target->Target->GetMakefile();
+  std::string targetDir = makefile->GetCurrentBinaryDirectory();
+  targetDir += "/";
+  targetDir += GetAutogenTargetName(target);
+  targetDir += ".dir/";
+  return targetDir;
+}
+
+static std::string GetSourceRelativePath(
+    cmGeneratorTarget const* target,
+    const std::string& fileName)
+{
+  std::string pathRel;
+  // Test if the file is child to any of the known directories
+  {
+    const std::string fileNameReal = cmsys::SystemTools::GetRealPath(fileName);
+    std::string parentDirectory;
+    bool match ( false );
+    {
+      std::string testDirs[4];
+      {
+        cmMakefile* makefile = target->Target->GetMakefile();
+        testDirs[0] = makefile->GetCurrentSourceDirectory();
+        testDirs[1] = makefile->GetCurrentBinaryDirectory();
+        testDirs[2] = makefile->GetHomeDirectory();
+        testDirs[3] = makefile->GetHomeOutputDirectory();
+      }
+      for(int ii=0; ii != sizeof(testDirs)/sizeof(std::string); ++ii )
+        {
+        const ::std::string testDir = cmsys::SystemTools::GetRealPath(
+                                                                 testDirs[ii]);
+        if (!testDir.empty()
+            && cmsys::SystemTools::IsSubDirectory(fileNameReal, testDir) )
+          {
+          parentDirectory = testDir;
+          match = true;
+          break;
+          }
+        }
+    }
+    // Use root as fallback parent directory
+    if (!match)
+      {
+      cmsys::SystemTools::SplitPathRootComponent(fileNameReal,
+                                                 &parentDirectory);
+      }
+    pathRel = cmsys::SystemTools::RelativePath(
+      parentDirectory, cmsys::SystemTools::GetParentDirectory(fileNameReal));
+  }
+  // Sanitize relative path
+  if (!pathRel.empty())
+    {
+    pathRel += '/';
+    cmSystemTools::ReplaceString(pathRel, "..", "__");
+    }
+  return pathRel;
+}
+
 static void SetupSourceFiles(cmGeneratorTarget const* target,
                                    std::vector<std::string>& skipMoc,
                                    std::vector<std::string>& mocSources,
@@ -61,13 +142,16 @@ static void SetupSourceFiles(cmGeneratorTarget const* 
target,
       if (ext == "qrc"
           && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
         {
+
+        std::string rcc_output_dir = GetAutogenTargetBuildDir(target);
+        rcc_output_dir += GetSourceRelativePath(target,absFile);
+        cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+
         std::string basename = cmsys::SystemTools::
                                       GetFilenameWithoutLastExtension(absFile);
 
-        std::string rcc_output_dir = target->GetSupportDirectory();
-        cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
         std::string rcc_output_file = rcc_output_dir;
-        rcc_output_file += "/qrc_" + basename + ".cpp";
+        rcc_output_file += "qrc_" + basename + ".cpp";
         makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
                                 rcc_output_file.c_str(), false);
         makefile->GetOrCreateSource(rcc_output_file, true);
@@ -433,26 +517,6 @@ static void MergeRccOptions(std::vector<std::string> &opts,
   opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
 }
 
-std::string GetAutogenTargetName(
-    cmGeneratorTarget const* target)
-{
-  std::string autogenTargetName = target->GetName();
-  autogenTargetName += "_automoc";
-  return autogenTargetName;
-}
-
-std::string GetAutogenTargetDir(
-    cmGeneratorTarget const* target)
-{
-  cmMakefile* makefile = target->Target->GetMakefile();
-  std::string targetDir = makefile->GetCurrentBinaryDirectory();
-  targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
-  targetDir += "/";
-  targetDir += GetAutogenTargetName(target);
-  targetDir += ".dir/";
-  return targetDir;
-}
-
 static void copyTargetProperty(cmTarget* destinationTarget,
                                cmTarget* sourceTarget,
                                const std::string& propertyName)
@@ -858,14 +922,18 @@ void 
cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
         if (ext == "qrc"
             && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
           {
-          std::string basename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(absFile);
-
-          std::string rcc_output_dir = target->GetSupportDirectory();
-          cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
-          std::string rcc_output_file = rcc_output_dir;
-          rcc_output_file += "/qrc_" + basename + ".cpp";
-          rcc_output.push_back(rcc_output_file);
+
+          {
+            std::string rcc_output_dir = GetAutogenTargetBuildDir(target);
+            rcc_output_dir += GetSourceRelativePath(target,absFile);
+            cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+
+            std::string basename = cmsys::SystemTools::
+                                    GetFilenameWithoutLastExtension(absFile);
+            std::string rcc_output_file = rcc_output_dir;
+            rcc_output_file += "qrc_" + basename + ".cpp";
+            rcc_output.push_back(rcc_output_file);
+          }
 
           if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
             {
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 1431323..3c6db2d 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1399,8 +1399,11 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
       {
       std::string basename = cmsys::SystemTools::
         GetFilenameWithoutLastExtension(*si);
-      std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
-        + ".dir/qrc_" + basename + ".cpp";
+      std::string qrcOutputFile = this->TargetBuildSubDir
+        + this->SourceRelativePath ( *si )
+        + "qrc_" + basename + ".cpp";
+      //std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
+      //                         + ".dir/qrc_" + basename + ".cpp";
       qrcGenMap[*si] = qrcOutputFile;
       }
     }
@@ -1438,8 +1441,10 @@ bool cmQtAutoGenerators::GenerateQrc (
   const std::string& qrcInputFile,
   const std::string& qrcOutputFile )
 {
-  const std::string basename = cmsys::SystemTools::
-    GetFilenameWithoutLastExtension(qrcInputFile);
+  std::string relName = this->SourceRelativePath ( qrcInputFile );
+  cmSystemTools::ReplaceString(relName, "/", "_");
+  relName += cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
+
   const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
 
   int sourceNewerThanQrc = 0;
@@ -1469,7 +1474,7 @@ bool cmQtAutoGenerators::GenerateQrc (
       }
 
     command.push_back("-name");
-    command.push_back(basename);
+    command.push_back(relName);
     command.push_back("-o");
     command.push_back(qrcBuildFile);
     command.push_back(qrcInputFile);

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/mailman/listinfo/cmake-commits

Reply via email to