[Cmake-commits] CMake branch, next, updated. v3.0.0-rc1-1016-g3aafa45

Stephen Kelly steveire at gmail.com
Fri Mar 14 05:03:28 EDT 2014


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  3aafa45107d37d75ef969877158367479a268fed (commit)
       via  9d865d4361fb5e325b803b83aee774c1d8acc0a0 (commit)
       via  622338828825c6eb7e79989fe4be7337ef33b204 (commit)
       via  9a026b902b7c7c263e6c3a70f755f974e8953132 (commit)
      from  f851206bae9b9f3ecf8c01e4f52c32ffa896bfe2 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3aafa45107d37d75ef969877158367479a268fed
commit 3aafa45107d37d75ef969877158367479a268fed
Merge: f851206 9d865d4
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Mar 14 05:03:27 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Mar 14 05:03:27 2014 -0400

    Merge topic 'fix-Qt4-moc-commands-depends' into next
    
    9d865d43 Qt4: Fix moc command dependencies for incremental build.
    62233882 CustomCommand: Evaluate generator expressions in DEPENDS.
    9a026b90 CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d865d4361fb5e325b803b83aee774c1d8acc0a0
commit 9d865d4361fb5e325b803b83aee774c1d8acc0a0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Mar 4 11:03:37 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Mar 14 10:01:29 2014 +0100

    Qt4: Fix moc command dependencies for incremental build.
    
    Since commit v2.8.12~327^2 (Qt4Macros: Allow specifying a TARGET
    in invokations of macros., 2013-02-26), a parameters file is
    populated with moc arguments at generate-time.
    
    When the compile definitions or include directories change, the
    parameters file is updated but moc is not re-run in response.
    
    Fix that by making the moc invocation depend on the parameters file.
    
    Reported-At: https://bugreports.qt-project.org/browse/QTBUG-36970

diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index 8baf896..aca8996 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -141,7 +141,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target)
   set(_moc_extra_parameters_file @${_moc_parameters_file})
   add_custom_command(OUTPUT ${outfile}
                       COMMAND Qt4::moc ${_moc_extra_parameters_file}
-                      DEPENDS ${infile}
+                      DEPENDS ${infile} ${_moc_parameters_file}
                       ${_moc_working_dir}
                       VERBATIM)
 endmacro ()
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt
index af9fc3f..60954a2 100644
--- a/Tests/Qt4Targets/CMakeLists.txt
+++ b/Tests/Qt4Targets/CMakeLists.txt
@@ -36,3 +36,24 @@ add_executable(Qt4WrapMacroTest WIN32 main_wrap_test.cpp ${moc_file})
 set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF)
 target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
 target_link_libraries(Qt4WrapMacroTest Qt4::QtGui)
+
+set(timeformat "%Y%j%H%M%S")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild")
+execute_process(COMMAND "${CMAKE_COMMAND}" -DADD_DEF=0 "-H${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" "-B${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}")
+execute_process(COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild")
+file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_before "${timeformat}")
+if (NOT tsvar_before)
+  message(SEND_ERROR "Unable to read timestamp from moc file from first build!")
+endif()
+
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that at least a second passes.
+execute_process(COMMAND "${CMAKE_COMMAND}" -DADD_DEF=1 "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}")
+execute_process(COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild")
+file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_after "${timeformat}")
+if (NOT tsvar_after)
+  message(SEND_ERROR "Unable to read timestamp from moc file from first build!")
+endif()
+
+if (NOT tsvar_after GREATER tsvar_before)
+  message(SEND_ERROR "Rebuild did not re-create moc file. Before: ${tsvar_before}. After: ${tsvar_after}")
+endif()
diff --git a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
new file mode 100644
index 0000000..4ba0ced
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
@@ -0,0 +1,13 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(IncrementalMoc)
+
+find_package(Qt4 REQUIRED)
+
+qt4_generate_moc(foo.h moc_foo.cpp)
+
+add_library(testlib foo.cpp moc_foo.cpp)
+target_link_libraries(testlib Qt4::QtCore)
+if (ADD_DEF)
+  target_compile_definitions(testlib PRIVATE NEW_DEF)
+endif()
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.cpp b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
new file mode 100644
index 0000000..e924f7e
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
@@ -0,0 +1,8 @@
+
+#include "foo.h"
+
+Foo::Foo()
+  : QObject(0)
+{
+
+}
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.h b/Tests/Qt4Targets/IncrementalMoc/foo.h
new file mode 100644
index 0000000..38d899f
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.h
@@ -0,0 +1,9 @@
+
+#include <QObject>
+
+class Foo : QObject
+{
+  Q_OBJECT
+public:
+  Foo();
+};

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=622338828825c6eb7e79989fe4be7337ef33b204
commit 622338828825c6eb7e79989fe4be7337ef33b204
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Mar 7 17:20:10 2014 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Mar 14 10:01:27 2014 +0100

    CustomCommand: Evaluate generator expressions in DEPENDS.
    
    Rely on evaluation in cmCustomCommandGenerator for the generators.
    
    When tracing target dependencies, depend on the union of dependencies
    for all configurations.

diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index b0c5446..028ca5a 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -156,3 +156,7 @@ target is built before any target using this custom command.
 Additionally, if the target is an executable or library a file-level
 dependency is created to cause the custom command to re-run whenever
 the target is recompiled.
+
+Arguments to ``DEPENDS`` may use "generator expressions" with the syntax
+``$<...>``.  See the :manual:`cmake-generator-expressions(7)` manual for
+available expressions.
diff --git a/Help/release/dev/add_custom_command-DEPENDS-genex.rst b/Help/release/dev/add_custom_command-DEPENDS-genex.rst
new file mode 100644
index 0000000..62f6f47
--- /dev/null
+++ b/Help/release/dev/add_custom_command-DEPENDS-genex.rst
@@ -0,0 +1,5 @@
+add_custom_command-DEPENDS-genex
+--------------------------------
+
+* The :command:`add_custom_command` command learned to interpret
+:manual:`cmake-generator-expressions(7)` in arguments to ``DEPENDS``.
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index a091cff..c359dda 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -21,7 +21,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(
   cmCustomCommand const& cc, const std::string& config, cmMakefile* mf):
   CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()),
   OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
-  GE(new cmGeneratorExpression(cc.GetBacktrace()))
+  GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false)
 {
 }
 
@@ -93,5 +93,18 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
 //----------------------------------------------------------------------------
 std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
 {
-  return this->CC.GetDepends();
+  if (!this->DependsDone)
+    {
+    this->DependsDone = true;
+    std::vector<std::string> depends = this->CC.GetDepends();
+    for(std::vector<std::string>::const_iterator
+          i = depends.begin();
+        i != depends.end(); ++i)
+      {
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i);
+      cmSystemTools::ExpandListArgument(
+                  cge->Evaluate(this->Makefile, this->Config), this->Depends);
+      }
+    }
+  return this->Depends;
 }
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index cbcdb41..0d8a0a4 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -28,6 +28,8 @@ class cmCustomCommandGenerator
   bool OldStyle;
   bool MakeVars;
   cmGeneratorExpression* GE;
+  mutable bool DependsDone;
+  mutable std::vector<std::string> Depends;
 public:
   cmCustomCommandGenerator(cmCustomCommand const& cc,
                            const std::string& config,
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index db88749..fc6b881 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -604,6 +604,9 @@ private:
   bool IsUtility(std::string const& dep);
   void CheckCustomCommand(cmCustomCommand const& cc);
   void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
+  void FollowCommandDepends(cmCustomCommand const& cc,
+                            const std::string& config,
+                            std::set<std::string>& emitted);
 };
 
 //----------------------------------------------------------------------------
@@ -820,16 +823,48 @@ cmTargetTraceDependencies
     }
 
   // Queue the custom command dependencies.
-  std::vector<std::string> const& depends = cc.GetDepends();
-  for(std::vector<std::string>::const_iterator di = depends.begin();
-      di != depends.end(); ++di)
+  std::vector<std::string> configs;
+  std::set<std::string> emitted;
+  this->Makefile->GetConfigurations(configs);
+  if (configs.empty())
+    {
+    this->FollowCommandDepends(cc, "", emitted);
+    }
+  for(std::vector<std::string>::const_iterator ci = configs.begin();
+      ci != configs.end(); ++ci)
+    {
+    this->FollowCommandDepends(cc, *ci, emitted);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc,
+                                              const std::string& config,
+                                              std::set<std::string>& emitted)
+{
+  cmListFileBacktrace lfbt;
+  std::vector<std::string> evaluatedDepends;
+  for(std::vector<std::string>::const_iterator di = cc.GetDepends().begin();
+      di != cc.GetDepends().end(); ++di)
+    {
+    cmGeneratorExpression ge(lfbt);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*di);
+    cmSystemTools::ExpandListArgument(
+      cge->Evaluate(this->Makefile, config), evaluatedDepends);
+    }
+
+  for(std::vector<std::string>::const_iterator di = evaluatedDepends.begin();
+      di != evaluatedDepends.end(); ++di)
     {
     std::string const& dep = *di;
-    if(!this->IsUtility(dep))
+    if(emitted.insert(dep).second)
       {
-      // The dependency does not name a target and may be a file we
-      // know how to generate.  Queue it.
-      this->FollowName(dep);
+      if(!this->IsUtility(dep))
+        {
+        // The dependency does not name a target and may be a file we
+        // know how to generate.  Queue it.
+        this->FollowName(dep);
+        }
       }
     }
 }
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index bbae387..4a74aec 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -185,7 +185,7 @@ add_executable(CustomCommand
 # here to test adding the generation rule after referencing the
 # generated source in a target.
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c
-  DEPENDS generator
+  DEPENDS $<1:generator> $<0:does_not_exist>
   COMMAND generator
   ARGS ${PROJECT_BINARY_DIR}/generated.c
   )

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

Summary of changes:
 Help/command/add_custom_command.rst                |    4 ++
 .../dev/add_custom_command-DEPENDS-genex.rst       |    5 ++
 Modules/Qt4Macros.cmake                            |    2 +-
 Source/CMakeVersion.cmake                          |    2 +-
 Source/cmCustomCommandGenerator.cxx                |   17 ++++++-
 Source/cmCustomCommandGenerator.h                  |    2 +
 Source/cmGeneratorTarget.cxx                       |   49 +++++++++++++++++---
 Tests/CustomCommand/CMakeLists.txt                 |    2 +-
 Tests/Qt4Targets/CMakeLists.txt                    |   21 +++++++++
 Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt     |   13 ++++++
 Tests/Qt4Targets/IncrementalMoc/foo.cpp            |    8 ++++
 Tests/Qt4Targets/IncrementalMoc/foo.h              |    9 ++++
 12 files changed, 122 insertions(+), 12 deletions(-)
 create mode 100644 Help/release/dev/add_custom_command-DEPENDS-genex.rst
 create mode 100644 Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
 create mode 100644 Tests/Qt4Targets/IncrementalMoc/foo.cpp
 create mode 100644 Tests/Qt4Targets/IncrementalMoc/foo.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list