Merge branch 'export-android-mk' into release-3.11

Merge-request: !1766
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
deleted file mode 100644
index e4cc01e..0000000
--- a/Help/release/dev/0-sample-topic.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-0-sample-topic
---------------
-
-* This is a sample release note for the change in a topic.
-  Developers should add similar notes for each topic branch
-  making a noteworthy change.  Each document should be named
-  and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 552922e..7375faf 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -7,8 +7,6 @@
   This file should include the adjacent "dev.txt" file
   in development versions but not in release versions.
 
-.. include:: dev.txt
-
 Releases
 ========
 
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index c16bbf2..881bff1 100644
--- a/Modules/FindImageMagick.cmake
+++ b/Modules/FindImageMagick.cmake
@@ -206,7 +206,7 @@
     list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_Magick++_LIBRARY)
   elseif(component STREQUAL "MagickWand")
     FIND_IMAGEMAGICK_API(MagickWand "wand/MagickWand.h;MagickWand/MagickWand.h"
-      Wand MagickWand CORE_RL_wand_
+      Wand MagickWand CORE_RL_wand_ CORE_RL_MagickWand_
       MagickWand-6 MagickWand-7
       MagickWand-Q16 MagickWand-Q8 MagickWand-Q16HDRI MagickWand-Q8HDRI
       MagickWand-6.Q64 MagickWand-6.Q32 MagickWand-6.Q64HDRI MagickWand-6.Q32HDRI
@@ -217,7 +217,7 @@
     list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickWand_LIBRARY)
   elseif(component STREQUAL "MagickCore")
     FIND_IMAGEMAGICK_API(MagickCore "magick/MagickCore.h;MagickCore/MagickCore.h"
-      Magick MagickCore CORE_RL_magick_
+      Magick MagickCore CORE_RL_magick_ CORE_RL_MagickCore_
       MagickCore-6 MagickCore-7
       MagickCore-Q16 MagickCore-Q8 MagickCore-Q16HDRI MagickCore-Q8HDRI
       MagickCore-6.Q64 MagickCore-6.Q32 MagickCore-6.Q64HDRI MagickCore-6.Q32HDRI
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index a6e8503..8fd129a 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
-set(CMake_VERSION_MINOR 10)
-set(CMake_VERSION_PATCH 20180205)
-#set(CMake_VERSION_RC 1)
+set(CMake_VERSION_MINOR 11)
+set(CMake_VERSION_PATCH 0)
+set(CMake_VERSION_RC 1)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index b1afdc9..2a38599 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -542,6 +542,7 @@
   makefileStream.SetCopyIfDifferent(true);
   makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
 
+  makefileStream << "TARGETS:= \n";
   makefileStream << "empty:= \n";
   makefileStream << "space:= $(empty) $(empty)\n";
   makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 41142e5..93c78b5 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -8,6 +8,7 @@
 #include "cmCustomCommandLines.h"
 #include "cmDuration.h"
 #include "cmFilePathChecksum.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmLinkItem.h"
@@ -22,7 +23,6 @@
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
-#include "cm_sys_stat.h"
 #include "cmake.h"
 #include "cmsys/FStream.hxx"
 #include "cmsys/SystemInformation.hxx"
@@ -867,34 +867,6 @@
     dir += cfg;
   }
 
-  auto OpenInfoFile = [](cmsys::ofstream& ofs,
-                         std::string const& fileName) -> bool {
-    // Ensure we have write permission
-    if (cmSystemTools::FileExists(fileName)) {
-      mode_t perm = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-      mode_t mode_write = S_IWRITE;
-#else
-      mode_t mode_write = S_IWUSR;
-#endif
-      cmSystemTools::GetPermissions(fileName, perm);
-      if (!(perm & mode_write)) {
-        cmSystemTools::SetPermissions(fileName, perm | mode_write);
-      }
-    }
-
-    ofs.open(fileName.c_str(),
-             (std::ios::out | std::ios::binary | std::ios::trunc));
-    if (!ofs) {
-      // File open error
-      std::string error = "Internal CMake error when trying to open file: ";
-      error += Quoted(fileName);
-      error += " for writing.";
-      cmSystemTools::Error(error.c_str());
-    }
-    return static_cast<bool>(ofs);
-  };
-
   // Generate autogen target info file
   if (this->MocEnabled || this->UicEnabled) {
     if (this->MocEnabled) {
@@ -911,8 +883,10 @@
       this->Parallel = std::to_string(GetParallelCPUCount());
     }
 
-    cmsys::ofstream ofs;
-    if (OpenInfoFile(ofs, this->AutogenInfoFile)) {
+    cmGeneratedFileStream ofs;
+    ofs.SetCopyIfDifferent(true);
+    ofs.Open(this->AutogenInfoFile.c_str(), false, true);
+    if (ofs) {
       // Utility lambdas
       auto CWrite = [&ofs](const char* key, std::string const& value) {
         ofs << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value)
@@ -1012,14 +986,18 @@
         CWriteNestedLists("AM_UIC_OPTIONS_OPTIONS", this->UicFileOptions);
         CWriteList("AM_UIC_SEARCH_PATHS", this->UicSearchPaths);
       }
+    } else {
+      return;
     }
   }
 
   // Generate auto RCC info files
   if (this->RccEnabled) {
     for (Qrc const& qrc : this->Qrcs) {
-      cmsys::ofstream ofs;
-      if (OpenInfoFile(ofs, qrc.InfoFile)) {
+      cmGeneratedFileStream ofs;
+      ofs.SetCopyIfDifferent(true);
+      ofs.Open(qrc.InfoFile.c_str(), false, true);
+      if (ofs) {
         // Utility lambdas
         auto CWrite = [&ofs](const char* key, std::string const& value) {
           ofs << "set(" << key << " "
@@ -1069,7 +1047,7 @@
         CWrite("ARCC_OPTIONS", cmJoin(qrc.Options, ";"));
         CWrite("ARCC_INPUTS", cmJoin(qrc.Resources, ";"));
       } else {
-        break;
+        return;
       }
     }
   }
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
index 3c83957..f627966 100644
--- a/Utilities/Release/upload_release.cmake
+++ b/Utilities/Release/upload_release.cmake
@@ -1,6 +1,6 @@
 set(CTEST_RUN_CURRENT_SCRIPT 0)
 if(NOT VERSION)
- set(VERSION 3.10)
+ set(VERSION 3.11)
 endif()
 if(NOT DEFINED PROJECT_PREFIX)
   set(PROJECT_PREFIX cmake-${VERSION})