[Cmake-commits] CMake branch, master, updated. v3.13.1-680-g0f7cca1

Kitware Robot kwrobot at kitware.com
Mon Dec 10 08:33:07 EST 2018


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, master has been updated
       via  0f7cca1dae77550487c2175de8ac2032b8582a55 (commit)
       via  2e2455cbd3ff429181d147374bbc3810acb98a97 (commit)
       via  d3983f7fc62eb35d08ab69ecdddff47953d86dab (commit)
       via  7630eb1975417ae49e00c58afcea71104a62ea55 (commit)
       via  dff28141dcddd90b0bb95740d66b8f698cc8da6a (commit)
       via  7b3d4799f8c03162d537e65effd3dd8d56fc3386 (commit)
       via  cfd808ff19bbd407dc230458e8a9369412244487 (commit)
       via  2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42 (commit)
       via  2295040e85321911d65bd36704560725d9c2ad27 (commit)
      from  45c5958e36cf55b00338b3f69cd48f43c51a03e0 (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=0f7cca1dae77550487c2175de8ac2032b8582a55
commit 0f7cca1dae77550487c2175de8ac2032b8582a55
Merge: 2e2455c 7630eb1
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Dec 10 13:25:56 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Dec 10 08:26:05 2018 -0500

    Merge topic 'autogen-cleanups'
    
    7630eb1975 cmQtAutoGenInitializer: Reduce code duplication
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Acked-by: Tobias Hunger <tobias.hunger at gmail.com>
    Merge-request: !2689


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2e2455cbd3ff429181d147374bbc3810acb98a97
commit 2e2455cbd3ff429181d147374bbc3810acb98a97
Merge: d3983f7 cfd808f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Dec 10 13:24:56 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Dec 10 08:25:03 2018 -0500

    Merge topic 'ninja-win-long-commands'
    
    cfd808ff19 cmLocalNinjaGenerator: Prevent echoing of lines in ninja generated batch files
    2c3f2dfa5a cmLocalNinjaGenerator: Report line of failure in ninja generated batch file
    2295040e85 cmLocalNinjaGenerator: Propagate failures from batch file back to ninja
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2701


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d3983f7fc62eb35d08ab69ecdddff47953d86dab
commit d3983f7fc62eb35d08ab69ecdddff47953d86dab
Merge: 45c5958 dff2814
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Dec 10 13:23:34 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon Dec 10 08:23:42 2018 -0500

    Merge topic 'SWIG'
    
    dff28141dc UseSWIG: add management of SWIG option -module
    7b3d4799f8 Help: update policy 0078 documentation
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2669


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7630eb1975417ae49e00c58afcea71104a62ea55
commit 7630eb1975417ae49e00c58afcea71104a62ea55
Author:     Tobias Hunger <tobias.hunger at qt.io>
AuthorDate: Wed Nov 28 15:04:33 2018 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Dec 7 13:44:33 2018 -0500

    cmQtAutoGenInitializer: Reduce code duplication
    
    Do not repeat the code used to find uic/rcc and moc exectuables.

diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index d4819a3..32e4a4f 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -35,9 +35,22 @@
 #include <set>
 #include <sstream>
 #include <string>
+#include <type_traits>
 #include <utility>
 #include <vector>
 
+std::string GetQtExecutableTargetName(
+  const cmQtAutoGen::IntegerVersion& qtVersion, std::string const& executable)
+{
+  if (qtVersion.Major == 5) {
+    return ("Qt5::" + executable);
+  }
+  if (qtVersion.Major == 4) {
+    return ("Qt4::" + executable);
+  }
+  return ("");
+}
+
 static std::size_t GetParallelCPUCount()
 {
   static std::size_t count = 0;
@@ -544,11 +557,7 @@ bool cmQtAutoGenInitializer::InitMoc()
   }
 
   // Moc executable
-  if (!GetMocExecutable()) {
-    return false;
-  }
-
-  return true;
+  return GetMocExecutable();
 }
 
 bool cmQtAutoGenInitializer::InitUic()
@@ -625,19 +634,12 @@ bool cmQtAutoGenInitializer::InitUic()
   }
 
   // Uic executable
-  if (!GetUicExecutable()) {
-    return false;
-  }
-
-  return true;
+  return GetUicExecutable();
 }
 
 bool cmQtAutoGenInitializer::InitRcc()
 {
-  if (!GetRccExecutable()) {
-    return false;
-  }
-  return true;
+  return GetRccExecutable();
 }
 
 bool cmQtAutoGenInitializer::InitScanFiles()
@@ -1409,199 +1411,109 @@ cmQtAutoGenInitializer::IntegerVersion cmQtAutoGenInitializer::GetQtVersion(
   return cmQtAutoGenInitializer::IntegerVersion();
 }
 
-bool cmQtAutoGenInitializer::GetMocExecutable()
+std::pair<bool, std::string> GetQtExecutable(
+  const cmQtAutoGen::IntegerVersion& qtVersion, cmGeneratorTarget* target,
+  const std::string& executable, bool ignoreMissingTarget, std::string* output)
 {
   std::string err;
+  std::string result;
 
-  // Find moc executable
+  // Find executable
   {
-    std::string targetName;
-    if (this->QtVersion.Major == 5) {
-      targetName = "Qt5::moc";
-    } else if (this->QtVersion.Major == 4) {
-      targetName = "Qt4::moc";
+    const std::string targetName =
+      GetQtExecutableTargetName(qtVersion, executable);
+    if (targetName.empty()) {
+      err = "The AUTOMOC, AUTOUIC and AUTORCC feature ";
+      err += "supports only Qt 4 and Qt 5";
     } else {
-      err = "The AUTOMOC feature supports only Qt 4 and Qt 5";
-    }
-    if (!targetName.empty()) {
-      cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
+      cmLocalGenerator* localGen = target->GetLocalGenerator();
       cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
       if (tgt != nullptr) {
-        this->Moc.Executable = tgt->ImportedGetLocation("");
+        result = tgt->ImportedGetLocation("");
       } else {
+        if (ignoreMissingTarget) {
+          return std::make_pair(true, "");
+        }
+
         err = "Could not find target " + targetName;
       }
     }
   }
 
-  // Test moc command
+  // Test executable
   if (err.empty()) {
-    if (cmSystemTools::FileExists(this->Moc.Executable, true)) {
+    if (cmSystemTools::FileExists(result, true)) {
       std::vector<std::string> command;
-      command.push_back(this->Moc.Executable);
+      command.push_back(result);
       command.push_back("-h");
       std::string stdOut;
       std::string stdErr;
       int retVal = 0;
-      bool result = cmSystemTools::RunSingleCommand(
+      const bool runResult = cmSystemTools::RunSingleCommand(
         command, &stdOut, &stdErr, &retVal, nullptr,
         cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
-      if (!result) {
-        err = "The moc test command failed: ";
-        err += QuotedCommand(command);
+      if (!runResult) {
+        err = "Test of \"" + executable + "\" binary ";
+        err += cmQtAutoGen::Quoted(result) + " failed: ";
+        err += cmQtAutoGen::QuotedCommand(command);
+      } else {
+        if (output != nullptr) {
+          *output = stdOut;
+        }
       }
     } else {
-      err = "The moc executable ";
-      err += Quoted(this->Moc.Executable);
+      err = "The \"" + executable + "\" binary ";
+      err += cmQtAutoGen::Quoted(result);
       err += " does not exist";
     }
   }
 
   // Print error
   if (!err.empty()) {
-    std::string msg = "AutoMoc (";
-    msg += this->Target->GetName();
+    std::string msg = "AutoGen (";
+    msg += target->GetName();
     msg += "): ";
     msg += err;
     cmSystemTools::Error(msg.c_str());
-    return false;
+    return std::make_pair(false, "");
   }
 
-  return true;
+  return std::make_pair(true, result);
 }
 
-bool cmQtAutoGenInitializer::GetUicExecutable()
+bool cmQtAutoGenInitializer::GetMocExecutable()
 {
-  std::string err;
-
-  // Find uic executable
-  {
-    std::string targetName;
-    if (this->QtVersion.Major == 5) {
-      targetName = "Qt5::uic";
-    } else if (this->QtVersion.Major == 4) {
-      targetName = "Qt4::uic";
-    } else {
-      err = "The AUTOUIC feature supports only Qt 4 and Qt 5";
-    }
-    if (!targetName.empty()) {
-      cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
-      cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
-      if (tgt != nullptr) {
-        this->Uic.Executable = tgt->ImportedGetLocation("");
-      } else {
-        if (this->QtVersion.Major == 5) {
-          // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
-        } else {
-          err = "Could not find target " + targetName;
-        }
-      }
-    }
-  }
-
-  // Test uic command
-  if (err.empty() && !this->Uic.Executable.empty()) {
-    if (cmSystemTools::FileExists(this->Uic.Executable, true)) {
-      std::vector<std::string> command;
-      command.push_back(this->Uic.Executable);
-      command.push_back("-h");
-      std::string stdOut;
-      std::string stdErr;
-      int retVal = 0;
-      bool result = cmSystemTools::RunSingleCommand(
-        command, &stdOut, &stdErr, &retVal, nullptr,
-        cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
-      if (!result) {
-        err = "The uic test command failed: ";
-        err += QuotedCommand(command);
-      }
-    } else {
-      err = "The uic executable ";
-      err += Quoted(this->Uic.Executable);
-      err += " does not exist";
-    }
-  }
-
-  // Print error
-  if (!err.empty()) {
-    std::string msg = "AutoUic (";
-    msg += this->Target->GetName();
-    msg += "): ";
-    msg += err;
-    cmSystemTools::Error(msg.c_str());
-    return false;
-  }
+  const auto result =
+    GetQtExecutable(this->QtVersion, this->Target, "moc", false, nullptr);
+  this->Moc.Executable = result.second;
+  return result.first;
+}
 
-  return true;
+bool cmQtAutoGenInitializer::GetUicExecutable()
+{
+  const auto result =
+    GetQtExecutable(this->QtVersion, this->Target, "uic", true, nullptr);
+  this->Uic.Executable = result.second;
+  return result.first;
 }
 
 bool cmQtAutoGenInitializer::GetRccExecutable()
 {
-  std::string err;
-
-  // Find rcc executable
-  {
-    std::string targetName;
-    if (this->QtVersion.Major == 5) {
-      targetName = "Qt5::rcc";
-    } else if (this->QtVersion.Major == 4) {
-      targetName = "Qt4::rcc";
-    } else {
-      err = "The AUTORCC feature supports only Qt 4 and Qt 5";
-    }
-    if (!targetName.empty()) {
-      cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
-      cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
-      if (tgt != nullptr) {
-        this->Rcc.Executable = tgt->ImportedGetLocation("");
-      } else {
-        err = "Could not find target " + targetName;
-      }
-    }
+  std::string stdOut;
+  const auto result =
+    GetQtExecutable(this->QtVersion, this->Target, "rcc", false, &stdOut);
+  this->Rcc.Executable = result.second;
+  if (!result.first) {
+    return false;
   }
 
-  // Test rcc command
-  if (err.empty()) {
-    if (cmSystemTools::FileExists(this->Rcc.Executable, true)) {
-      std::vector<std::string> command;
-      command.push_back(this->Rcc.Executable);
-      command.push_back("-h");
-      std::string stdOut;
-      std::string stdErr;
-      int retVal = 0;
-      bool result = cmSystemTools::RunSingleCommand(
-        command, &stdOut, &stdErr, &retVal, nullptr,
-        cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
-      if (result) {
-        // Detect if rcc supports (-)-list
-        if (this->QtVersion.Major == 5) {
-          if (stdOut.find("--list") != std::string::npos) {
-            this->Rcc.ListOptions.push_back("--list");
-          } else {
-            this->Rcc.ListOptions.push_back("-list");
-          }
-        }
-      } else {
-        err = "The rcc test command failed: ";
-        err += QuotedCommand(command);
-      }
+  if (this->QtVersion.Major == 5) {
+    if (stdOut.find("--list") != std::string::npos) {
+      this->Rcc.ListOptions.push_back("--list");
     } else {
-      err = "The rcc executable ";
-      err += Quoted(this->Rcc.Executable);
-      err += " does not exist";
+      this->Rcc.ListOptions.push_back("-list");
     }
   }
-
-  // Print error
-  if (!err.empty()) {
-    std::string msg = "AutoRcc (";
-    msg += this->Target->GetName();
-    msg += "): ";
-    msg += err;
-    cmSystemTools::Error(msg.c_str());
-    return false;
-  }
-
   return true;
 }
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dff28141dcddd90b0bb95740d66b8f698cc8da6a
commit dff28141dcddd90b0bb95740d66b8f698cc8da6a
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Tue Nov 27 15:10:32 2018 +0100
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Fri Dec 7 18:51:57 2018 +0100

    UseSWIG: add management of SWIG option -module
    
    When file property SWIG_MODULE_NAME is specified, provide option -module
    to SWIG compiler.
    
    Fixes: #18374

diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 044a06e..ed61ae0 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.14
 .. toctree::
    :maxdepth: 1
 
+   CMP0086: UseSWIG honors SWIG_MODULE_NAME via -module flag. </policy/CMP0086>
    CMP0085: IN_LIST generator expression handles empty list items. </policy/CMP0085>
    CMP0084: The FindQt module does not exist for find_package(). </policy/CMP0084>
    CMP0083: Add PIE options when linking executable. </policy/CMP0083>
diff --git a/Help/policy/CMP0086.rst b/Help/policy/CMP0086.rst
new file mode 100644
index 0000000..4a9e8b8
--- /dev/null
+++ b/Help/policy/CMP0086.rst
@@ -0,0 +1,20 @@
+CMP0086
+-------
+
+:module:`UseSWIG` honors ``SWIG_MODULE_NAME`` via ``-module`` flag.
+
+Starting with CMake 3.14, :module:`UseSWIG` passes option
+``-module <module_name>`` to ``SWIG`` compiler if the file property
+``SWIG_MODULE_NAME`` is specified. This policy provides compatibility with
+projects that expect the legacy behavior.
+
+The ``OLD`` behavior for this policy is to never pass ``-module`` option.
+The ``NEW`` behavior is to pass ``-module`` option to ``SWIG`` compiler if
+``SWIG_MODULE_NAME`` is specified.
+
+This policy was introduced in CMake version 3.14.  CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/release/dev/UseSWIG-CMP0086.rst b/Help/release/dev/UseSWIG-CMP0086.rst
new file mode 100644
index 0000000..d6fd0d1
--- /dev/null
+++ b/Help/release/dev/UseSWIG-CMP0086.rst
@@ -0,0 +1,6 @@
+UseSWIG-CMP0086
+---------------
+
+* The :module:`UseSWIG` module passes option ``-module <module_name>`` to
+  ``SWIG`` compiler if the file property ``SWIG_MODULE_NAME`` is defined.
+  See policy :policy:`CMP0086`.
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index d9a0389..a3d6d9e 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -142,6 +142,11 @@ ensure generated files will receive the required settings.
 
     set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
 
+  .. note::
+
+    If policy :policy:`CMP0086` is set to ``NEW``, ``-module <module_name>``
+    is passed to ``SWIG`` compiler.
+
 Target library properties can be set to apply same configuration to all SWIG
 input files.
 
@@ -220,12 +225,19 @@ as well as ``SWIG``:
 #]=======================================================================]
 
 cmake_policy(GET CMP0078 target_name_policy)
+cmake_policy(GET CMP0086 module_name_policy)
+
 cmake_policy (VERSION 3.12)
 if (target_name_policy)
   # respect user choice regarding CMP0078 policy
   cmake_policy(SET CMP0078 ${target_name_policy})
 endif()
+if (module_name_policy)
+  # respect user choice regarding CMP0086 policy
+  cmake_policy(SET CMP0086 ${module_name_policy})
+endif()
 unset(target_name_policy)
+unset(module_name_policy)
 
 set(SWIG_CXX_EXTENSION "cxx")
 set(SWIG_EXTRA_LIBRARIES "")
@@ -426,6 +438,19 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
     list (APPEND swig_special_flags "-c++")
   endif()
 
+  cmake_policy(GET CMP0086 module_name_policy)
+  if (module_name_policy STREQUAL "NEW")
+    get_source_file_property(module_name "${infile}" SWIG_MODULE_NAME)
+    if (module_name)
+      list (APPEND swig_special_flags "-module" "${module_name}")
+    endif()
+  else()
+    if (NOT module_name_policy)
+      cmake_policy(GET_WARNING CMP0086 _cmp0086_warning)
+      message(AUTHOR_WARNING "${_cmp0086_warning}\n")
+    endif()
+  endif()
+
   set (swig_extra_flags)
   if(SWIG_MODULE_${name}_LANGUAGE STREQUAL "CSHARP")
     if(NOT ("-dllimport" IN_LIST swig_source_file_flags OR "-dllimport" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS))
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 9985d63..7674877 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -251,7 +251,10 @@ class cmMakefile;
          "The FindQt module does not exist for find_package().", 3, 14, 0,    \
          cmPolicies::WARN)                                                    \
   SELECT(POLICY, CMP0085, "$<IN_LIST:...> handles empty list items.", 3, 14,  \
-         0, cmPolicies::WARN)
+         0, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0086,                                                     \
+         "UseSWIG honors SWIG_MODULE_NAME via -module flag.", 3, 14, 0,       \
+         cmPolicies::WARN)
 
 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
 #define CM_FOR_EACH_POLICY_ID(POLICY)                                         \
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index b044757..5ff2538 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -159,7 +159,7 @@ add_RunCMake_test(FindBoost)
 add_RunCMake_test(FindLua)
 add_RunCMake_test(FindOpenGL)
 if(CMake_TEST_UseSWIG)
-  add_RunCMake_test(UseSWIG)
+  add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython})
 endif()
 if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom")
   add_RunCMake_test(GenerateExportHeader)
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt
index f0ed577..d89d174 100644
--- a/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt
+++ b/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt
@@ -4,7 +4,7 @@ CMake Warning \(dev\) at .*/Modules/UseSWIG\.cmake:[0-9]+ \(message\):
   command to set the policy and suppress this warning\.
 
 Call Stack \(most recent call first\):
-  CMP0078-common\.cmake:6 \(swig_add_library\)
+  CMP0078-common\.cmake:8 \(swig_add_library\)
   CMP0078-WARN\.cmake:1 \(include\)
   CMakeLists\.txt:3 \(include\)
 This warning is for project developers.  Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-common.cmake b/Tests/RunCMake/UseSWIG/CMP0078-common.cmake
index 6cf39dc..b13796b 100644
--- a/Tests/RunCMake/UseSWIG/CMP0078-common.cmake
+++ b/Tests/RunCMake/UseSWIG/CMP0078-common.cmake
@@ -1,4 +1,6 @@
 
+cmake_policy(SET CMP0086 NEW)
+
 set(SWIG_EXECUTABLE "swig")
 set(SWIG_DIR "/swig")
 include(UseSWIG)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake b/Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake
new file mode 100644
index 0000000..ea8b2cd
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/new_example.py")
+  set (RunCMake_TEST_FAILED "Not found expected file: '${RunCMake_TEST_BINARY_DIR}/new_example.py'.")
+endif()
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake b/Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake
new file mode 100644
index 0000000..b54338d
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0086 NEW)
+include(CMP0086-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake b/Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake
new file mode 100644
index 0000000..96b5295
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/example.py")
+  set (RunCMake_TEST_FAILED "Not found expected file: '${RunCMake_TEST_BINARY_DIR}/example.py'.")
+endif()
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake b/Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake
new file mode 100644
index 0000000..6a63d4c
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0086 OLD)
+include(CMP0086-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt
new file mode 100644
index 0000000..af41021
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt
@@ -0,0 +1,11 @@
+CMake Warning \(dev\) at .*/Modules/UseSWIG.cmake:[0-9]+ \(message\):
+  Policy CMP0086 is not set: UseSWIG honors SWIG_MODULE_NAME via -module
+  flag.  Run "cmake --help-policy CMP0086" for policy details\.  Use the
+  cmake_policy command to set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+  .*/Modules/UseSWIG.cmake:[0-9]+ \(SWIG_ADD_SOURCE_TO_MODULE\)
+  CMP0086-common\.cmake:[0-9]+ \(swig_add_library\)
+  CMP0086-WARN\.cmake:1 \(include\)
+  CMakeLists\.txt:3 \(include\)
+This warning is for project developers\.  Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake b/Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake
new file mode 100644
index 0000000..69c2d9d
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0086-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-common.cmake b/Tests/RunCMake/UseSWIG/CMP0086-common.cmake
new file mode 100644
index 0000000..c02592a
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-common.cmake
@@ -0,0 +1,11 @@
+
+cmake_policy(SET CMP0078 NEW)
+
+find_package(Python REQUIRED COMPONENTS Development)
+find_package (SWIG REQUIRED)
+include(UseSWIG)
+
+set_property (SOURCE example.i PROPERTY SWIG_MODULE_NAME "new_example")
+
+swig_add_library(example LANGUAGE python TYPE MODULE SOURCES example.i)
+target_link_libraries(example PRIVATE Python::Python)
diff --git a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake
index b96622a..6acf719 100644
--- a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake
+++ b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake
@@ -3,3 +3,23 @@ include(RunCMake)
 run_cmake(CMP0078-WARN)
 run_cmake(CMP0078-OLD)
 run_cmake(CMP0078-NEW)
+
+run_cmake(CMP0086-WARN)
+
+if (CMake_TEST_FindPython)
+
+  macro(run_cmake_target test subtest target)
+    set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+    set(RunCMake_TEST_NO_CLEAN 1)
+    run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})
+
+    unset(RunCMake_TEST_BINARY_DIR)
+    unset(RunCMake_TEST_NO_CLEAN)
+  endmacro()
+
+  run_cmake(CMP0086-OLD)
+  run_cmake_target(CMP0086-OLD build example)
+  run_cmake(CMP0086-NEW)
+  run_cmake_target(CMP0086-NEW build example)
+
+endif()
diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt
index 4c3d901..f79cda6 100644
--- a/Tests/UseSWIG/CMakeLists.txt
+++ b/Tests/UseSWIG/CMakeLists.txt
@@ -96,6 +96,18 @@ add_test(NAME UseSWIG.UseTargetINCLUDE_DIRECTORIES COMMAND
   "${CMake_SOURCE_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES"
   "${CMake_BINARY_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES"
   ${build_generator_args}
-  --build-project TestModuleVersion2
+  --build-project TestUseTargetINCLUDE_DIRECTORIES
   --build-options ${build_options}
   )
+
+
+add_test(NAME UseSWIG.ModuleName COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleName"
+  "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleName"
+  ${build_generator_args}
+  --build-project TestModuleName
+  --build-options ${build_options}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/UseSWIG/ModuleName/CMakeLists.txt b/Tests/UseSWIG/ModuleName/CMakeLists.txt
new file mode 100644
index 0000000..de63883
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.1...3.14)
+
+project(TestModuleName CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+cmake_policy(SET CMP0086 NEW)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+
+# Path separator
+if (WIN32)
+  set (PS "$<SEMICOLON>")
+else()
+  set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall)
+set_property(SOURCE "example.i" PROPERTY SWIG_MODULE_NAME new_example)
+
+swig_add_library(example1
+                 LANGUAGE python
+                 OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1"
+                 SOURCES example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+  INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+  SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
+  OUTPUT_NAME new_example
+  LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+  ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+  RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1")
+target_link_libraries(example1 PRIVATE Python2::Python)
+
+
+add_test (NAME ModuleName.example1
+  COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>"
+  "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py")
diff --git a/Tests/UseSWIG/ModuleName/example.i b/Tests/UseSWIG/ModuleName/example.i
new file mode 100644
index 0000000..fbdf724
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/UseSWIG/ModuleName/runme.py b/Tests/UseSWIG/ModuleName/runme.py
new file mode 100644
index 0000000..c37e4a7
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/runme.py
@@ -0,0 +1,52 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+from __future__ import print_function
+
+import new_example
+
+# ----- Object creation -----
+
+print ("Creating some objects:")
+c = new_example.Circle(10)
+print ("    Created circle", c)
+s = new_example.Square(10)
+print ("    Created square", s)
+
+# ----- Access a static member -----
+
+print ("\nA total of", new_example.cvar.Shape_nshapes,"shapes were created")
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print ("\nHere is their current position:")
+print ("    Circle = (%f, %f)" % (c.x,c.y))
+print ("    Square = (%f, %f)" % (s.x,s.y))
+
+# ----- Call some methods -----
+
+print ("\nHere are some properties of the shapes:")
+for o in [c,s]:
+      print ("   ", o)
+      print ("        area      = ", o.area())
+      print ("        perimeter = ", o.perimeter())
+
+print ("\nGuess I'll clean up now")
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print (new_example.cvar.Shape_nshapes,"shapes remain")
+print ("Goodbye")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b3d4799f8c03162d537e65effd3dd8d56fc3386
commit 7b3d4799f8c03162d537e65effd3dd8d56fc3386
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Wed Nov 28 11:45:09 2018 +0100
Commit:     Marc Chevrier <marc.chevrier at gmail.com>
CommitDate: Fri Dec 7 10:56:37 2018 +0100

    Help: update policy 0078 documentation

diff --git a/Help/policy/CMP0078.rst b/Help/policy/CMP0078.rst
index 54cdc9c..2e97934 100644
--- a/Help/policy/CMP0078.rst
+++ b/Help/policy/CMP0078.rst
@@ -1,6 +1,8 @@
 CMP0078
 -------
 
+:module:`UseSWIG` generates standard target names.
+
 Starting with CMake 3.13, :module:`UseSWIG` generates now standard target
 names. This policy provides compatibility with projects that expect the legacy
 behavior.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cfd808ff19bbd407dc230458e8a9369412244487
commit cfd808ff19bbd407dc230458e8a9369412244487
Author:     Mark O'Neill <moneill at cayan.com>
AuthorDate: Tue Dec 4 12:37:06 2018 +0000
Commit:     Mark O'Neill <moneill at cayan.com>
CommitDate: Thu Dec 6 16:53:07 2018 +0000

    cmLocalNinjaGenerator: Prevent echoing of lines in ninja generated batch files

diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index c88432b..a8647b1 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -319,6 +319,7 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
   cmsys::ofstream script(scriptPath.c_str());
 
 #ifdef _WIN32
+  script << "@echo off\n";
   int line = 1;
 #else
   script << "set -e\n\n";

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42
commit 2c3f2dfa5a6cdb272ce63aa4d8bba842e0134f42
Author:     Mark O'Neill <moneill at cayan.com>
AuthorDate: Tue Dec 4 12:35:35 2018 +0000
Commit:     Mark O'Neill <moneill at cayan.com>
CommitDate: Thu Dec 6 16:53:06 2018 +0000

    cmLocalNinjaGenerator: Report line of failure in ninja generated batch file
    
    Fixes: 18676

diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index ecea4ea..c88432b 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -318,7 +318,9 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
 
   cmsys::ofstream script(scriptPath.c_str());
 
-#ifndef _WIN32
+#ifdef _WIN32
+  int line = 1;
+#else
   script << "set -e\n\n";
 #endif
 
@@ -329,12 +331,22 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
     // for the raw shell script.
     cmSystemTools::ReplaceString(cmd, "$$", "$");
 #ifdef _WIN32
-    script << cmd << " || exit /b 1" << '\n';
+    script << cmd << " || (set FAIL_LINE=" << ++line << "& goto :ABORT)"
+           << '\n';
 #else
     script << cmd << '\n';
 #endif
   }
 
+#ifdef _WIN32
+  script << "goto :EOF\n\n"
+            ":ABORT\n"
+            "set ERROR_CODE=%ERRORLEVEL%\n"
+            "echo Batch file failed at line %FAIL_LINE% "
+            "with errorcode %ERRORLEVEL%\n"
+            "exit /b %ERROR_CODE%";
+#endif
+
   return scriptPath;
 }
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2295040e85321911d65bd36704560725d9c2ad27
commit 2295040e85321911d65bd36704560725d9c2ad27
Author:     Mark O'Neill <moneill at cayan.com>
AuthorDate: Tue Dec 4 12:21:42 2018 +0000
Commit:     Mark O'Neill <moneill at cayan.com>
CommitDate: Thu Dec 6 16:01:24 2018 +0000

    cmLocalNinjaGenerator: Propagate failures from batch file back to ninja
    
    Fixes: #18676

diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 8a07516..ecea4ea 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -329,7 +329,7 @@ std::string cmLocalNinjaGenerator::WriteCommandScript(
     // for the raw shell script.
     cmSystemTools::ReplaceString(cmd, "$$", "$");
 #ifdef _WIN32
-    script << cmd << " || exit /b" << '\n';
+    script << cmd << " || exit /b 1" << '\n';
 #else
     script << cmd << '\n';
 #endif

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

Summary of changes:
 Help/manual/cmake-policies.7.rst                   |   1 +
 Help/policy/CMP0078.rst                            |   2 +
 Help/policy/CMP0086.rst                            |  20 ++
 Help/release/dev/UseSWIG-CMP0086.rst               |   6 +
 Modules/UseSWIG.cmake                              |  25 +++
 Source/cmLocalNinjaGenerator.cxx                   |  17 +-
 Source/cmPolicies.h                                |   5 +-
 Source/cmQtAutoGenInitializer.cxx                  | 232 +++++++--------------
 Tests/RunCMake/CMakeLists.txt                      |   2 +-
 Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt     |   2 +-
 Tests/RunCMake/UseSWIG/CMP0078-common.cmake        |   2 +
 .../RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake |   4 +
 Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake           |   2 +
 .../RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake |   4 +
 Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake           |   2 +
 Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt     |  11 +
 Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake          |   1 +
 Tests/RunCMake/UseSWIG/CMP0086-common.cmake        |  11 +
 Tests/RunCMake/UseSWIG/RunCMakeTest.cmake          |  20 ++
 Tests/UseSWIG/CMakeLists.txt                       |  14 +-
 Tests/UseSWIG/ModuleName/CMakeLists.txt            |  42 ++++
 Tests/UseSWIG/{ => ModuleName}/example.i           |   0
 Tests/UseSWIG/{ => ModuleName}/runme.py            |  10 +-
 23 files changed, 264 insertions(+), 171 deletions(-)
 create mode 100644 Help/policy/CMP0086.rst
 create mode 100644 Help/release/dev/UseSWIG-CMP0086.rst
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake
 create mode 100644 Tests/RunCMake/UseSWIG/CMP0086-common.cmake
 create mode 100644 Tests/UseSWIG/ModuleName/CMakeLists.txt
 copy Tests/UseSWIG/{ => ModuleName}/example.i (100%)
 copy Tests/UseSWIG/{ => ModuleName}/runme.py (81%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list