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  c0566538859b568a58f23eabe12e49ff2370a140 (commit)
       via  0278989405eea53ca7e5f1bfa6af9aea7a0b49c5 (commit)
       via  a88c99f1bc301276a1780fec683d5061ca13f66f (commit)
      from  a15e3696ff5b80792bc6de10a27b1826735f1825 (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=c0566538859b568a58f23eabe12e49ff2370a140
commit c0566538859b568a58f23eabe12e49ff2370a140
Merge: a15e369 0278989
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Tue Aug 9 15:15:59 2016 -0400
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Tue Aug 9 15:15:59 2016 -0400

    Merge topic 'ninja-directory-targets' into next
    
    02789894 Ninja: Add `$subdir/{test,install,package}` targets
    a88c99f1 Ninja: Simplify computation of GLOBAL_TARGET outputs


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0278989405eea53ca7e5f1bfa6af9aea7a0b49c5
commit 0278989405eea53ca7e5f1bfa6af9aea7a0b49c5
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Fri Aug 5 15:55:32 2016 -0400
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Tue Aug 9 15:15:24 2016 -0400

    Ninja: Add `$subdir/{test,install,package}` targets
    
    With the Makefile generator one can use `cd $subdir; make install` to build 
and
    install targets associated with a given subdirectory.  This is not possible 
to
    do with the Ninja generator since there is only one `build.ninja` file at 
the
    top of the build tree.  However, we can approximate it by allowing one to 
run
    `ninja $subdir/install` at the top of the tree to build the targets in the
    corresponding subdirectory and install them.
    
    This also makes sense for `test`, `package`, and other GLOBAL_TARGET 
targets.
    It was already done for `all` by commit v3.6.0-rc1~240^2~2 (Ninja: Add
    `$subdir/all` targets, 2016-03-11).

diff --git a/Help/generator/Ninja.rst b/Help/generator/Ninja.rst
index d94e5f6..ef0e28b 100644
--- a/Help/generator/Ninja.rst
+++ b/Help/generator/Ninja.rst
@@ -7,6 +7,17 @@ A build.ninja file is generated into the build tree.  Recent 
versions
 of the ninja program can build the project through the "all" target.
 An "install" target is also provided.
 
-For each subdirectory ``sub/dir`` of the project an additional target
-named ``sub/dir/all`` is generated that depends on all targets required
-by that subdirectory.
+For each subdirectory ``sub/dir`` of the project, additional targets
+are generated:
+
+``sub/dir/all``
+  Depends on all targets required by the subdirectory.
+
+``sub/dir/install``
+  Runs the install step in the subdirectory, if any.
+
+``sub/dir/test``
+  Runs the test step in the subdirectory, if any.
+
+``sub/dir/package``
+  Runs the package step in the subdirectory, if any.
diff --git a/Help/release/dev/ninja-directory-targets.rst 
b/Help/release/dev/ninja-directory-targets.rst
new file mode 100644
index 0000000..c4269d8
--- /dev/null
+++ b/Help/release/dev/ninja-directory-targets.rst
@@ -0,0 +1,8 @@
+ninja-directory-targets
+-----------------------
+
+* The :generator:`Ninja` generator learned to produce phony targets
+  of the form ``sub/dir/{test,install,package}`` to drive the build
+  of a subdirectory installation, test or packaging target.
+  This is equivalent to ``cd sub/dir; make {test,install,package}``
+  with :ref:`Makefile Generators`.
diff --git a/Source/cmGlobalNinjaGenerator.cxx 
b/Source/cmGlobalNinjaGenerator.cxx
index afd43b8..3b8aaa6 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -885,10 +885,15 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
   cmGeneratorTarget const* target, cmNinjaDeps& outputs)
 {
   if (target->GetType() == cmState::GLOBAL_TARGET) {
-    // Global targets only depend on other utilities, which may not appear in
-    // the TargetDepends set (e.g. "all").
+    // These depend only on other CMake-provided targets, e.g. "all".
     std::set<std::string> const& utils = target->GetUtilities();
-    std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
+    for (std::set<std::string>::const_iterator i = utils.begin();
+         i != utils.end(); ++i) {
+      std::string d =
+        target->GetLocalGenerator()->GetCurrentBinaryDirectory() +
+        std::string("/") + *i;
+      outputs.push_back(this->ConvertToNinjaPath(d));
+    }
   } else {
     cmNinjaDeps outs;
     cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
diff --git a/Source/cmNinjaTargetGenerator.cxx 
b/Source/cmNinjaTargetGenerator.cxx
index 1466f8a..9030e05 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -38,19 +38,8 @@ cmNinjaTargetGenerator* 
cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
       return new cmNinjaNormalTargetGenerator(target);
 
     case cmState::UTILITY:
+    case cmState::GLOBAL_TARGET:
       return new cmNinjaUtilityTargetGenerator(target);
-      ;
-
-    case cmState::GLOBAL_TARGET: {
-      // We only want to process global targets that live in the home
-      // (i.e. top-level) directory.  CMake creates copies of these targets
-      // in every directory, which we don't need.
-      if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
-                 target->GetLocalGenerator()->GetSourceDirectory()) == 0) {
-        return new cmNinjaUtilityTargetGenerator(target);
-      }
-      // else fallthrough
-    }
 
     default:
       return CM_NULLPTR;
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx 
b/Source/cmNinjaUtilityTargetGenerator.cxx
index c549646..96a17ff 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -31,10 +31,12 @@ 
cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator()
 
 void cmNinjaUtilityTargetGenerator::Generate()
 {
-  std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash();
+  std::string utilCommandName =
+    this->GetLocalGenerator()->GetCurrentBinaryDirectory();
+  utilCommandName += cmake::GetCMakeFilesDirectory();
+  utilCommandName += "/";
   utilCommandName += this->GetTargetName() + ".util";
-  utilCommandName =
-    this->GetGlobalGenerator()->NinjaOutputPath(utilCommandName);
+  utilCommandName = this->ConvertToNinjaPath(utilCommandName);
 
   std::vector<std::string> commands;
   cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
@@ -144,6 +146,11 @@ void cmNinjaUtilityTargetGenerator::Generate()
       cmNinjaDeps(1, utilCommandName));
   }
 
-  this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
-                                             this->GetGeneratorTarget());
+  // Add an alias for the logical target name regardless of what directory
+  // contains it.  Skip this for GLOBAL_TARGET because they are meant to
+  // be per-directory and have one at the top-level anyway.
+  if (this->GetGeneratorTarget()->GetType() != cmState::GLOBAL_TARGET) {
+    this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
+                                               this->GetGeneratorTarget());
+  }
 }
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake 
b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index c73f852..622c327 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -41,10 +41,16 @@ function(run_SubDir)
   run_cmake(SubDir)
   if(WIN32)
     set(SubDir_all [[SubDir\all]])
+    set(SubDir_test [[SubDir\test]])
+    set(SubDir_install [[SubDir\install]])
   else()
     set(SubDir_all [[SubDir/all]])
+    set(SubDir_test [[SubDir/test]])
+    set(SubDir_install [[SubDir/install]])
   endif()
   run_cmake_command(SubDir-build ${CMAKE_COMMAND} --build . --target 
${SubDir_all})
+  run_cmake_command(SubDir-test ${CMAKE_COMMAND} --build . --target 
${SubDir_test})
+  run_cmake_command(SubDir-install ${CMAKE_COMMAND} --build . --target 
${SubDir_install})
 endfunction()
 run_SubDir()
 
diff --git a/Tests/RunCMake/Ninja/SubDir-install-stdout.txt 
b/Tests/RunCMake/Ninja/SubDir-install-stdout.txt
new file mode 100644
index 0000000..4261b0e
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDir-install-stdout.txt
@@ -0,0 +1 @@
+-- Installing SubDir
diff --git a/Tests/RunCMake/Ninja/SubDir-test-stdout.txt 
b/Tests/RunCMake/Ninja/SubDir-test-stdout.txt
new file mode 100644
index 0000000..9c493ac
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDir-test-stdout.txt
@@ -0,0 +1 @@
+1/1 Test #1: SubDirTest
diff --git a/Tests/RunCMake/Ninja/SubDir.cmake 
b/Tests/RunCMake/Ninja/SubDir.cmake
index 7224ec3..d227753 100644
--- a/Tests/RunCMake/Ninja/SubDir.cmake
+++ b/Tests/RunCMake/Ninja/SubDir.cmake
@@ -1,2 +1,7 @@
+include(CTest)
 add_subdirectory(SubDir)
 add_custom_target(TopFail ALL COMMAND does_not_exist)
+add_test(NAME TopTest COMMAND ${CMAKE_COMMAND} -E echo "Running TopTest")
+install(CODE [[
+  message(FATAL_ERROR "Installing Top")
+]])
diff --git a/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt 
b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt
index 73ae431..456c1db 100644
--- a/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt
+++ b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt
@@ -1,2 +1,6 @@
 add_custom_target(SubFail COMMAND does_not_exist)
 add_custom_target(InAll ALL COMMAND ${CMAKE_COMMAND} -E echo "Building InAll")
+add_test(NAME SubDirTest COMMAND ${CMAKE_COMMAND} -E echo "Running SubDirTest")
+install(CODE [[
+  message(STATUS "Installing SubDir")
+]])

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a88c99f1bc301276a1780fec683d5061ca13f66f
commit a88c99f1bc301276a1780fec683d5061ca13f66f
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Fri Aug 5 14:58:16 2016 -0400
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Tue Aug 9 14:36:04 2016 -0400

    Ninja: Simplify computation of GLOBAL_TARGET outputs
    
    In cmGlobalNinjaGenerator::AppendTargetOutputs we previously
    handled GLOBAL_TARGET outputs specially in order to avoid adding
    directory components to the output.  However, this is not necessary
    because cmNinjaTargetGenerator::New already filters out copies of
    these targets that are not at the top level.  Instead we can simply
    follow the same output computation code path as UTILITY targets.

diff --git a/Source/cmGlobalNinjaGenerator.cxx 
b/Source/cmGlobalNinjaGenerator.cxx
index 44418f2..afd43b8 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -867,6 +867,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
       break;
     }
     case cmState::OBJECT_LIBRARY:
+    case cmState::GLOBAL_TARGET:
     case cmState::UTILITY: {
       std::string path =
         target->GetLocalGenerator()->GetCurrentBinaryDirectory() +
@@ -875,12 +876,6 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs(
       break;
     }
 
-    case cmState::GLOBAL_TARGET:
-      // Always use the target in HOME instead of an unused duplicate in a
-      // subdirectory.
-      outputs.push_back(this->NinjaOutputPath(target->GetName()));
-      break;
-
     default:
       return;
   }

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

Summary of changes:
 Help/generator/Ninja.rst                       |   17 ++++++++++++++---
 Help/release/dev/ninja-directory-targets.rst   |    8 ++++++++
 Source/cmGlobalNinjaGenerator.cxx              |   18 +++++++++---------
 Source/cmNinjaTargetGenerator.cxx              |   13 +------------
 Source/cmNinjaUtilityTargetGenerator.cxx       |   17 ++++++++++++-----
 Tests/RunCMake/Ninja/RunCMakeTest.cmake        |    6 ++++++
 Tests/RunCMake/Ninja/SubDir-install-stdout.txt |    1 +
 Tests/RunCMake/Ninja/SubDir-test-stdout.txt    |    1 +
 Tests/RunCMake/Ninja/SubDir.cmake              |    5 +++++
 Tests/RunCMake/Ninja/SubDir/CMakeLists.txt     |    4 ++++
 10 files changed, 61 insertions(+), 29 deletions(-)
 create mode 100644 Help/release/dev/ninja-directory-targets.rst
 create mode 100644 Tests/RunCMake/Ninja/SubDir-install-stdout.txt
 create mode 100644 Tests/RunCMake/Ninja/SubDir-test-stdout.txt


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

Reply via email to