[Cmake-commits] CMake branch, next, updated. v3.7.0-rc2-714-g2d4e194

Brad King brad.king at kitware.com
Mon Oct 24 10:32:16 EDT 2016


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  2d4e1942743e5d150076e57b2cc5efef7f9ab115 (commit)
       via  e983bd326a9e3b7902d8f7cf0d891030ad3bd4c1 (commit)
      from  dc8b205f50d910eabbd0ef5b75873045aa862ea8 (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=2d4e1942743e5d150076e57b2cc5efef7f9ab115
commit 2d4e1942743e5d150076e57b2cc5efef7f9ab115
Merge: dc8b205 e983bd3
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Oct 24 10:32:15 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Oct 24 10:32:15 2016 -0400

    Merge topic 'ninja-subdir-binary-dir' into next
    
    e983bd32 Ninja: Use binary dir for `$subdir/all` targets


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e983bd326a9e3b7902d8f7cf0d891030ad3bd4c1
commit e983bd326a9e3b7902d8f7cf0d891030ad3bd4c1
Author:     Alexis Murzeau <amubtdx at outlook.fr>
AuthorDate: Sun Oct 23 18:58:28 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Oct 24 10:30:02 2016 -0400

    Ninja: Use binary dir for `$subdir/all` targets
    
    The targets added by commit v3.6.0-rc1~240^2~2 (Ninja: Add `$subdir/all`
    targets, 2016-03-11) use as `$subdir` the relative path from the top of
    the source tree to the current source directory.  This is not correct
    when using `add_subdirectory(test test_bin)`.  Instead we need to use
    the relative path from the top of the binary tree to the current binary
    directory as was done for related targets by commit v3.7.0-rc1~268^2
    (Ninja: Add `$subdir/{test,install,package}` targets, 2016-08-05).

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 182d7e4..ee594b0 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -879,20 +879,6 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(
   return convPath;
 }
 
-std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
-  const std::string& path)
-{
-  cmLocalNinjaGenerator* ng =
-    static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
-  std::string convPath = ng->ConvertToRelativePath(
-    this->LocalGenerators[0]->GetState()->GetSourceDirectory(), path + "/all");
-  convPath = this->NinjaOutputPath(convPath);
-#ifdef _WIN32
-  std::replace(convPath.begin(), convPath.end(), '/', '\\');
-#endif
-  return convPath;
-}
-
 void cmGlobalNinjaGenerator::AddCXXCompileCommand(
   const std::string& commandLine, const std::string& sourceFile)
 {
@@ -1119,11 +1105,11 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
          this->LocalGenerators.begin();
        lgi != this->LocalGenerators.end(); ++lgi) {
     cmLocalGenerator const* lg = *lgi;
-    const std::string currentSourceFolder(
-      lg->GetStateSnapshot().GetDirectory().GetCurrentSource());
+    const std::string currentBinaryFolder(
+      lg->GetStateSnapshot().GetDirectory().GetCurrentBinary());
     // The directory-level rule should depend on the target-level rules
     // for all targets in the directory.
-    targetsPerFolder[currentSourceFolder] = cmNinjaDeps();
+    targetsPerFolder[currentBinaryFolder] = cmNinjaDeps();
     for (std::vector<cmGeneratorTarget*>::const_iterator ti =
            lg->GetGeneratorTargets().begin();
          ti != lg->GetGeneratorTargets().end(); ++ti) {
@@ -1136,7 +1122,7 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
            type == cmStateEnums::OBJECT_LIBRARY ||
            type == cmStateEnums::UTILITY) &&
           !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
-        targetsPerFolder[currentSourceFolder].push_back(gt->GetName());
+        targetsPerFolder[currentBinaryFolder].push_back(gt->GetName());
       }
     }
 
@@ -1147,28 +1133,30 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
     for (std::vector<cmStateSnapshot>::const_iterator stateIt =
            children.begin();
          stateIt != children.end(); ++stateIt) {
-      targetsPerFolder[currentSourceFolder].push_back(
-        this->ConvertToNinjaFolderRule(
-          stateIt->GetDirectory().GetCurrentSource()));
+      std::string const currentBinaryDir =
+        stateIt->GetDirectory().GetCurrentBinary();
+
+      targetsPerFolder[currentBinaryFolder].push_back(
+        this->ConvertToNinjaPath(currentBinaryDir + "/all"));
     }
   }
 
-  std::string const rootSourceDir =
-    this->LocalGenerators[0]->GetSourceDirectory();
+  std::string const rootBinaryDir =
+    this->LocalGenerators[0]->GetBinaryDirectory();
   for (std::map<std::string, cmNinjaDeps>::const_iterator it =
          targetsPerFolder.begin();
        it != targetsPerFolder.end(); ++it) {
     cmGlobalNinjaGenerator::WriteDivider(os);
-    std::string const& currentSourceDir = it->first;
+    std::string const& currentBinaryDir = it->first;
 
-    // Do not generate a rule for the root source dir.
-    if (rootSourceDir.length() >= currentSourceDir.length()) {
+    // Do not generate a rule for the root binary dir.
+    if (rootBinaryDir.length() >= currentBinaryDir.length()) {
       continue;
     }
 
-    std::string const comment = "Folder: " + currentSourceDir;
+    std::string const comment = "Folder: " + currentBinaryDir;
     cmNinjaDeps output(1);
-    output.push_back(this->ConvertToNinjaFolderRule(currentSourceDir));
+    output.push_back(this->ConvertToNinjaPath(currentBinaryDir + "/all"));
 
     this->WritePhonyBuild(os, comment, output, it->second);
   }
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 1084469..81ec3eb 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -241,7 +241,6 @@ public:
   }
 
   std::string ConvertToNinjaPath(const std::string& path) const;
-  std::string ConvertToNinjaFolderRule(const std::string& path);
 
   struct MapToNinjaPathImpl
   {
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 446dc3c..7b4e51e 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -51,14 +51,23 @@ function(run_SubDir)
     set(SubDir_all [[SubDir\all]])
     set(SubDir_test [[SubDir\test]])
     set(SubDir_install [[SubDir\install]])
+    set(SubDirBinary_test [[SubDirBinary\test]])
+    set(SubDirBinary_all [[SubDirBinary\all]])
+    set(SubDirBinary_install [[SubDirBinary\install]])
   else()
     set(SubDir_all [[SubDir/all]])
     set(SubDir_test [[SubDir/test]])
     set(SubDir_install [[SubDir/install]])
+    set(SubDirBinary_all [[SubDirBinary/all]])
+    set(SubDirBinary_test [[SubDirBinary/test]])
+    set(SubDirBinary_install [[SubDirBinary/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})
+  run_cmake_command(SubDirBinary-build ${CMAKE_COMMAND} --build . --target ${SubDirBinary_all})
+  run_cmake_command(SubDirBinary-test ${CMAKE_COMMAND} --build . --target ${SubDirBinary_test})
+  run_cmake_command(SubDirBinary-install ${CMAKE_COMMAND} --build . --target ${SubDirBinary_install})
 endfunction()
 run_SubDir()
 
diff --git a/Tests/RunCMake/Ninja/SubDir.cmake b/Tests/RunCMake/Ninja/SubDir.cmake
index d227753..11f467a 100644
--- a/Tests/RunCMake/Ninja/SubDir.cmake
+++ b/Tests/RunCMake/Ninja/SubDir.cmake
@@ -1,5 +1,6 @@
 include(CTest)
 add_subdirectory(SubDir)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/SubDirSource SubDirBinary)
 add_custom_target(TopFail ALL COMMAND does_not_exist)
 add_test(NAME TopTest COMMAND ${CMAKE_COMMAND} -E echo "Running TopTest")
 install(CODE [[
diff --git a/Tests/RunCMake/Ninja/SubDirBinary-build-stdout.txt b/Tests/RunCMake/Ninja/SubDirBinary-build-stdout.txt
new file mode 100644
index 0000000..244eaa0
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirBinary-build-stdout.txt
@@ -0,0 +1 @@
+Building SubDirSourceInAll
diff --git a/Tests/RunCMake/Ninja/SubDirBinary-install-stdout.txt b/Tests/RunCMake/Ninja/SubDirBinary-install-stdout.txt
new file mode 100644
index 0000000..6b6c6dd
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirBinary-install-stdout.txt
@@ -0,0 +1 @@
+-- Installing SubDirSource
diff --git a/Tests/RunCMake/Ninja/SubDirBinary-test-stdout.txt b/Tests/RunCMake/Ninja/SubDirBinary-test-stdout.txt
new file mode 100644
index 0000000..d6d6605
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirBinary-test-stdout.txt
@@ -0,0 +1 @@
+1/1 Test #1: SubDirSourceTest
diff --git a/Tests/RunCMake/Ninja/SubDirSource/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDirSource/CMakeLists.txt
new file mode 100644
index 0000000..2664261
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirSource/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_custom_target(SubDirSourceFail COMMAND does_not_exist)
+add_custom_target(SubDirSourceInAll ALL COMMAND ${CMAKE_COMMAND} -E echo "Building SubDirSourceInAll")
+add_test(NAME SubDirSourceTest COMMAND ${CMAKE_COMMAND} -E echo "Running SubDirSourceTest")
+install(CODE [[
+  message(STATUS "Installing SubDirSource")
+]])

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

Summary of changes:
 Source/cmGlobalNinjaGenerator.cxx                  |   44 +++++++-------------
 Source/cmGlobalNinjaGenerator.h                    |    1 -
 Tests/RunCMake/Ninja/RunCMakeTest.cmake            |    9 ++++
 Tests/RunCMake/Ninja/SubDir.cmake                  |    1 +
 Tests/RunCMake/Ninja/SubDirBinary-build-stdout.txt |    1 +
 .../RunCMake/Ninja/SubDirBinary-install-stdout.txt |    1 +
 Tests/RunCMake/Ninja/SubDirBinary-test-stdout.txt  |    1 +
 Tests/RunCMake/Ninja/SubDirSource/CMakeLists.txt   |    6 +++
 8 files changed, 35 insertions(+), 29 deletions(-)
 create mode 100644 Tests/RunCMake/Ninja/SubDirBinary-build-stdout.txt
 create mode 100644 Tests/RunCMake/Ninja/SubDirBinary-install-stdout.txt
 create mode 100644 Tests/RunCMake/Ninja/SubDirBinary-test-stdout.txt
 create mode 100644 Tests/RunCMake/Ninja/SubDirSource/CMakeLists.txt


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list