Merge branch 'backport-FindLAPACK-typo' into release-3.13

Merge-request: !2897
diff --git a/Help/release/3.13.rst b/Help/release/3.13.rst
index 68e05c3..1c58550 100644
--- a/Help/release/3.13.rst
+++ b/Help/release/3.13.rst
@@ -252,3 +252,29 @@
   directories to the ``moc`` tool for :prop_tgt:`AUTOMOC`.  This has
   been reverted due to regressing existing builds and will need
   further investigation before being re-introduced in a later release.
+
+3.13.3
+------
+
+* The :generator:`Visual Studio 15 2017` generator has been fixed to work
+  when VS 2019 is installed.
+
+* CMake now checks that at least one of the source or binary directory
+  is specified when running CMake and issues an error if both are missing.
+  This has always been a documented requirement, but the implementation
+  previously accidentally accepted cases in which neither are specified
+  so long as some other argument is given, and silently used the current
+  working directory as the source and build tree.
+
+3.13.4
+------
+
+* The error added by 3.13.3 in cases that neither a source or binary
+  directory is specified has been downgraded to a warning.  While this
+  was never intended, documented, nor supported behavior, some projects
+  relied on it.  The error has been downgraded to a warning for the
+  remainder of the 3.13.x release series to allow a transition period,
+  but it may become a fatal error again in a later release.  Scripts
+  relying on the old behavior can be trivially fixed by specifying
+  the path to the source tree (even if just ``.``) explicitly and
+  continue to work with all versions of CMake.
diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
index 0df6c0f..aa35b97 100644
--- a/Modules/Compiler/Intel-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
@@ -24,7 +24,7 @@
 unset(DETECT_BUGGY_ICC15)
 
 set(Intel17_CXX14 "__INTEL_COMPILER >= 1700 && ${DETECT_CXX14}")
-set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && __INTEL_COMPILER != 1800 && !defined(_MSC_VER))")
+set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && !(__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 5) && !defined(_MSC_VER))")
 
 set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}")
 set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}")
diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake
index 2ed9449..cb4738b 100644
--- a/Modules/FindDoxygen.cmake
+++ b/Modules/FindDoxygen.cmake
@@ -708,7 +708,9 @@
         if(_line MATCHES "([A-Z][A-Z0-9_]+)( *=)(.*)")
             set(_key "${CMAKE_MATCH_1}")
             set(_eql "${CMAKE_MATCH_2}")
-            string(REPLACE ";" "\\\n" _value "${CMAKE_MATCH_3}")
+            set(_value "${CMAKE_MATCH_3}")
+            string(REPLACE "\\" "\\\\" _value "${_value}")
+            string(REPLACE ";" "\\\n" _value "${_value}")
             list(APPEND _Doxygen_tpl_params "${_key}${_eql}${_value}")
         endif()
     endforeach()
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 311f3f4..8aff8f6 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -791,9 +791,10 @@
   endif()
 endif()
 
-# On Apple we need CoreFoundation
+# On Apple we need CoreFoundation and CoreServices
 if(APPLE)
   target_link_libraries(CMakeLib "-framework CoreFoundation")
+  target_link_libraries(CMakeLib "-framework CoreServices")
 endif()
 
 if(WIN32 AND NOT UNIX)
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 1f76703..5d34b71 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2906,10 +2906,6 @@
   ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
   check_curl_result(res, "DOWNLOAD cannot set url: ");
 
-  // enable auth
-  res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
-  check_curl_result(res, "DOWNLOAD cannot set httpauth: ");
-
   // enable HTTP ERROR parsing
   res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
   check_curl_result(res, "DOWNLOAD cannot set http failure option: ");
@@ -3209,10 +3205,6 @@
   res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
   check_curl_result(res, "UPLOAD cannot set url: ");
 
-  // enable auth
-  res = ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
-  check_curl_result(res, "UPLOAD cannot set httpauth: ");
-
   res =
     ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToMemoryCallback);
   check_curl_result(res, "UPLOAD cannot set write function: ");
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 8b8f79b..bf0217a 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -210,8 +210,29 @@
       // An import library looks like a static library.
       type = cmInstallType_STATIC_LIBRARY;
     } else if (this->Target->IsFrameworkOnApple()) {
-      // There is a bug in cmInstallCommand if this fails.
-      assert(this->NamelinkMode == NamelinkModeNone);
+      // FIXME: In principle we should be able to
+      //   assert(this->NamelinkMode == NamelinkModeNone);
+      // but since the current install() command implementation checks
+      // the FRAMEWORK property immediately instead of delaying until
+      // generate time, it is possible for project code to set the
+      // property after calling install().  In such a case, the install()
+      // command will use the LIBRARY code path and create two install
+      // generators, one for the namelink component (NamelinkModeOnly)
+      // and one for the primary artifact component (NamelinkModeSkip).
+      // Historically this was not diagnosed and resulted in silent
+      // installation of a framework to the LIBRARY destination.
+      // Retain that behavior.
+      switch (this->NamelinkMode) {
+        case NamelinkModeNone:
+          // Normal case.
+          break;
+        case NamelinkModeOnly:
+          // Assume the NamelinkModeSkip instance will install.
+          return;
+        case NamelinkModeSkip: {
+          // Proceed to install in the LIBRARY destination for compatibility.
+        } break;
+      }
 
       // Install the whole framework directory.
       type = cmInstallType_DIRECTORY;
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index f9c8c7f..90111801 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1281,6 +1281,12 @@
   if (qtMajor.empty()) {
     qtMajor = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
   }
+  if (qtMajor.empty()) {
+    const char* dirprop = makefile->GetProperty("Qt5Core_VERSION_MAJOR");
+    if (dirprop) {
+      qtMajor = dirprop;
+    }
+  }
   {
     const char* targetQtVersion =
       target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "");
@@ -1294,6 +1300,12 @@
   if (!qtMajor.empty()) {
     if (qtMajor == "5") {
       qtMinor = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR");
+      if (qtMinor.empty()) {
+        const char* dirprop = makefile->GetProperty("Qt5Core_VERSION_MINOR");
+        if (dirprop) {
+          qtMinor = dirprop;
+        }
+      }
     }
     if (qtMinor.empty()) {
       qtMinor = makefile->GetSafeDefinition("QT_VERSION_MINOR");
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 74542df..d0863b0 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -808,8 +808,11 @@
 
   if (this->CurrentWorkingMode == cmake::NORMAL_MODE && !haveSourceDir &&
       !haveBinaryDir) {
-    cmSystemTools::Error("No source or binary directory provided");
-    return;
+    this->IssueMessage(
+      cmake::WARNING,
+      "No source or binary directory provided. Both will be assumed to be "
+      "the same as the current working directory, but note that this "
+      "warning will become a fatal error in future CMake releases.");
   }
 
   if (!haveSourceDir) {
diff --git a/Tests/RunCMake/Autogen/QtInFunction.cmake b/Tests/RunCMake/Autogen/QtInFunction.cmake
new file mode 100644
index 0000000..a44bc5a
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunction.cmake
@@ -0,0 +1,13 @@
+enable_language(CXX)
+
+function (use_autogen target)
+  find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
+  set(Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}" PARENT_SCOPE)
+  set(Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}" PARENT_SCOPE)
+  set_property(TARGET "${target}" PROPERTY AUTOMOC 1)
+  set_property(TARGET "${target}" PROPERTY AUTORCC 1)
+  set_property(TARGET "${target}" PROPERTY AUTOUIC 1)
+endfunction ()
+
+add_executable(main empty.cpp)
+use_autogen(main)
diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt b/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt
new file mode 100644
index 0000000..6b4a933
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+  AUTOGEN: No valid Qt version found for target main.  AUTOMOC, AUTOUIC,
+  AUTORCC disabled.  Consider adding:
+
+    find_package\(Qt5 COMPONENTS Widgets\)
+
+  to your CMakeLists.txt file.
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested.cmake b/Tests/RunCMake/Autogen/QtInFunctionNested.cmake
new file mode 100644
index 0000000..5421ba0
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunctionNested.cmake
@@ -0,0 +1,17 @@
+enable_language(CXX)
+
+function (use_autogen target)
+  find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
+  set(Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}" PARENT_SCOPE)
+  set(Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}" PARENT_SCOPE)
+  set_property(TARGET "${target}" PROPERTY AUTOMOC 1)
+  set_property(TARGET "${target}" PROPERTY AUTORCC 1)
+  set_property(TARGET "${target}" PROPERTY AUTOUIC 1)
+endfunction ()
+
+function (wrap_autogen target)
+  use_autogen("${target}")
+endfunction ()
+
+add_executable(main empty.cpp)
+wrap_autogen(main)
diff --git a/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake b/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake
new file mode 100644
index 0000000..35f1cd1
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake
@@ -0,0 +1,21 @@
+enable_language(CXX)
+
+function (use_autogen target)
+  find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
+  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    PROPERTY
+      Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}")
+  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    PROPERTY
+      Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}")
+  set_property(TARGET "${target}" PROPERTY AUTOMOC 1)
+  set_property(TARGET "${target}" PROPERTY AUTORCC 1)
+  set_property(TARGET "${target}" PROPERTY AUTOUIC 1)
+endfunction ()
+
+function (wrap_autogen target)
+  use_autogen("${target}")
+endfunction ()
+
+add_executable(main empty.cpp)
+wrap_autogen(main)
diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake
index e52f28d..a31b67c 100644
--- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake
@@ -1,3 +1,8 @@
 include(RunCMake)
 
 run_cmake(NoQt)
+if (with_qt5)
+  run_cmake(QtInFunction)
+  run_cmake(QtInFunctionNested)
+  run_cmake(QtInFunctionProperty)
+endif ()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 89102dd..27413dd 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -142,7 +142,14 @@
 endif()
 
 add_RunCMake_test(AndroidTestUtilities)
-add_RunCMake_test(Autogen)
+set(autogen_with_qt5 FALSE)
+if(CMake_TEST_Qt5)
+  find_package(Qt5Widgets QUIET NO_MODULE)
+endif()
+if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND)
+  set(autogen_with_qt5 TRUE)
+endif ()
+add_RunCMake_test(Autogen -Dwith_qt5=${autogen_with_qt5})
 add_RunCMake_test(BuildDepends)
 if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
   add_RunCMake_test(Byproducts)
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 32e20ac..3e56c25 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -54,12 +54,22 @@
   ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/)
 
 function(run_ExplicitDirs)
+  set(source_dir ${RunCMake_BINARY_DIR}/ExplicitDirsMissing)
+
+  file(REMOVE_RECURSE "${source_dir}")
+  file(MAKE_DIRECTORY "${source_dir}")
+  file(WRITE ${source_dir}/CMakeLists.txt [=[
+cmake_minimum_required(VERSION 3.13)
+project(ExplicitDirsMissing LANGUAGES NONE)
+]=])
+  run_cmake_command(no-S-B ${CMAKE_COMMAND} -E chdir ${source_dir}
+    ${CMAKE_COMMAND} -DFOO=BAR)
+
   set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs)
   set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build)
 
   file(REMOVE_RECURSE "${binary_dir}")
   file(MAKE_DIRECTORY "${binary_dir}")
-  run_cmake_command(no-S-B ${CMAKE_COMMAND} -DFOO=BAR)
   run_cmake_command(S-arg ${CMAKE_COMMAND} -S ${source_dir} ${binary_dir})
   run_cmake_command(S-arg-reverse-order ${CMAKE_COMMAND} ${binary_dir} -S${source_dir} )
   run_cmake_command(S-no-arg ${CMAKE_COMMAND} -S )
diff --git a/Tests/RunCMake/CommandLine/no-S-B-result.txt b/Tests/RunCMake/CommandLine/no-S-B-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/CommandLine/no-S-B-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/CommandLine/no-S-B-stderr.txt b/Tests/RunCMake/CommandLine/no-S-B-stderr.txt
index 7a94307..c166dcf 100644
--- a/Tests/RunCMake/CommandLine/no-S-B-stderr.txt
+++ b/Tests/RunCMake/CommandLine/no-S-B-stderr.txt
@@ -1 +1,4 @@
-CMake Error: No source or binary directory provided
+CMake Warning:
+  No source or binary directory provided.  Both will be assumed to be the
+  same as the current working directory, but note that this warning will
+  become a fatal error in future CMake releases.
diff --git a/Tests/RunCMake/Framework/InstallBeforeFramework.cmake b/Tests/RunCMake/Framework/InstallBeforeFramework.cmake
new file mode 100644
index 0000000..3791dac
--- /dev/null
+++ b/Tests/RunCMake/Framework/InstallBeforeFramework.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_library(foo SHARED foo.c)
+install(TARGETS foo LIBRARY DESTINATION lib)
+set_property(TARGET foo PROPERTY FRAMEWORK TRUE)
diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake
index 4fc83f8..e705a31 100644
--- a/Tests/RunCMake/Framework/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake
@@ -1,5 +1,7 @@
 include(RunCMake)
 
+run_cmake(InstallBeforeFramework)
+
 function(framework_layout_test Name Toolchain Type)
   set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkLayout-build)
   set(RunCMake_TEST_NO_CLEAN 1)