Merge topic 'update-kwsys'

05e3abafa5 Merge branch 'upstream-KWSys' into update-kwsys
82fd685043 KWSys 2020-08-05 (185dd56e)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5104
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index ed8447e..52536bb 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -144,7 +144,12 @@
   References a library file located outside the project.  The
   :prop_tgt:`IMPORTED_LOCATION` target property (or its per-configuration
   variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) specifies the
-  location of the main library file on disk.
+  location of the main library file on disk.  In the case of a ``SHARED``
+  library on Windows, the :prop_tgt:`IMPORTED_IMPLIB` target property
+  (or its per-configuration variant :prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`)
+  specifies the location of the DLL import library file (``.lib`` or
+  ``.dll.a``) on disk, and the ``IMPORTED_LOCATION`` is the location of
+  the ``.dll`` runtime library (and is optional).
   Additional usage requirements may be specified in ``INTERFACE_*`` properties.
 
   An ``UNKNOWN`` library type is typically only used in the implementation of
diff --git a/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst b/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst
index b923800..c9301b5 100644
--- a/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst
+++ b/Help/prop_tgt/CUDA_STANDARD_REQUIRED.rst
@@ -10,7 +10,7 @@
 property is ``OFF`` or unset, the :prop_tgt:`CUDA_STANDARD` target property is
 treated as optional and may "decay" to a previous standard if the requested is
 not available.  For compilers that have no notion of a standard level, such as
-MSVC, this has no effect.
+MSVC 1800 (Visual Studio 2013) and lower, this has no effect.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst
index 2ea2215..8b17490 100644
--- a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst
+++ b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst
@@ -10,7 +10,7 @@
 property is ``OFF`` or unset, the :prop_tgt:`CXX_STANDARD` target property is
 treated as optional and may "decay" to a previous standard if the requested is
 not available.  For compilers that have no notion of a standard level, such as
-MSVC, this has no effect.
+MSVC 1800 (Visual Studio 2013) and lower, this has no effect.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Help/prop_tgt/C_STANDARD_REQUIRED.rst b/Help/prop_tgt/C_STANDARD_REQUIRED.rst
index c1b58a0..55bff04 100644
--- a/Help/prop_tgt/C_STANDARD_REQUIRED.rst
+++ b/Help/prop_tgt/C_STANDARD_REQUIRED.rst
@@ -10,7 +10,7 @@
 property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is
 treated as optional and may "decay" to a previous standard if the requested is
 not available.  For compilers that have no notion of a standard level, such as
-MSVC, this has no effect.
+MSVC 1800 (Visual Studio 2013) and lower, this has no effect.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index 5d098d9..883e1f4 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -44,8 +44,8 @@
   cmake_parse_arguments(
     ""
     ""
-    "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_EXECUTOR;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR"
-    "TEST_EXTRA_ARGS;TEST_PROPERTIES"
+    "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR"
+    "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR"
     ${ARGN}
   )
 
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 3a0d53d..091f97f 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 18)
-set(CMake_VERSION_PATCH 20200805)
+set(CMake_VERSION_PATCH 20200806)
 #set(CMake_VERSION_RC 0)
 set(CMake_VERSION_IS_DIRTY 0)
 
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 8e9abf8..570f4ea 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -125,14 +125,6 @@
 cmGraphVizWriter::~cmGraphVizWriter()
 {
   this->WriteFooter(this->GlobalFileStream);
-
-  for (auto& fileStream : this->PerTargetFileStreams) {
-    this->WriteFooter(*fileStream.second);
-  }
-
-  for (auto& fileStream : this->TargetDependersFileStreams) {
-    this->WriteFooter(*fileStream.second);
-  }
 }
 
 void cmGraphVizWriter::VisitGraph(std::string const&)
@@ -151,20 +143,10 @@
   ++NextNodeId;
 
   this->WriteNode(this->GlobalFileStream, item);
-
-  if (this->GeneratePerTarget) {
-    this->CreateTargetFile(this->PerTargetFileStreams, item);
-  }
-
-  if (this->GenerateDependers) {
-    this->CreateTargetFile(this->TargetDependersFileStreams, item,
-                           ".dependers");
-  }
 }
 
-void cmGraphVizWriter::CreateTargetFile(FileStreamMap& fileStreamMap,
-                                        cmLinkItem const& item,
-                                        std::string const& fileNameSuffix)
+std::unique_ptr<cmGeneratedFileStream> cmGraphVizWriter::CreateTargetFile(
+  cmLinkItem const& item, std::string const& fileNameSuffix)
 {
   auto const pathSafeItemName = PathSafeString(item.AsStr());
   auto const perTargetFileName =
@@ -175,7 +157,7 @@
   this->WriteHeader(*perTargetFileStream, item.AsStr());
   this->WriteNode(*perTargetFileStream, item);
 
-  fileStreamMap.emplace(item.AsStr(), std::move(perTargetFileStream));
+  return perTargetFileStream;
 }
 
 void cmGraphVizWriter::OnDirectLink(cmLinkItem const& depender,
@@ -323,13 +305,12 @@
   }
 
   if (this->GeneratePerTarget) {
-    WritePerTargetConnections<DependeesDir>(PerTargetConnections,
-                                            PerTargetFileStreams);
+    WritePerTargetConnections<DependeesDir>(PerTargetConnections);
   }
 
   if (this->GenerateDependers) {
     WritePerTargetConnections<DependersDir>(TargetDependersConnections,
-                                            TargetDependersFileStreams);
+                                            ".dependers");
   }
 }
 
@@ -368,7 +349,7 @@
 
 template <typename DirFunc>
 void cmGraphVizWriter::WritePerTargetConnections(
-  const ConnectionsMap& connections, const FileStreamMap& streams)
+  const ConnectionsMap& connections, const std::string& fileNameSuffix)
 {
   // the per target connections must be extended by indirect dependencies
   ConnectionsMap extendedConnections;
@@ -387,7 +368,9 @@
     }
 
     const Connections& cons = conPerTarget.second;
-    auto fileStream = streams.at(rootItem.AsStr()).get();
+
+    std::unique_ptr<cmGeneratedFileStream> fileStream =
+      this->CreateTargetFile(rootItem, fileNameSuffix);
 
     for (const Connection& con : cons) {
       const cmLinkItem& src = DirFunc::src(con);
@@ -395,6 +378,8 @@
       this->WriteNode(*fileStream, con.dst);
       this->WriteConnection(*fileStream, src, dst, con.scopeType);
     }
+
+    this->WriteFooter(*fileStream);
   }
 }
 
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index 9766068..d1300ac 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -46,9 +46,6 @@
   void Write();
 
 private:
-  using FileStreamMap =
-    std::map<std::string, std::unique_ptr<cmGeneratedFileStream>>;
-
   struct Connection
   {
     Connection(cmLinkItem s, cmLinkItem d, std::string scope)
@@ -76,8 +73,8 @@
 
   void WriteNode(cmGeneratedFileStream& fs, cmLinkItem const& item);
 
-  void CreateTargetFile(FileStreamMap& fileStreamMap, cmLinkItem const& target,
-                        std::string const& fileNameSuffix = "");
+  std::unique_ptr<cmGeneratedFileStream> CreateTargetFile(
+    cmLinkItem const& target, std::string const& fileNameSuffix = "");
 
   void WriteConnection(cmGeneratedFileStream& fs,
                        cmLinkItem const& dependerTargetName,
@@ -95,7 +92,7 @@
 
   template <typename DirFunc>
   void WritePerTargetConnections(const ConnectionsMap& connections,
-                                 const FileStreamMap& streams);
+                                 const std::string& fileNameSuffix = "");
 
   bool ItemExcluded(cmLinkItem const& item);
   bool ItemNameFilteredOut(std::string const& itemName);
@@ -111,8 +108,6 @@
 
   std::string FileName;
   cmGeneratedFileStream GlobalFileStream;
-  FileStreamMap PerTargetFileStreams;
-  FileStreamMap TargetDependersFileStreams;
 
   ConnectionsMap PerTargetConnections;
   ConnectionsMap TargetDependersConnections;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 4d39312..7e35fe7 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2613,7 +2613,7 @@
     }
     file << "      break()\n"
          << "    endif()\n";
-    file << "  else()\n"
+    file << "  elseif(NOT EXISTS \"" << from_file << "\")\n"
          << "    execute_process(COMMAND ${CMAKE_COMMAND}"
          << " -E sleep 1)\n"
          << "  endif()\n";
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 1775085..bde5ee7 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -733,12 +733,8 @@
     static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) -
     globalGen->GetRuleCmdLength(this->LanguageLinkerDeviceRule(config));
 
-  std::string path = localGen.GetHomeRelativeOutputPath();
-  if (!path.empty()) {
-    path += '/';
-  }
   build.RspFile = this->ConvertToNinjaPath(
-    cmStrCat(path, "CMakeFiles/", genTarget->GetName(),
+    cmStrCat("CMakeFiles/", genTarget->GetName(),
              globalGen->IsMultiConfig() ? cmStrCat('.', config) : "", ".rsp"));
 
   // Gather order-only dependencies.
@@ -1160,12 +1156,8 @@
       globalGen->GetRuleCmdLength(linkBuild.Rule);
   }
 
-  std::string path = localGen.GetHomeRelativeOutputPath();
-  if (!path.empty()) {
-    path += '/';
-  }
   linkBuild.RspFile = this->ConvertToNinjaPath(
-    cmStrCat(path, "CMakeFiles/", gt->GetName(),
+    cmStrCat("CMakeFiles/", gt->GetName(),
              globalGen->IsMultiConfig() ? cmStrCat('.', config) : "", ".rsp"));
 
   // Gather order-only dependencies.
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 205097d..06957b0 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1181,11 +1181,54 @@
     if (useNinjaDepfile) {
       // Create a custom command that generates a timestamp file and
       // has a depfile assigned. The depfile is created by JobDepFilesMergeT.
+      //
+      // Also create an additional '_autogen_timestamp_deps' that the custom
+      // command will depend on. It will have no sources or commands to
+      // execute, but it will have dependencies that would originally be
+      // assigned to the pre-Qt 5.15 'autogen' target. These dependencies will
+      // serve as a list of order-only dependencies for the custom command,
+      // without forcing the custom command to re-execute.
+      //
+      // The dependency tree would then look like
+      // '_autogen_timestamp_deps (order-only)' <- '/timestamp' file <-
+      // '_autogen' target.
+      const auto timestampTargetName =
+        cmStrCat(this->GenTarget->GetName(), "_autogen_timestamp_deps");
+      std::vector<std::string> timestampTargetProvides;
+      cmCustomCommandLines timestampTargetCommandLines;
 
-      // Add additional autogen target dependencies
+      // Add additional autogen target dependencies to
+      // '_autogen_timestamp_deps'.
       for (const cmTarget* t : this->AutogenTarget.DependTargets) {
         dependencies.push_back(t->GetName());
       }
+
+      cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand(
+        timestampTargetName, true, this->Dir.Work.c_str(),
+        /*byproducts=*/timestampTargetProvides,
+        /*depends=*/dependencies, timestampTargetCommandLines, false, nullptr);
+      this->LocalGen->AddGeneratorTarget(
+        cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen));
+
+      // Set FOLDER property on the timestamp target, so it appears in the
+      // appropriate folder in an IDE or in the file api.
+      if (!this->TargetsFolder.empty()) {
+        timestampTarget->SetProperty("FOLDER", this->TargetsFolder);
+      }
+
+      // Make '/timestamp' file depend on '_autogen_timestamp_deps' and on the
+      // moc and uic executables (whichever are enabled).
+      dependencies.clear();
+      dependencies.push_back(timestampTargetName);
+
+      if (this->Moc.ExecutableTarget != nullptr) {
+        dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName());
+      }
+      if (this->Uic.ExecutableTarget != nullptr) {
+        dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName());
+      }
+
+      // Create the custom command that outputs the timestamp file.
       const char timestampFileName[] = "timestamp";
       const std::string outputFile =
         cmStrCat(this->Dir.Build, "/", timestampFileName);
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 9adcabb..f6cccfb 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -2163,7 +2163,9 @@
 void cmQtAutoMocUicT::JobDepFilesMergeT::Process()
 {
   if (Log().Verbose()) {
-    Log().Info(GenT::MOC, "Merging MOC dependencies");
+    Log().Info(GenT::MOC,
+               cmStrCat("Merging MOC dependencies into ",
+                        MessagePath(BaseConst().DepFile.c_str())));
   }
   auto processDepFile =
     [](const std::string& mocOutputFile) -> std::vector<std::string> {
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 7c66c5c..4600fc5 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -71,7 +71,7 @@
   { "--open <dir>", "Open generated project in the associated application." },
   { "-N", "View mode only." },
   { "-P <file>", "Process script mode." },
-  { "--find-package", "Run in pkg-config like mode." },
+  { "--find-package", "Legacy pkg-config like mode.  Do not use." },
   { "--graphviz=[file]",
     "Generate graphviz of dependencies, see "
     "CMakeGraphVizOptions.cmake for more." },
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 4d2a53c..294e252 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -142,6 +142,9 @@
   if(CMAKE_Fortran_COMPILER)
     list(APPEND Ninja_ARGS -DTEST_Fortran=1)
   endif()
+  if(CMake_TEST_Qt5 AND Qt5Core_FOUND)
+    list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION})
+  endif()
   add_RunCMake_test(Ninja)
   set(NinjaMultiConfig_ARGS
     -DCYGWIN=${CYGWIN}
diff --git a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake
new file mode 100644
index 0000000..d69a119
--- /dev/null
+++ b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake
@@ -0,0 +1,9 @@
+enable_language(CXX)
+
+find_package(Qt5Core REQUIRED)
+
+set(CMAKE_AUTOMOC ON)
+
+add_library(simple_lib SHARED simple_lib.cpp)
+add_executable(app_with_qt app.cpp app_qt.cpp)
+target_link_libraries(app_with_qt PRIVATE simple_lib Qt5::Core)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 8f9c263..d43023b 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -138,6 +138,7 @@
     message(FATAL_ERROR
       "top ninja build failed exited with status ${ninja_result}")
   endif()
+  set(ninja_stdout "${ninja_stdout}" PARENT_SCOPE)
 endfunction(run_ninja)
 
 function (run_LooseObjectDepends)
@@ -322,3 +323,23 @@
   run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err)
 endfunction()
 run_ChangeBuildType()
+
+function(run_Qt5AutoMocDeps)
+  if(CMake_TEST_Qt5 AND CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0)
+    set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5AutoMocDeps-build)
+    run_cmake(Qt5AutoMocDeps)
+    unset(RunCMake_TEST_OPTIONS)
+    # Build the project.
+    run_ninja("${RunCMake_TEST_BINARY_DIR}")
+    # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC
+    # for app_with_qt target.
+    touch("${RunCMake_SOURCE_DIR}/simple_lib.cpp")
+    # Build and assert that AUTOMOC was not run for app_with_qt.
+    run_ninja("${RunCMake_TEST_BINARY_DIR}")
+    if(ninja_stdout MATCHES "Automatic MOC for target app_with_qt")
+        message(FATAL_ERROR
+               "AUTOMOC should not have executed for 'app_with_qt' target:\nstdout:\n${ninja_stdout}")
+    endif()
+  endif()
+endfunction()
+run_Qt5AutoMocDeps()
diff --git a/Tests/RunCMake/Ninja/app.cpp b/Tests/RunCMake/Ninja/app.cpp
new file mode 100644
index 0000000..57380e4
--- /dev/null
+++ b/Tests/RunCMake/Ninja/app.cpp
@@ -0,0 +1,6 @@
+int main(int argc, char* argv[])
+{
+  (void)argc;
+  (void)argv;
+  return 0;
+}
diff --git a/Tests/RunCMake/Ninja/app_qt.cpp b/Tests/RunCMake/Ninja/app_qt.cpp
new file mode 100644
index 0000000..302c672
--- /dev/null
+++ b/Tests/RunCMake/Ninja/app_qt.cpp
@@ -0,0 +1,11 @@
+#include <QObject>
+
+class Mango : public QObject
+{
+  Q_OBJECT
+public:
+Q_SIGNALS:
+  void eatFruit();
+};
+
+#include "app_qt.moc"
diff --git a/Tests/RunCMake/Ninja/simple_lib.cpp b/Tests/RunCMake/Ninja/simple_lib.cpp
new file mode 100644
index 0000000..cf8d689
--- /dev/null
+++ b/Tests/RunCMake/Ninja/simple_lib.cpp
@@ -0,0 +1,6 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+  void dummy_symbol()
+{
+}