Merge branch 'FindCUDA-verbatim' into release
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake
index a0aadcc..3203279 100644
--- a/CMakeCPack.cmake
+++ b/CMakeCPack.cmake
@@ -198,6 +198,17 @@
 
   set(CPACK_WIX_UPGRADE_GUID "8ffd1d72-b7f1-11e2-8ee5-00238bca4991")
 
+  if(MSVC AND NOT "$ENV{WIX}" STREQUAL "")
+    set(WIX_CUSTOM_ACTION_ENABLED TRUE)
+    if(CMAKE_CONFIGURATION_TYPES)
+      set(WIX_CUSTOM_ACTION_MULTI_CONFIG TRUE)
+    else()
+      set(WIX_CUSTOM_ACTION_MULTI_CONFIG FALSE)
+    endif()
+  else()
+    set(WIX_CUSTOM_ACTION_ENABLED FALSE)
+  endif()
+
   # Set the options file that needs to be included inside CMakeCPackOptions.cmake
   set(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake)
   configure_file("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in"
diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in
index 25af0c9..59ae224 100644
--- a/CMakeCPackOptions.cmake.in
+++ b/CMakeCPackOptions.cmake.in
@@ -246,6 +246,29 @@
     "@CMake_SOURCE_DIR@/Utilities/Release/WiX/cmake_extra_dialog.wxs"
   )
 
+  set(_WIX_CUSTOM_ACTION_ENABLED "@WIX_CUSTOM_ACTION_ENABLED@")
+  if(_WIX_CUSTOM_ACTION_ENABLED)
+    list(APPEND CPACK_WIX_EXTRA_SOURCES
+      "@CMake_SOURCE_DIR@/Utilities/Release/WiX/cmake_nsis_overwrite_dialog.wxs"
+      )
+    list(APPEND CPACK_WIX_CANDLE_EXTRA_FLAGS -dCHECK_NSIS=1)
+
+    set(_WIX_CUSTOM_ACTION_MULTI_CONFIG "@WIX_CUSTOM_ACTION_MULTI_CONFIG@")
+    if(_WIX_CUSTOM_ACTION_MULTI_CONFIG)
+      if(CPACK_BUILD_CONFIG)
+        set(_WIX_CUSTOM_ACTION_CONFIG "${CPACK_BUILD_CONFIG}")
+      else()
+        set(_WIX_CUSTOM_ACTION_CONFIG "Release")
+      endif()
+
+      list(APPEND CPACK_WIX_EXTRA_SOURCES
+        "@CMake_BINARY_DIR@/Utilities/Release/WiX/custom_action_dll-${_WIX_CUSTOM_ACTION_CONFIG}.wxs")
+    else()
+      list(APPEND CPACK_WIX_EXTRA_SOURCES
+        "@CMake_BINARY_DIR@/Utilities/Release/WiX/custom_action_dll.wxs")
+    endif()
+  endif()
+
   set(CPACK_WIX_UI_REF "CMakeUI_InstallDir")
 
   set(CPACK_WIX_PATCH_FILE
@@ -261,8 +284,7 @@
   if(BUILD_QtDialog)
     list(APPEND CPACK_WIX_PATCH_FILE
       "@CMake_SOURCE_DIR@/Utilities/Release/WiX/patch_desktop_shortcut.xml"
-    )
-
-    set(CPACK_WIX_CANDLE_EXTRA_FLAGS "-dBUILD_QtDialog=1")
+      )
+    list(APPEND CPACK_WIX_CANDLE_EXTRA_FLAGS -dBUILD_QtDialog=1)
   endif()
 endif()
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index ecbf9dd..8726b70 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -178,7 +178,7 @@
 
 ::
 
-  add_custom_command(TARGET target
+  add_custom_command(TARGET <target>
                      PRE_BUILD | PRE_LINK | POST_BUILD
                      COMMAND command1 [ARGS] [args1...]
                      [COMMAND command2 [ARGS] [args2...] ...]
@@ -188,7 +188,10 @@
                      [VERBATIM] [USES_TERMINAL])
 
 This defines a new command that will be associated with building the
-specified target.  When the command will happen is determined by which
+specified ``<target>``.  The ``<target>`` must be defined in the current
+directory; targets defined in other directories may not be specified.
+
+When the command will happen is determined by which
 of the following is specified:
 
 ``PRE_BUILD``
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst
index 8573218..dc65a9e 100644
--- a/Help/command/cmake_minimum_required.rst
+++ b/Help/command/cmake_minimum_required.rst
@@ -5,7 +5,7 @@
 
 ::
 
-  cmake_minimum_required(VERSION major[.minor[.patch[.tweak]]]
+  cmake_minimum_required(VERSION major.minor[.patch[.tweak]]
                          [FATAL_ERROR])
 
 If the current version of CMake is lower than that required it will
diff --git a/Help/command/get_target_property.rst b/Help/command/get_target_property.rst
index 7798252..2a72c3a 100644
--- a/Help/command/get_target_property.rst
+++ b/Help/command/get_target_property.rst
@@ -13,6 +13,6 @@
 Properties are usually used to control how a target is built, but some
 query the target instead.  This command can get properties for any
 target so far created.  The targets do not need to be in the current
-CMakeLists.txt file.
+``CMakeLists.txt`` file.
 
 See also the more general :command:`get_property` command.
diff --git a/Help/command/if.rst b/Help/command/if.rst
index 2465bde..56e618c 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -67,9 +67,10 @@
  True if the given name is an existing policy (of the form ``CMP<NNNN>``).
 
 ``if(TARGET target-name)``
- True if the given name is an existing logical target name such as those
- created by the :command:`add_executable`, :command:`add_library`, or
- :command:`add_custom_target` commands.
+ True if the given name is an existing logical target name created
+ by a call to the :command:`add_executable`, :command:`add_library`,
+ or :command:`add_custom_target` command that has already been invoked
+ (in any directory).
 
 ``if(TEST test-name)``
  True if the given name is an existing test name created by the
@@ -80,7 +81,7 @@
  only for full paths.
 
 ``if(file1 IS_NEWER_THAN file2)``
- True if file1 is newer than file2 or if one of the two files doesn't
+ True if ``file1`` is newer than ``file2`` or if one of the two files doesn't
  exist.  Behavior is well-defined only for full paths.  If the file
  time stamps are exactly the same, an ``IS_NEWER_THAN`` comparison returns
  true, so that any dependent build operations will occur in the event
diff --git a/Help/command/install.rst b/Help/command/install.rst
index 5d2add7..45167bc 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -72,12 +72,13 @@
           [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|
             PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
            [DESTINATION <dir>]
-           [INCLUDES DESTINATION [<dir> ...]]
            [PERMISSIONS permissions...]
            [CONFIGURATIONS [Debug|Release|...]]
            [COMPONENT <component>]
            [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
-          ] [...])
+          ] [...]
+          [INCLUDES DESTINATION [<dir> ...]]
+          )
 
 The ``TARGETS`` form specifies rules for installing targets from a
 project.  There are five kinds of target files that may be installed:
@@ -97,11 +98,7 @@
 If none is given the installation properties apply to all target
 types.  If only one is given then only targets of that type will be
 installed (which can be used to install just a DLL or just an import
-library).  The ``INCLUDES DESTINATION`` specifies a list of directories
-which will be added to the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`
-target property of the ``<targets>`` when exported by the
-:command:`install(EXPORT)` command.  If a relative path is
-specified, it is treated as relative to the ``$<INSTALL_PREFIX>``.
+library).
 
 The ``PRIVATE_HEADER``, ``PUBLIC_HEADER``, and ``RESOURCE`` arguments
 cause subsequent properties to be applied to installing a ``FRAMEWORK``
@@ -131,6 +128,14 @@
 :prop_tgt:`SOVERSION` target properties for details on creating versioned
 shared libraries.
 
+The ``INCLUDES DESTINATION`` specifies a list of directories
+which will be added to the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`
+target property of the ``<targets>`` when exported by the
+:command:`install(EXPORT)` command.  If a relative path is
+specified, it is treated as relative to the ``$<INSTALL_PREFIX>``.
+This is independent of the rest of the argument groups and does
+not actually install anything.
+
 One or more groups of properties may be specified in a single call to
 the ``TARGETS`` form of this command.  A target may be installed more than
 once to different locations.  Consider hypothetical targets ``myExe``,
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index 4a04f31..9004bb2 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -427,7 +427,7 @@
   )
 
   add_library(lib1Version3 SHARED lib1_v3.cpp)
-  set_property(TARGET lib1Version2 PROPERTY INTERFACE_CONTAINER_SIZE_REQUIRED 1000)
+  set_property(TARGET lib1Version3 PROPERTY INTERFACE_CONTAINER_SIZE_REQUIRED 1000)
 
   add_executable(exe1 exe1.cpp)
   # CONTAINER_SIZE_REQUIRED will be "200"
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index a335384..7bfdcad 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -718,7 +718,7 @@
   If False, do not try to use the relevant CMake wrapping command.
 
 ``Xxx_Yy_FOUND``
-  If False, optional Yy part of Xxx sytem is not available.
+  If False, optional Yy part of Xxx system is not available.
 
 ``Xxx_FOUND``
   Set to false, or undefined, if we haven't found, or don't want to use
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index c9219d5..10f05df 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -213,6 +213,7 @@
    /module/FindwxWidgets
    /module/FindwxWindows
    /module/FindXCTest
+   /module/FindXalanC
    /module/FindXercesC
    /module/FindX11
    /module/FindXMLRPC
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 3f49572..15eaece 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -118,6 +118,7 @@
    /variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName
    /variable/CMAKE_ERROR_DEPRECATED
    /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+   /variable/CMAKE_EXPORT_COMPILE_COMMANDS
    /variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    /variable/CMAKE_SYSROOT
    /variable/CMAKE_FIND_APPBUNDLE
diff --git a/Help/module/FindXalanC.rst b/Help/module/FindXalanC.rst
new file mode 100644
index 0000000..b99d212
--- /dev/null
+++ b/Help/module/FindXalanC.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindXalanC.cmake
diff --git a/Help/policy/CMP0040.rst b/Help/policy/CMP0040.rst
index e746c03..d46baf6 100644
--- a/Help/policy/CMP0040.rst
+++ b/Help/policy/CMP0040.rst
@@ -1,18 +1,21 @@
 CMP0040
 -------
 
-The target in the TARGET signature of add_custom_command() must exist.
+The target in the ``TARGET`` signature of :command:`add_custom_command`
+must exist and must be defined in current directory.
 
 CMake 2.8.12 and lower silently ignored a custom command created with
-the TARGET signature of :command:`add_custom_command`
-if the target is unknown.
+the ``TARGET`` signature of :command:`add_custom_command`
+if the target is unknown or was defined outside the current directory.
 
-The OLD behavior for this policy is to ignore custom commands
-for unknown targets. The NEW behavior for this policy is to report an error
-if the target referenced in :command:`add_custom_command` is unknown.
+The ``OLD`` behavior for this policy is to ignore custom commands
+for unknown targets.  The ``NEW`` behavior for this policy is to report
+an error if the target referenced in :command:`add_custom_command` is
+unknown or was defined outside the current directory.
 
 This policy was introduced in CMake version 3.0.  CMake version
-|release| warns when the policy is not set and uses OLD behavior.  Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|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/3.5.rst b/Help/release/3.5.rst
new file mode 100644
index 0000000..009eb3c
--- /dev/null
+++ b/Help/release/3.5.rst
@@ -0,0 +1,185 @@
+CMake 3.5 Release Notes
+***********************
+
+.. only:: html
+
+  .. contents::
+
+Changes made since CMake 3.4 include the following.
+
+New Features
+============
+
+GUI
+---
+
+* The :manual:`cmake-gui(1)` gained options to control warnings about
+  deprecated functionality.
+
+* The :manual:`cmake-gui(1)` learned an option to set the toolset
+  to be used with VS IDE and Xcode generators, much like the
+  existing ``-T`` option to :manual:`cmake(1)`.
+
+* The :manual:`cmake-gui(1)` gained a Regular Expression Explorer which
+  may be used to create and evaluate regular expressions in real-time.
+  The explorer window is available via the ``Tools`` menu.
+
+Command-Line
+------------
+
+* The ``-Wdev`` and ``-Wno-dev`` :manual:`cmake(1)` options now also enable
+  and suppress the deprecated warnings output by default.
+
+* The suppression of developer warnings as errors can now be controlled with
+  the new ``-Werror=dev`` and ``-Wno-error=dev`` :manual:`cmake(1)` options.
+
+* The :manual:`cmake(1)` ``-E`` command-line tools ``copy``,
+  ``copy_if_different``, ``copy_directory``, and ``make_directory``
+  learned to support multiple input files or directories.
+
+Commands
+--------
+
+* The :command:`cmake_parse_arguments` command is now implemented natively.
+  The :module:`CMakeParseArguments` module remains as an empty placeholder
+  for compatibility.
+
+* The :command:`install(DIRECTORY)` command learned to support
+  :manual:`generator expressions <cmake-generator-expressions(7)>`
+  in the list of directories.
+
+Variables
+---------
+
+* The :variable:`CMAKE_ERROR_DEPRECATED` variable can now be set using the
+  ``-Werror=deprecated`` and ``-Wno-error=deprecated`` :manual:`cmake(1)`
+  options.
+
+* The :variable:`CMAKE_WARN_DEPRECATED` variable can now be set using the
+  ``-Wdeprecated`` and ``-Wno-deprecated`` :manual:`cmake(1)` options.
+
+Properties
+----------
+
+* The :prop_tgt:`VS_GLOBAL_<variable>` target property is now implemented
+  for VS 2010 and above.  Previously it worked only in VS 2008 and below.
+
+Modules
+-------
+
+* The :module:`ExternalProject` module learned a new ``GIT_REMOTE_NAME``
+  option to control the ``git clone --origin`` value.
+
+* The :module:`FindBoost` module now provides imported targets
+  such as ``Boost::boost`` and ``Boost::filesystem``.
+
+* The :module:`FindFLEX` module ``FLEX_TARGET`` macro learned a
+  new ``DEFINES_FILE`` option to specify a custom output header
+  to be generated.
+
+* The :module:`FindGTest` module now provides imported targets.
+
+* The :module:`FindGTK2` module, when ``GTK2_USE_IMPORTED_TARGETS`` is
+  enabled, now sets ``GTK2_LIBRARIES`` to contain the list of imported
+  targets instead of the paths to the libraries.  Moreover it now sets
+  a new ``GTK2_TARGETS`` variable containing all the targets imported.
+
+* The :module:`FindOpenMP` module learned to support Clang.
+
+* The :module:`FindOpenSSL` module gained a new
+  ``OPENSSL_MSVC_STATIC_RT`` option to search for libraries using
+  the MSVC static runtime.
+
+* The :module:`FindPNG` module now provides imported targets.
+
+* The :module:`FindTIFF` module now provides imported targets.
+
+* A :module:`FindXalanC` module was introduced to find the
+  Apache Xalan-C++ XSL transform processing library.
+
+* The :module:`FindXercesC` module now provides imported targets.
+
+Platforms
+---------
+
+* Support was added for the ARM Compiler (arm.com) with compiler id ``ARMCC``.
+
+* A new platform file for cross-compiling in the Cray Linux Environment to
+  target compute nodes was added.  See
+  :ref:`Cross Compiling for the Cray Linux Environment <Cray Cross-Compile>`
+  for usage details.
+
+* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
+  is now aware of features supported by Clang compilers on Windows (MinGW).
+
+* When building for embedded Apple platforms like iOS CMake learned to build and
+  install combined targets which contain both a device and a simulator build.
+  This behavior can be enabled by setting the :prop_tgt:`IOS_INSTALL_COMBINED`
+  target property.
+
+CPack
+-----
+
+* The :module:`CPackDMG` module learned new variable to specify AppleScript
+  file run to customize appearance of ``DragNDrop`` installer folder,
+  including background image setting using supplied PNG or multi-resolution
+  TIFF file.  See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and
+  :variable:`CPACK_DMG_BACKGROUND_IMAGE` variables.
+
+* The :module:`CPackDeb` module learned to set the optional config
+  file ``Source`` field using a monolithic or per-component variable.
+  See :variable:`CPACK_DEBIAN_PACKAGE_SOURCE`.
+
+* The :module:`CPackDeb` module learned to set Package, Section
+  and Priority control fields per-component.
+  See variables :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION` and
+  :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`.
+
+* The :module:`CPack DragNDrop generator <CPackDMG>` learned to add
+  multi-lingual SLAs to a DMG which is presented to the user when they try to
+  mount the DMG.  See the :variable:`CPACK_DMG_SLA_LANGUAGES` and
+  :variable:`CPACK_DMG_SLA_DIR` variables for details.
+
+* The :module:`CPackNSIS` module learned new variables to add bitmaps to the
+  installer.  See the :variable:`CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP`
+  and :variable:`CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP` variables.
+
+* The :module:`CPackRPM` module learned to set Name and Group
+  control fields per-component.
+  See :variable:`CPACK_RPM_<component>_PACKAGE_NAME`
+  and :variable:`CPACK_RPM_<component>_PACKAGE_GROUP`.
+
+Other
+-----
+
+* Warnings about deprecated functionality are now enabled by default.
+  They may be suppressed with ``-Wno-deprecated`` or by setting the
+  :variable:`CMAKE_WARN_DEPRECATED` variable to false.
+
+Deprecated and Removed Features
+===============================
+
+* The :manual:`cmake(1)` ``-E time`` command now properly passes arguments
+  with spaces or special characters through to the child process.  This
+  may break scripts that worked around the bug with their own extra
+  quoting or escaping.
+
+* The :generator:`Xcode` generator was fixed to escape backslashes in
+  strings consistently with other generators.  Projects that previously
+  worked around the inconsistecy with an extra level of backslashes
+  conditioned on the Xcode generator must be updated to remove the
+  workaround for CMake 3.5 and greater.
+
+Other Changes
+=============
+
+* The :generator:`Visual Studio 14 2015` generator learned to map the
+  ``/debug:fastlink`` linker flag to the ``.vcxproj`` file property.
+
+* The :module:`FindGTK2` module now configures the ``GTK2::sigc++`` imported
+  target to enable c++11 on its dependents when using sigc++ 2.5.1 or higher.
+
+* The precompiled Windows binary provided on ``cmake.org`` is now a
+  ``.msi`` package instead of an installer executable.  One may need
+  to manually uninstall CMake versions lower than 3.5 before installing
+  the new package.
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/dev/CMakeParseArguments-native-impl.rst b/Help/release/dev/CMakeParseArguments-native-impl.rst
deleted file mode 100644
index 114a099..0000000
--- a/Help/release/dev/CMakeParseArguments-native-impl.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-CMakeParseArguments-native-impl
--------------------------------
-
-* The :command:`cmake_parse_arguments` command is now implemented natively.
-  The :module:`CMakeParseArguments` module remains as an empty placeholder
-  for compatibility.
diff --git a/Help/release/dev/FindBoost-imported-targets.rst b/Help/release/dev/FindBoost-imported-targets.rst
deleted file mode 100644
index 1129ded..0000000
--- a/Help/release/dev/FindBoost-imported-targets.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-FindBoost-imported-targets
---------------------------
-
-* The :module:`FindBoost` module now provides imported targets
-  such as ``Boost::boost`` and ``Boost::filesystem``.
diff --git a/Help/release/dev/FindFLEX-DEFINES_FILE.rst b/Help/release/dev/FindFLEX-DEFINES_FILE.rst
deleted file mode 100644
index 95133aa..0000000
--- a/Help/release/dev/FindFLEX-DEFINES_FILE.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-FindFLEX-DEFINES_FILE
----------------------
-
-* The :module:`FindFLEX` module ``FLEX_TARGET`` macro learned a
-  new ``DEFINES_FILE`` option to specify a custom output header
-  to be generated.
diff --git a/Help/release/dev/FindGTK2_GTK2_TARGETS.rst b/Help/release/dev/FindGTK2_GTK2_TARGETS.rst
deleted file mode 100644
index 76e3657..0000000
--- a/Help/release/dev/FindGTK2_GTK2_TARGETS.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-FindGTK2_GTK2_TARGETS
----------------------
-
-* The :module:`FindGTK2` module, when ``GTK2_USE_IMPORTED_TARGETS`` is
-  enabled, now sets ``GTK2_LIBRARIES`` to contain the list of imported
-  targets instead of the paths to the libraries.  Moreover it now sets
-  a new ``GTK2_TARGETS`` variable containing all the targets imported.
diff --git a/Help/release/dev/FindGTK2_sigc++_c++11.rst b/Help/release/dev/FindGTK2_sigc++_c++11.rst
deleted file mode 100644
index 2ba1459..0000000
--- a/Help/release/dev/FindGTK2_sigc++_c++11.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-FindGTK2_sigc++_c++11
----------------------
-
-* Starting with sigc++ 2.5.1, c++11 must be enabled in order to use
-  sigc++. The GTK2::sigc++ imported target will automatically enable the
-  required build flags in order to build with the version found on the
-  system.
diff --git a/Help/release/dev/FindGTest-imported-targets.rst b/Help/release/dev/FindGTest-imported-targets.rst
deleted file mode 100644
index 3cb98da..0000000
--- a/Help/release/dev/FindGTest-imported-targets.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-FindGTest-imported-targets
---------------------------
-
-* The :module:`FindGTest` module now provides imported targets.
diff --git a/Help/release/dev/FindOpenMP-clang.rst b/Help/release/dev/FindOpenMP-clang.rst
deleted file mode 100644
index 44c805c..0000000
--- a/Help/release/dev/FindOpenMP-clang.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-FindOpenMP-clang
-----------------
-
-* The :module:`FindOpenMP` module learned to support Clang.
diff --git a/Help/release/dev/FindOpenSSL-msvc-static-rt.rst b/Help/release/dev/FindOpenSSL-msvc-static-rt.rst
deleted file mode 100644
index 6e0ee27..0000000
--- a/Help/release/dev/FindOpenSSL-msvc-static-rt.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-FindOpenSSL-msvc-static-rt
---------------------------
-
-* The :module:`FindOpenSSL` module gained a new
-  ``OPENSSL_MSVC_STATIC_RT`` option to search for libraries using
-  the MSVC static runtime.
diff --git a/Help/release/dev/FindTIFF-imported-targets.rst b/Help/release/dev/FindTIFF-imported-targets.rst
deleted file mode 100644
index f8bbc14..0000000
--- a/Help/release/dev/FindTIFF-imported-targets.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-FindTIFF-imported-targets
--------------------------
-
-* The :module:`FindTIFF` module now provides imported targets.
diff --git a/Help/release/dev/FindXercesC-imported-targets.rst b/Help/release/dev/FindXercesC-imported-targets.rst
deleted file mode 100644
index 69cec5c..0000000
--- a/Help/release/dev/FindXercesC-imported-targets.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-FindXercesC-imported-targets
-----------------------------
-
-* The :module:`FindXercesC` module now provides imported targets.
diff --git a/Help/release/dev/add-armcc-toolchain.rst b/Help/release/dev/add-armcc-toolchain.rst
deleted file mode 100644
index 2cf6414..0000000
--- a/Help/release/dev/add-armcc-toolchain.rst
+++ /dev/null
@@ -1,4 +0,0 @@
-add-armcc-toolchain
--------------------
-
-* Support was added for the ARM Compiler (arm.com) with compiler id ``ARMCC``.
diff --git a/Help/release/dev/add-cray-linux-platform.rst b/Help/release/dev/add-cray-linux-platform.rst
deleted file mode 100644
index 7000382..0000000
--- a/Help/release/dev/add-cray-linux-platform.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-add-cray-linux-platform
------------------------
-
-* A new platform file for cross-compiling in the Cray Linux Environment to
-  target compute nodes was added.  See
-  :ref:`Cross Compiling for the Cray Linux Environment <Cray Cross-Compile>`
-  for usage details.
diff --git a/Help/release/dev/better-looking-mac-packages.rst b/Help/release/dev/better-looking-mac-packages.rst
deleted file mode 100644
index ef1b8e8..0000000
--- a/Help/release/dev/better-looking-mac-packages.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-better-looking-mac-packages
----------------------------
-
-* The :module:`CPackDMG` module learned new variable to specify AppleScript
-  file run to customize appearance of ``DragNDrop`` installer folder,
-  including background image setting using supplied PNG or multi-resolution
-  TIFF file.  See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and
-  :variable:`CPACK_DMG_BACKGROUND_IMAGE` variables.
diff --git a/Help/release/dev/cmake-E-multiple-inputs.rst b/Help/release/dev/cmake-E-multiple-inputs.rst
deleted file mode 100644
index 480261d..0000000
--- a/Help/release/dev/cmake-E-multiple-inputs.rst
+++ /dev/null
@@ -1,11 +0,0 @@
-cmake-E-multiple-inputs
------------------------
-
-* The :manual:`cmake(1)` ``-E copy`` and ``-E copy_if_different`` command-line
-  tools learned to support copying multiple input files to a directory.
-
-* The :manual:`cmake(1)` ``-E copy_directory`` command-line
-  tool learned to support copying multiple input directories to a directory.
-
-* The :manual:`cmake(1)` ``-E make_directory`` command-line
-  tool learned to support copying multiple input directories to a directory.
diff --git a/Help/release/dev/cmake-W-options.rst b/Help/release/dev/cmake-W-options.rst
deleted file mode 100644
index c055f96..0000000
--- a/Help/release/dev/cmake-W-options.rst
+++ /dev/null
@@ -1,22 +0,0 @@
-cmake-W-options
----------------
-
-* The :variable:`CMAKE_WARN_DEPRECATED` variable can now be set using the
-  ``-Wdeprecated`` and ``-Wno-deprecated`` :manual:`cmake(1)` options.
-
-* The ``-Wdev`` and ``-Wno-dev`` :manual:`cmake(1)` options now also enable
-  and suppress the deprecated warnings output by default.
-
-* Warnings about deprecated functionality are now enabled by default.
-  They may be suppressed with ``-Wno-deprecated`` or by setting the
-  :variable:`CMAKE_WARN_DEPRECATED` variable to false.
-
-* Warnings about deprecated functionality can now be controlled in the
-  :manual:`cmake-gui(1)` application.
-
-* The suppression of developer warnings as errors can now be controlled with
-  the new ``-Werror=dev`` and ``-Wno-error=dev`` :manual:`cmake(1)` options.
-
-* The :variable:`CMAKE_ERROR_DEPRECATED` variable can now be set using the
-  ``-Werror=deprecated`` and ``-Wno-error=deprecated`` :manual:`cmake(1)`
-  options.
diff --git a/Help/release/dev/cmake-gui-select-toolset.rst b/Help/release/dev/cmake-gui-select-toolset.rst
deleted file mode 100644
index 5186f91..0000000
--- a/Help/release/dev/cmake-gui-select-toolset.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-cmake-gui-select-toolset
-------------------------
-
-* The :manual:`cmake-gui(1)` learned an option to set the toolset
-  to be used with VS IDE and Xcode generators, much like the
-  existing ``-T`` option to :manual:`cmake(1)`.
diff --git a/Help/release/dev/cpack-deb-config-file-source-field.rst b/Help/release/dev/cpack-deb-config-file-source-field.rst
deleted file mode 100644
index bbc2aa6..0000000
--- a/Help/release/dev/cpack-deb-config-file-source-field.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-cpack-deb-config-file-source-field
-----------------------------------
-
-* The :module:`CPackDeb` module learned to set optional config
-  file ``Source`` field - monolithic and per-component variable.
-  See :variable:`CPACK_DEBIAN_PACKAGE_SOURCE`.
diff --git a/Help/release/dev/cpack-deb-new-component-vars.rst b/Help/release/dev/cpack-deb-new-component-vars.rst
deleted file mode 100644
index e30afdb..0000000
--- a/Help/release/dev/cpack-deb-new-component-vars.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-cpack-deb-new-component-vars
-----------------------------
-
-* The :module:`CPackDeb` module learned to set Package, Section
-  and Priority control fields per-component.
-  See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION`
-  and :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`.
diff --git a/Help/release/dev/cpack-dmg-multilanguage-sla.rst b/Help/release/dev/cpack-dmg-multilanguage-sla.rst
deleted file mode 100644
index 9e28fa2..0000000
--- a/Help/release/dev/cpack-dmg-multilanguage-sla.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-cpack-dmg-multilanguage-sla
----------------------------
-
-* The :module:`CPack DragNDrop generator <CPackDMG>` learned to add
-  multi-lingual SLAs to a DMG which is presented to the user when they try to
-  mount the DMG.  See the :variable:`CPACK_DMG_SLA_LANGUAGES` and
-  :variable:`CPACK_DMG_SLA_DIR` variables for details.
diff --git a/Help/release/dev/cpack-nsis-bitmap.rst b/Help/release/dev/cpack-nsis-bitmap.rst
deleted file mode 100644
index c5ccfb5..0000000
--- a/Help/release/dev/cpack-nsis-bitmap.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-cpack-nsis-bitmap
------------------
-
-* The :module:`CPackNSIS` module learned new variables to add bitmaps to the
-  installer.  See the :variable:`CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP`
-  and :variable:`CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP` variables.
diff --git a/Help/release/dev/cpack-rpm-percomponent-group-and-name.rst b/Help/release/dev/cpack-rpm-percomponent-group-and-name.rst
deleted file mode 100644
index 146f8ac..0000000
--- a/Help/release/dev/cpack-rpm-percomponent-group-and-name.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-cpack-rpm-percomponent-group-and-name
--------------------------------------
-
-* The :module:`CPackRPM` module learned to set Name and Group
-  control fields per-component.
-  See :variable:`CPACK_RPM_<component>_PACKAGE_NAME`
-  and :variable:`CPACK_RPM_<component>_PACKAGE_GROUP`.
diff --git a/Help/release/dev/deprecate-CMakeForceCompiler.rst b/Help/release/dev/deprecate-CMakeForceCompiler.rst
deleted file mode 100644
index dc6e817..0000000
--- a/Help/release/dev/deprecate-CMakeForceCompiler.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-deprecate-CMakeForceCompiler
-----------------------------
-
-* The :module:`CMakeForceCompiler` module and its macros are now deprecated.
-  See module documentation for an explanation.
diff --git a/Help/release/dev/install-DIRECTORY-genex.rst b/Help/release/dev/install-DIRECTORY-genex.rst
deleted file mode 100644
index e48f19b..0000000
--- a/Help/release/dev/install-DIRECTORY-genex.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-install-DIRECTORY-genex
------------------------
-
-* The :command:`install(DIRECTORY)` command learned to support
-  :manual:`generator expressions <cmake-generator-expressions(7)>`
-  in the list of directories.
diff --git a/Help/release/dev/ios-universal.rst b/Help/release/dev/ios-universal.rst
deleted file mode 100644
index f96abed..0000000
--- a/Help/release/dev/ios-universal.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-ios-universal
--------------
-
-* When building for embedded Apple platforms like iOS CMake learned to build and
-  install combined targets which contain both a device and a simulator build.
-  This behavior can be enabled by setting the :prop_tgt:`IOS_INSTALL_COMBINED`
-  target property.
diff --git a/Help/release/dev/mingw-clang-compile-features.rst b/Help/release/dev/mingw-clang-compile-features.rst
deleted file mode 100644
index 5b1fb96..0000000
--- a/Help/release/dev/mingw-clang-compile-features.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-mingw-clang-compile-features
-----------------------------
-
-* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
-  is now aware of features supported by Clang compilers on Windows (MinGW).
diff --git a/Help/release/dev/regex-explorer.rst b/Help/release/dev/regex-explorer.rst
deleted file mode 100644
index 2147816..0000000
--- a/Help/release/dev/regex-explorer.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-regex-explorer
---------------
-
-* The Qt base CMake GUI got a Regular Expression Explorer which could be used to
-  create and evaluate regular expressions in real-time. The explorer window
-  is available via the ``Tools`` menu.
diff --git a/Help/release/dev/release-windows.rst b/Help/release/dev/release-windows.rst
deleted file mode 100644
index cc9f2d5..0000000
--- a/Help/release/dev/release-windows.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-release-windows
----------------
-
-* The precompiled Windows binary provided on ``cmake.org`` is now a
-  ``.msi`` package instead of an installer executable.  One may need
-  to manually uninstall CMake versions lower than 3.5 before installing
-  the new package.
diff --git a/Help/release/dev/vs-debug-fastlink.rst b/Help/release/dev/vs-debug-fastlink.rst
deleted file mode 100644
index c2e0599..0000000
--- a/Help/release/dev/vs-debug-fastlink.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-vs-debug-fastlink
------------------
-
-* The :generator:`Visual Studio 14 2015` generator learned to map the
-  ``/debug:fastlink`` linker flag to the ``.vcxproj`` file property.
diff --git a/Help/release/dev/vs-global-properties.rst b/Help/release/dev/vs-global-properties.rst
deleted file mode 100644
index cae49b7..0000000
--- a/Help/release/dev/vs-global-properties.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-vs-global-properties
---------------------
-
-* The :prop_tgt:`VS_GLOBAL_<variable>` target property is now implemented
-  for VS 2010 and above.  Previously it worked only in VS 2008 and below.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 752acbd..6b7da3c 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -5,14 +5,13 @@
   This file should include the adjacent "dev.txt" file
   in development versions but not in release versions.
 
-.. include:: dev.txt
-
 Releases
 ========
 
 .. toctree::
    :maxdepth: 1
 
+   3.5 <3.5>
    3.4 <3.4>
    3.3 <3.3>
    3.2 <3.2>
diff --git a/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst b/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst
new file mode 100644
index 0000000..8776279
--- /dev/null
+++ b/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst
@@ -0,0 +1,30 @@
+CMAKE_EXPORT_COMPILE_COMMANDS
+-----------------------------
+
+Enable/Disable output of compile commands during generation.
+
+If enabled, generates a ``compile_commands.json`` file containing the exact
+compiler calls for all translation units of the project in machine-readable
+form.  The format of the JSON file looks like:
+
+.. code-block:: javascript
+
+  [
+    {
+      "directory": "/home/user/development/project",
+      "command": "/usr/bin/c++ ... -c ../foo/foo.cc",
+      "file": "../foo/foo.cc"
+    },
+
+    ...
+
+    {
+      "directory": "/home/user/development/project",
+      "command": "/usr/bin/c++ ... -c ../foo/bar.cc",
+      "file": "../foo/bar.cc"
+    }
+  ]
+
+.. note::
+  This option is implemented only by :ref:`Makefile Generators`
+  and the :generator:`Ninja`.  It is ignored on other generators.
diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
index 6392849..e0be3a4 100644
--- a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
+++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst
@@ -8,4 +8,5 @@
 The :variable:`CMAKE_SYSTEM_VERSION` variable may be set to specify a
 version.  Otherwise CMake computes a default version based on the Windows
 SDK versions available.  The chosen Windows target version number is provided
-in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``.
+in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``.  If no Windows 10 SDK
+is available this value will be empty.
diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake
index 343ab3f..faa0dc5 100644
--- a/Modules/CMakeForceCompiler.cmake
+++ b/Modules/CMakeForceCompiler.cmake
@@ -2,7 +2,9 @@
 # CMakeForceCompiler
 # ------------------
 #
-# Deprecated.  Do not use.
+# Discouraged.  Avoid using this module if possible.  It will be deprecated
+# by a future version of CMake once alternatives have been provided for all
+# toolchain file use cases.
 #
 # The macros provided by this module were once intended for use by
 # cross-compiling toolchain files when CMake was not able to automatically
@@ -12,6 +14,12 @@
 # CMake detects from a compiler is now too extensive to be provided by
 # toolchain files using these macros.
 #
+# The only known remaining use case for these macros is to write toolchain
+# files for cross-compilers that cannot link binaries without special flags or
+# custom linker scripts.  These macros cause CMake to skip checks it normally
+# performs as part of enabling a language and introspecting the toolchain.
+# However, skipping these checks may limit some generation functionality.
+#
 # -------------------------------------------------------------------------
 #
 # Macro CMAKE_FORCE_C_COMPILER has the following signature:
@@ -70,8 +78,6 @@
 #  License text for the above reference.)
 
 macro(CMAKE_FORCE_C_COMPILER compiler id)
-  message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated.  "
-    "Instead just set CMAKE_C_COMPILER and allow CMake to identify the compiler.")
   set(CMAKE_C_COMPILER "${compiler}")
   set(CMAKE_C_COMPILER_ID_RUN TRUE)
   set(CMAKE_C_COMPILER_ID ${id})
@@ -84,8 +90,6 @@
 endmacro()
 
 macro(CMAKE_FORCE_CXX_COMPILER compiler id)
-  message(DEPRECATION "The CMAKE_FORCE_CXX_COMPILER macro is deprecated.  "
-    "Instead just set CMAKE_CXX_COMPILER and allow CMake to identify the compiler.")
   set(CMAKE_CXX_COMPILER "${compiler}")
   set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
   set(CMAKE_CXX_COMPILER_ID ${id})
@@ -98,8 +102,6 @@
 endmacro()
 
 macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
-  message(DEPRECATION "The CMAKE_FORCE_Fortran_COMPILER macro is deprecated.  "
-    "Instead just set CMAKE_Fortran_COMPILER and allow CMake to identify the compiler.")
   set(CMAKE_Fortran_COMPILER "${compiler}")
   set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
   set(CMAKE_Fortran_COMPILER_ID ${id})
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index c822bdb..249658d 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -57,6 +57,8 @@
     URL of git repo
   ``GIT_TAG <tag>``
     Git branch name, commit id or tag
+  ``GIT_REMOTE_NAME <name>``
+    The optional name of the remote, default to ``origin``
   ``GIT_SUBMODULES <module>...``
     Git submodules that shall be updated, all if empty
   ``HG_REPOSITORY <url>``
@@ -494,7 +496,7 @@
   "ExternalProject module."
   )
 
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_submodules src_name work_dir gitclone_infofile gitclone_stampfile)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules src_name work_dir gitclone_infofile gitclone_stampfile)
   file(WRITE ${script_filename}
 "if(\"${git_tag}\" STREQUAL \"\")
   message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
@@ -524,7 +526,7 @@
 set(number_of_tries 0)
 while(error_code AND number_of_tries LESS 3)
   execute_process(
-    COMMAND \"${git_EXECUTABLE}\" clone \"${git_repository}\" \"${src_name}\"
+    COMMAND \"${git_EXECUTABLE}\" clone --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
     WORKING_DIRECTORY \"${work_dir}\"
     RESULT_VARIABLE error_code
     )
@@ -645,7 +647,7 @@
 endfunction()
 
 
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_submodules git_repository work_dir)
+function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir)
   if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.6)
     set(git_stash_save_options --all --quiet)
   else()
@@ -687,7 +689,7 @@
   set(git_remote \"\${CMAKE_MATCH_1}\")
   set(git_tag \"\${CMAKE_MATCH_2}\")
 else()
-  set(git_remote \"origin\")
+  set(git_remote \"${git_remote_name}\")
   set(git_tag \"${git_tag}\")
 endif()
 
@@ -1228,9 +1230,24 @@
           set(cmd "${CMAKE_COMMAND}")
         endif()
         set(args --build ".")
-        if (CMAKE_CFG_INTDIR AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
-          list(APPEND args --config "${CMAKE_CFG_INTDIR}")
-        endif ()
+        if(CMAKE_CONFIGURATION_TYPES)
+          if (CMAKE_CFG_INTDIR AND
+              NOT CMAKE_CFG_INTDIR STREQUAL "." AND
+              NOT CMAKE_CFG_INTDIR MATCHES "\\$")
+            # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value
+            # provided by multi-configuration generators.  Some projects were
+            # taking advantage of that undocumented implementation detail to
+            # specify a specific configuration here.  They should use
+            # BUILD_COMMAND to change the default command instead, but for
+            # compatibility honor the value.
+            set(config ${CMAKE_CFG_INTDIR})
+            message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n"
+              "To get a non-default build command, use the BUILD_COMMAND option.")
+          else()
+            set(config $<CONFIG>)
+          endif()
+          list(APPEND args --config ${config})
+        endif()
         if(step STREQUAL "INSTALL")
           list(APPEND args --target install)
         endif()
@@ -1238,6 +1255,9 @@
         if("x${step}x" STREQUAL "xTESTx")
           string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
           set(args "")
+          if(CMAKE_CONFIGURATION_TYPES)
+            list(APPEND args -C ${config})
+          endif()
         endif()
       endif()
     else()
@@ -1749,6 +1769,11 @@
     endif()
     get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
 
+    get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
+    if(NOT git_remote_name)
+      set(git_remote_name "origin")
+    endif()
+
     # For the download step, and the git clone operation, only the repository
     # should be recorded in a configured RepositoryInfo file. If the repo
     # changes, the clone script should be run again. But if only the tag
@@ -1772,7 +1797,7 @@
     # The script will delete the source directory and then call git clone.
     #
     _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
-      ${GIT_EXECUTABLE} ${git_repository} ${git_tag} "${git_submodules}" ${src_name} ${work_dir}
+      ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" ${src_name} ${work_dir}
       ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt
       )
     set(comment "Performing download step (git clone) for '${name}'")
@@ -1993,9 +2018,13 @@
     if(NOT git_tag)
       set(git_tag "master")
     endif()
+    get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
+    if(NOT git_remote_name)
+      set(git_remote_name "origin")
+    endif()
     get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
     _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
-      ${GIT_EXECUTABLE} ${git_tag} "${git_submodules}" ${git_repository} ${work_dir}
+      ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} "${git_submodules}" ${git_repository} ${work_dir}
       )
     set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
     set(always 1)
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index edfed8e..c3058ea 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -707,7 +707,7 @@
     set(_Boost_TIMER_DEPENDENCIES chrono system)
     set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
     set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
-  elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100)
+  elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106200)
     set(_Boost_CHRONO_DEPENDENCIES system)
     set(_Boost_COROUTINE_DEPENDENCIES context system)
     set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -821,7 +821,7 @@
   # information in _Boost_COMPONENT_DEPENDENCIES.  See the
   # instructions at the top of _Boost_COMPONENT_DEPENDENCIES.
   set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
-    "1.60.0" "1.60"
+    "1.61.0" "1.61" "1.60.0" "1.60"
     "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
     "1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
     "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1"
diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index 2c3e5fd..d18f965 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -2,27 +2,26 @@
 # FindGit
 # -------
 #
-#
-#
 # The module defines the following variables:
 #
-# ::
-#
-#    GIT_EXECUTABLE - path to git command line client
-#    GIT_FOUND - true if the command line client was found
-#    GIT_VERSION_STRING - the version of git found (since CMake 2.8.8)
+# ``GIT_EXECUTABLE``
+#   Path to Git command-line client.
+# ``Git_FOUND``, ``GIT_FOUND``
+#   True if the Git command-line client was found.
+# ``GIT_VERSION_STRING``
+#   The version of Git found.
 #
 # Example usage:
 #
-# ::
+# .. code-block:: cmake
 #
 #    find_package(Git)
-#    if(GIT_FOUND)
-#      message("git found: ${GIT_EXECUTABLE}")
+#    if(Git_FOUND)
+#      message("Git found: ${GIT_EXECUTABLE}")
 #    endif()
 
 #=============================================================================
-# Copyright 2010 Kitware, Inc.
+# Copyright 2010-2016 Kitware, Inc.
 # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
 #
 # Distributed under the OSI-approved BSD License (the "License");
@@ -57,10 +56,11 @@
   NAMES ${git_names}
   PATHS ${github_path} ${_git_sourcetree_path}
   PATH_SUFFIXES Git/cmd Git/bin
-  DOC "git command line client"
+  DOC "Git command line client"
   )
 mark_as_advanced(GIT_EXECUTABLE)
 
+unset(git_names)
 unset(_git_sourcetree_path)
 
 if(GIT_EXECUTABLE)
@@ -74,7 +74,7 @@
   unset(git_version)
 endif()
 
-# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
+# Handle the QUIETLY and REQUIRED arguments and set Git_FOUND to TRUE if
 # all listed variables are TRUE
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index 7cf3f22..cae41ac 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -2,13 +2,20 @@
 # FindPNG
 # -------
 #
-# Find the native PNG includes and library
+# Find libpng, the official reference library for the PNG image format.
 #
+# Imported targets
+# ^^^^^^^^^^^^^^^^
 #
+# This module defines the following :prop_tgt:`IMPORTED` target:
 #
-# This module searches libpng, the library for working with PNG images.
+# ``PNG::PNG``
+#   The libpng library, if found.
 #
-# It defines the following variables
+# Result variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module will set the following variables in your project:
 #
 # ``PNG_INCLUDE_DIRS``
 #   where to find png.h, etc.
@@ -22,19 +29,22 @@
 # ``PNG_VERSION_STRING``
 #   the version of the PNG library found (since CMake 2.8.8)
 #
-# Also defined, but not for general use are
+# Obsolete variables
+# ^^^^^^^^^^^^^^^^^^
+#
+# The following variables may also be set, for backwards compatibility:
 #
 # ``PNG_LIBRARY``
 #   where to find the PNG library.
-#
-# For backward compatiblity the variable PNG_INCLUDE_DIR is also set.
-# It has the same value as PNG_INCLUDE_DIRS.
+# ``PNG_INCLUDE_DIR``
+#   where to find the PNG headers (same as PNG_INCLUDE_DIRS)
 #
 # Since PNG depends on the ZLib compression library, none of the above
 # will be defined unless ZLib can be found.
 
 #=============================================================================
 # Copyright 2002-2009 Kitware, Inc.
+# Copyright 2016 Raumfeld
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -105,6 +115,32 @@
         endif()
       endif ()
 
+      if(NOT TARGET PNG::PNG)
+        add_library(PNG::PNG UNKNOWN IMPORTED)
+        set_target_properties(PNG::PNG PROPERTIES
+          INTERFACE_COMPILE_DEFINITIONS "${PNG_DEFINITIONS}"
+          INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
+          INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
+        if(EXISTS "${PNG_LIBRARY}")
+          set_target_properties(PNG::PNG PROPERTIES
+            IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+            IMPORTED_LOCATION "${PNG_LIBRARY}")
+        endif()
+        if(EXISTS "${PNG_LIBRARY_DEBUG}")
+          set_property(TARGET PNG::PNG APPEND PROPERTY
+            IMPORTED_CONFIGURATIONS DEBUG)
+          set_target_properties(PNG::PNG PROPERTIES
+            IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+            IMPORTED_LOCATION_DEBUG "${PNG_LIBRARY_DEBUG}")
+        endif()
+        if(EXISTS "${PNG_LIBRARY_RELEASE}")
+          set_property(TARGET PNG::PNG APPEND PROPERTY
+            IMPORTED_CONFIGURATIONS RELEASE)
+          set_target_properties(PNG::PNG PROPERTIES
+            IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+            IMPORTED_LOCATION_RELEASE "${PNG_LIBRARY_RELEASE}")
+        endif()
+      endif()
   endif ()
 
   if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h")
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index eba6953..4f50e38 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -238,8 +238,8 @@
     if(NOT "${_extra_paths}" STREQUAL "")
       # Save the PKG_CONFIG_PATH environment variable, and add paths
       # from the CMAKE_PREFIX_PATH variables
-      set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH})
-      set(_pkgconfig_path ${_pkgconfig_path_old})
+      set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}")
+      set(_pkgconfig_path "${_pkgconfig_path_old}")
       if(NOT "${_pkgconfig_path}" STREQUAL "")
         file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
       endif()
@@ -285,7 +285,7 @@
           string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
           string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
         endif()
-        set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+        set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}")
       endif()
 
       # Unset variables
@@ -382,6 +382,9 @@
         pkg_get_variable("${_pkg_check_prefix}_PREFIX" ${_pkg_check_modules_pkg} "prefix")
         pkg_get_variable("${_pkg_check_prefix}_INCLUDEDIR" ${_pkg_check_modules_pkg} "includedir")
         pkg_get_variable("${_pkg_check_prefix}_LIBDIR" ${_pkg_check_modules_pkg} "libdir")
+        foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR)
+          _pkgconfig_set("${_pkg_check_modules_pkg}_${variable}" "${${_pkg_check_modules_pkg}_${variable}}")
+        endforeach ()
 
         if (NOT ${_is_silent})
           message(STATUS "  Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
@@ -401,7 +404,7 @@
 
     if(NOT "${_extra_paths}" STREQUAL "")
       # Restore the environment variable
-      set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+      set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}")
     endif()
 
     unset(_extra_paths)
diff --git a/Modules/FindXalanC.cmake b/Modules/FindXalanC.cmake
new file mode 100644
index 0000000..016b7aa
--- /dev/null
+++ b/Modules/FindXalanC.cmake
@@ -0,0 +1,162 @@
+#.rst:
+# FindXalanC
+# -----------
+#
+# Find the Apache Xalan-C++ XSL transform processor headers and libraries.
+#
+# Imported targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following :prop_tgt:`IMPORTED` targets:
+#
+# ``XalanC::XalanC``
+#   The Xalan-C++ ``xalan-c`` library, if found.
+#
+# Result variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module will set the following variables in your project:
+#
+# ``XalanC_FOUND``
+#   true if the Xalan headers and libraries were found
+# ``XalanC_VERSION``
+#   Xalan release version
+# ``XalanC_INCLUDE_DIRS``
+#   the directory containing the Xalan headers; note
+#   ``XercesC_INCLUDE_DIRS`` is also required
+# ``XalanC_LIBRARIES``
+#   Xalan libraries to be linked; note ``XercesC_LIBRARIES`` is also
+#   required
+#
+# Cache variables
+# ^^^^^^^^^^^^^^^
+#
+# The following cache variables may also be set:
+#
+# ``XalanC_INCLUDE_DIR``
+#   the directory containing the Xalan headers
+# ``XalanC_LIBRARY``
+#   the Xalan library
+
+# Written by Roger Leigh <rleigh@codelibre.net>
+
+#=============================================================================
+# Copyright 2016 University of Dundee
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+function(_XalanC_GET_VERSION  version_hdr)
+    file(STRINGS ${version_hdr} _contents REGEX "^[ \t]*#define XALAN_VERSION_.*")
+    if(_contents)
+        string(REGEX REPLACE "[^*]*#define XALAN_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" XalanC_MAJOR "${_contents}")
+        string(REGEX REPLACE "[^*]*#define XALAN_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" XalanC_MINOR "${_contents}")
+        string(REGEX REPLACE "[^*]*#define XALAN_VERSION_REVISION[ \t]+([0-9]+).*" "\\1" XalanC_PATCH "${_contents}")
+
+        if(NOT XalanC_MAJOR MATCHES "^[0-9]+$")
+            message(FATAL_ERROR "Version parsing failed for XALAN_VERSION_MAJOR!")
+        endif()
+        if(NOT XalanC_MINOR MATCHES "^[0-9]+$")
+            message(FATAL_ERROR "Version parsing failed for XALAN_VERSION_MINOR!")
+        endif()
+        if(NOT XalanC_PATCH MATCHES "^[0-9]+$")
+            message(FATAL_ERROR "Version parsing failed for XALAN_VERSION_REVISION!")
+        endif()
+
+        set(XalanC_VERSION "${XalanC_MAJOR}.${XalanC_MINOR}.${XalanC_PATCH}" PARENT_SCOPE)
+        set(XalanC_VERSION_MAJOR "${XalanC_MAJOR}" PARENT_SCOPE)
+        set(XalanC_VERSION_MINOR "${XalanC_MINOR}" PARENT_SCOPE)
+        set(XalanC_VERSION_PATCH "${XalanC_PATCH}" PARENT_SCOPE)
+    else()
+        message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information")
+    endif()
+endfunction()
+
+# Find include directory
+find_path(XalanC_INCLUDE_DIR
+          NAMES "xalanc/XalanTransformer/XalanTransformer.hpp"
+          DOC "Xalan-C++ include directory")
+mark_as_advanced(XalanC_INCLUDE_DIR)
+
+if(XalanC_INCLUDE_DIR)
+  _XalanC_GET_VERSION("${XalanC_INCLUDE_DIR}/xalanc/Include/XalanVersion.hpp")
+endif()
+
+if(NOT XalanC_LIBRARY)
+  # Find all XalanC libraries
+  find_library(XalanC_LIBRARY_RELEASE
+               NAMES "Xalan-C" "xalan-c"
+                     "Xalan-C_${XalanC_VERSION_MAJOR}"
+                     "Xalan-C_${XalanC_VERSION_MAJOR}_${XalanC_VERSION_MINOR}"
+               DOC "Xalan-C++ libraries (release)")
+  find_library(XalanC_LIBRARY_DEBUG
+               NAMES "Xalan-CD" "xalan-cd"
+                     "Xalan-C_${XalanC_VERSION_MAJOR}D"
+                     "Xalan-C_${XalanC_VERSION_MAJOR}_${XalanC_VERSION_MINOR}D"
+               DOC "Xalan-C++ libraries (debug)")
+  include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+  select_library_configurations(XalanC)
+  mark_as_advanced(XalanC_LIBRARY_RELEASE XalanC_LIBRARY_DEBUG)
+endif()
+
+unset(XalanC_VERSION_MAJOR)
+unset(XalanC_VERSION_MINOR)
+unset(XalanC_VERSION_PATCH)
+
+unset(XalanC_XERCESC_REQUIRED)
+if(XalanC_FIND_REQUIRED)
+  set(XalanC_XERCESC_REQUIRED REQUIRED)
+endif()
+find_package(XercesC ${XalanC_XERCESC_REQUIRED})
+unset(XalanC_XERCESC_REQUIRED)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(XalanC
+                                  FOUND_VAR XalanC_FOUND
+                                  REQUIRED_VARS XalanC_LIBRARY
+                                                XalanC_INCLUDE_DIR
+                                                XalanC_VERSION
+                                                XercesC_FOUND
+                                  VERSION_VAR XalanC_VERSION
+                                  FAIL_MESSAGE "Failed to find XalanC")
+
+if(XalanC_FOUND)
+  set(XalanC_INCLUDE_DIRS "${XalanC_INCLUDE_DIR}" ${XercesC_INCLUDE_DIRS})
+  set(XalanC_LIBRARIES "${XalanC_LIBRARY}" ${XercesC_LIBRARIES})
+
+  # For header-only libraries
+  if(NOT TARGET XalanC::XalanC)
+    add_library(XalanC::XalanC UNKNOWN IMPORTED)
+    if(XalanC_INCLUDE_DIRS)
+      set_target_properties(XalanC::XalanC PROPERTIES
+        INTERFACE_INCLUDE_DIRECTORIES "${XalanC_INCLUDE_DIRS}")
+    endif()
+    if(EXISTS "${XalanC_LIBRARY}")
+      set_target_properties(XalanC::XalanC PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+        IMPORTED_LOCATION "${XalanC_LIBRARY}")
+    endif()
+    if(EXISTS "${XalanC_LIBRARY_DEBUG}")
+      set_property(TARGET XalanC::XalanC APPEND PROPERTY
+        IMPORTED_CONFIGURATIONS DEBUG)
+      set_target_properties(XalanC::XalanC PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
+        IMPORTED_LOCATION_DEBUG "${XalanC_LIBRARY_DEBUG}")
+    endif()
+    if(EXISTS "${XalanC_LIBRARY_RELEASE}")
+      set_property(TARGET XalanC::XalanC APPEND PROPERTY
+        IMPORTED_CONFIGURATIONS RELEASE)
+      set_target_properties(XalanC::XalanC PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
+        IMPORTED_LOCATION_RELEASE "${XalanC_LIBRARY_RELEASE}")
+    endif()
+    set_target_properties(XalanC::XalanC PROPERTIES INTERFACE_LINK_LIBRARIES XercesC::XercesC)
+  endif()
+endif()
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index e4018b6..391e7f8 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -538,7 +538,7 @@
       string(TOLOWER "$ENV{windir}" windir)
       file(TO_CMAKE_PATH "${windir}" windir)
 
-      if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)")
+      if(lower MATCHES "^(api-ms-win-|${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)")
         set(is_system 1)
       endif()
 
@@ -566,7 +566,7 @@
           string(TOLOWER "${env_windir}" windir)
           string(TOLOWER "${env_sysdir}" sysroot)
 
-          if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)")
+          if(lower MATCHES "^(api-ms-win-|${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)")
             set(is_system 1)
           endif()
         endif()
diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake
index 658de3b..eafa8fa 100644
--- a/Modules/Platform/WindowsPaths.cmake
+++ b/Modules/Platform/WindowsPaths.cmake
@@ -28,46 +28,32 @@
 # Windows 64-bit Binary:
 #   ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
 #   ENV{ProgramFiles} = [C:\Program Files]
-#   ENV{ProgramW6432} = <not set>
-# (executed from cygwin):
-#   ENV{ProgramFiles(x86)} = <not set>
-#   ENV{ProgramFiles} = [C:\Program Files]
-#   ENV{ProgramW6432} = <not set>
+#   ENV{ProgramW6432} = [C:\Program Files] or <not set>
 #
-# Windows 32-bit Binary:
+# Windows 32-bit Binary on 64-bit Windows:
 #   ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
 #   ENV{ProgramFiles} = [C:\Program Files (x86)]
 #   ENV{ProgramW6432} = [C:\Program Files]
-# (executed from cygwin):
-#   ENV{ProgramFiles(x86)} = <not set>
-#   ENV{ProgramFiles} = [C:\Program Files (x86)]
-#   ENV{ProgramW6432} = [C:\Program Files]
-if(DEFINED "ENV{ProgramW6432}")
-  # 32-bit binary on 64-bit windows.
-  # The 64-bit program files are in ProgramW6432.
-  list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramW6432}")
-
-  # The 32-bit program files are in ProgramFiles.
-  if(DEFINED "ENV{ProgramFiles}")
-    list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
+set(_programfiles "")
+foreach(v "ProgramW6432" "ProgramFiles" "ProgramFiles(x86)")
+  if(DEFINED "ENV{${v}}")
+    file(TO_CMAKE_PATH "$ENV{${v}}" _env_programfiles)
+    list(APPEND _programfiles "${_env_programfiles}")
+    unset(_env_programfiles)
   endif()
-else()
-  # 64-bit binary, or 32-bit binary on 32-bit windows.
-  if(DEFINED "ENV{ProgramFiles}")
-    list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
-  endif()
-  set(programfilesx86 "ProgramFiles(x86)")
-  if(DEFINED "ENV{${programfilesx86}}")
-    # 64-bit binary.  32-bit program files are in ProgramFiles(x86).
-    list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{${programfilesx86}}")
-  elseif(DEFINED "ENV{SystemDrive}")
-    # Guess the 32-bit program files location.
-    if(EXISTS "$ENV{SystemDrive}/Program Files (x86)")
-      list(APPEND CMAKE_SYSTEM_PREFIX_PATH
-        "$ENV{SystemDrive}/Program Files (x86)")
+endforeach()
+if(DEFINED "ENV{SystemDrive}")
+  foreach(d "Program Files" "Program Files (x86)")
+    if(EXISTS "$ENV{SystemDrive}/${d}")
+      list(APPEND _programfiles "$ENV{SystemDrive}/${d}")
     endif()
-  endif()
+  endforeach()
 endif()
+if(_programfiles)
+  list(REMOVE_DUPLICATES _programfiles)
+  list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_programfiles})
+endif()
+unset(_programfiles)
 
 # Add the CMake install location.
 get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 6146d78..475ad5e 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -184,7 +184,7 @@
 #                       This is used by install_jni_symlink().
 #    JAR_FILE           The location of the jar file so that you can include
 #                       it.
-#    CLASS_DIR          The directory where the class files can be found. For
+#    CLASSDIR           The directory where the class files can be found. For
 #                       example to use them with javah.
 #
 # ::
@@ -1212,7 +1212,7 @@
 
     set (_output_files)
     if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
-      set(_classpath_sep ";")
+      set(_classpath_sep "$<SEMICOLON>")
     else ()
       set(_classpath_sep ":")
     endif()
@@ -1242,7 +1242,7 @@
         endif()
       endforeach()
       string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}")
-      list (APPEND _javah_options -classpath ${_classpath})
+      list (APPEND _javah_options -classpath "${_classpath}")
     endif()
 
     if (_create_javah_OUTPUT_DIR)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index ea95862..58eb1fc 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 4)
-set(CMake_VERSION_PATCH 20160114)
-#set(CMake_VERSION_RC 1)
+set(CMake_VERSION_MINOR 5)
+set(CMake_VERSION_PATCH 0)
+set(CMake_VERSION_RC 2)
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index ef607d2..bb65ea5 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -52,13 +52,13 @@
 size_t cmArraySize(const T (&)[N]) { return N; }
 
 template<typename T, size_t N>
-bool cmHasLiteralPrefix(T str1, const char (&str2)[N])
+bool cmHasLiteralPrefix(const T& str1, const char (&str2)[N])
 {
   return cmHasLiteralPrefixImpl(str1, str2, N - 1);
 }
 
 template<typename T, size_t N>
-bool cmHasLiteralSuffix(T str1, const char (&str2)[N])
+bool cmHasLiteralSuffix(const T& str1, const char (&str2)[N])
 {
   return cmHasLiteralSuffixImpl(str1, str2, N - 1);
 }
@@ -230,7 +230,7 @@
 std::string cmJoin(Range const& r, std::string delimiter)
 {
   return cmJoin(r, delimiter.c_str());
-};
+}
 
 template<typename Range>
 typename Range::const_iterator cmRemoveN(Range& r, size_t n)
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index ce8af55..7466c29 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -64,12 +64,14 @@
   const char *realbuffer;
   std::string buffer;
   std::string entryKey;
+  unsigned int lineno = 0;
   while(fin)
     {
     // Format is key:type=value
     std::string helpString;
     CacheEntry e;
     cmSystemTools::GetLineFromStream(fin, buffer);
+    lineno++;
     realbuffer = buffer.c_str();
     while(*realbuffer != '0' &&
           (*realbuffer == ' ' ||
@@ -77,6 +79,7 @@
            *realbuffer == '\r' ||
            *realbuffer == '\n'))
       {
+      if (*realbuffer == '\n') lineno++;
       realbuffer++;
       }
     // skip blank lines and comment lines
@@ -96,6 +99,7 @@
         helpString += &realbuffer[2];
         }
       cmSystemTools::GetLineFromStream(fin, buffer);
+      lineno++;
       realbuffer = buffer.c_str();
       if(!fin)
         {
@@ -138,8 +142,10 @@
       }
     else
       {
-      cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
-                           ". Offending entry: ", realbuffer);
+      std::ostringstream error;
+      error << "Parse error in cache file " << cacheFile;
+      error << " on line " << lineno << ". Offending entry: " << realbuffer;
+      cmSystemTools::Error(error.str().c_str());
       }
     }
   this->CacheMajorVersion = 0;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 5330acd..6a0ebec 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -12,6 +12,7 @@
 
 #include "cmConditionEvaluator.h"
 #include "cmOutputConverter.h"
+#include "cmAlgorithms.h"
 
 cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
                                            const cmListFileContext &context,
@@ -578,6 +579,7 @@
                   cmake::MessageType &status)
 {
   int reducible;
+  std::string def_buf;
   const char *def;
   const char *def2;
   do
@@ -594,6 +596,14 @@
         IsKeyword("MATCHES", *argP1))
         {
         def = this->GetVariableOrString(*arg);
+        if (def != arg->c_str() // yes, we compare the pointer value
+            && cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_"))
+          {
+          // The string to match is owned by our match result variables.
+          // Move it to our own buffer before clearing them.
+          def_buf = def;
+          def = def_buf.c_str();
+          }
         const char* rex = argP2->c_str();
         this->Makefile.ClearMatches();
         cmsys::RegularExpression regEntry;
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index ad0c7d3..4f3d890 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -12,6 +12,11 @@
 #include "cmCurl.h"
 #include "cmSystemTools.h"
 
+// curl versions before 7.21.5 did not provide this error code
+#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x071505
+# define CURLE_NOT_BUILT_IN 4
+#endif
+
 #define check_curl_result(result, errstr)                               \
   if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN)               \
     {                                                                   \
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index e8a2e6a..c005995 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -772,6 +772,27 @@
     lastPos = endPos;
     }
 
+  pos = 0;
+  lastPos = pos;
+  while (errorString.empty() &&
+         (pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos)
+    {
+    std::string::size_type nameStartPos = pos + sizeof("$<LINK_ONLY:") - 1;
+    std::string::size_type endPos = input.find(">", nameStartPos);
+    if (endPos == input.npos)
+      {
+      errorString = "$<LINK_ONLY:...> expression incomplete";
+      break;
+      }
+    std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
+    if (cmGeneratorExpression::IsValidTargetName(libName) &&
+        this->AddTargetNamespace(libName, target, missingTargets))
+      {
+      input.replace(nameStartPos, endPos - nameStartPos, libName);
+      }
+    lastPos = nameStartPos + libName.size() + 1;
+    }
+
   this->ReplaceInstallPrefix(input);
 
   if (!errorString.empty())
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index b695904..71418e8 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -496,7 +496,7 @@
     bool containsTarget = false;
     for(unsigned int i=0; i<targets->size(); i++)
       {
-      if (name == (*targets)[i]->Target->GetName())
+      if (name == (*targets)[i]->TargetName)
         {
         containsTarget = true;
         break;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index b05fb41..ff12320 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -335,7 +335,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmGeneratorTarget::GetName() const
+const std::string& cmGeneratorTarget::GetName() const
 {
   return this->Target->GetName();
 }
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index bd23477..d96a32c 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -55,7 +55,7 @@
     GetLinkInformation(const std::string& config) const;
 
   cmState::TargetType GetType() const;
-  std::string GetName() const;
+  const std::string& GetName() const;
   std::string GetExportName() const;
 
   std::vector<std::string> GetPropertyKeys() const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2126c71..848028f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -86,6 +86,13 @@
   this->TryCompileOuterMakefile = 0;
 
   this->ConfigureDoneCMP0026AndCMP0024 = false;
+
+  cm->GetState()->SetMinGWMake(false);
+  cm->GetState()->SetMSYSShell(false);
+  cm->GetState()->SetNMake(false);
+  cm->GetState()->SetWatcomWMake(false);
+  cm->GetState()->SetWindowsShell(false);
+  cm->GetState()->SetWindowsVSIDE(false);
 }
 
 cmGlobalGenerator::~cmGlobalGenerator()
@@ -1649,6 +1656,8 @@
 
   this->ExportSets.clear();
   this->TargetDependencies.clear();
+  this->TargetSearchIndex.clear();
+  this->GeneratorTargetSearchIndex.clear();
   this->ProjectMap.clear();
   this->RuleHashes.clear();
   this->DirectoryContentMap.clear();
@@ -1850,7 +1859,7 @@
       !makeCommand.empty() && cmSystemTools::LowerCase(
         cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe")
     {
-    outputflag = cmSystemTools::OUTPUT_NORMAL;
+    outputflag = cmSystemTools::OUTPUT_FORWARD;
     }
 
   // should we do a clean first?
@@ -2177,18 +2186,28 @@
   return this->AliasTargets.find(name) != this->AliasTargets.end();
 }
 
+void cmGlobalGenerator::IndexTarget(cmTarget* t)
+{
+  if (!t->IsImported() || t->IsImportedGloballyVisible())
+    {
+    this->TargetSearchIndex[t->GetName()] = t;
+    }
+}
+
+void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt)
+{
+  if (!gt->IsImported() || gt->IsImportedGloballyVisible())
+    {
+    this->GeneratorTargetSearchIndex[gt->GetName()] = gt;
+    }
+}
+
 cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
 {
-  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+  TargetMap::const_iterator i = this->TargetSearchIndex.find(name);
+  if (i != this->TargetSearchIndex.end())
     {
-    cmTargets& tgts = this->Makefiles[i]->GetTargets();
-    for (cmTargets::iterator it = tgts.begin(); it != tgts.end(); ++it)
-      {
-      if (it->second.GetName() == name)
-        {
-        return &it->second;
-        }
-      }
+    return i->second;
     }
   return 0;
 }
@@ -2196,56 +2215,11 @@
 cmGeneratorTarget*
 cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
 {
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
+  GeneratorTargetMap::const_iterator i =
+    this->GeneratorTargetSearchIndex.find(name);
+  if (i != this->GeneratorTargetSearchIndex.end())
     {
-    std::vector<cmGeneratorTarget*> tgts =
-        this->LocalGenerators[i]->GetGeneratorTargets();
-    for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
-         it != tgts.end(); ++it)
-      {
-      if ((*it)->GetName() == name)
-        {
-        return *it;
-        }
-      }
-    }
-  return 0;
-}
-
-cmTarget*
-cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
-{
-  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
-    {
-    std::vector<cmTarget*> tgts =
-        this->Makefiles[i]->GetOwnedImportedTargets();
-    for (std::vector<cmTarget*>::iterator it = tgts.begin();
-         it != tgts.end(); ++it)
-      {
-      if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
-        {
-        return *it;
-        }
-      }
-    }
-  return 0;
-}
-
-cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
-    std::string const& name) const
-{
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    std::vector<cmGeneratorTarget*> tgts =
-        this->LocalGenerators[i]->GetImportedGeneratorTargets();
-    for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
-         it != tgts.end(); ++it)
-      {
-      if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name)
-        {
-        return *it;
-        }
-      }
+    return i->second;
     }
   return 0;
 }
@@ -2264,11 +2238,7 @@
       return this->FindTargetImpl(ai->second);
       }
     }
-  if (cmTarget* tgt = this->FindTargetImpl(name))
-    {
-    return tgt;
-    }
-  return this->FindImportedTargetImpl(name);
+  return this->FindTargetImpl(name);
 }
 
 cmGeneratorTarget*
@@ -2280,11 +2250,7 @@
     {
     return this->FindGeneratorTargetImpl(ai->second);
     }
-  if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
-    {
-    return tgt;
-    }
-  return this->FindImportedGeneratorTargetImpl(name);
+  return this->FindGeneratorTargetImpl(name);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index bc6e17d..48fa704 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -278,6 +278,9 @@
   std::set<std::string> const& GetDirectoryContent(std::string const& dir,
                                                    bool needDisk = true);
 
+  void IndexTarget(cmTarget* t);
+  void IndexGeneratorTarget(cmGeneratorTarget* gt);
+
   static bool IsReservedTarget(std::string const& name);
 
   virtual const char* GetAllTargetName()         const { return "ALL_BUILD"; }
@@ -420,7 +423,6 @@
   std::map<std::string, std::string> AliasTargets;
 
   cmTarget* FindTargetImpl(std::string const& name) const;
-  cmTarget* FindImportedTargetImpl(std::string const& name) const;
 
   cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
   cmGeneratorTarget*
@@ -430,6 +432,26 @@
   virtual bool UseFolderProperty();
 
 private:
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+  typedef std::unordered_map<std::string, cmTarget*> TargetMap;
+  typedef std::unordered_map<std::string, cmGeneratorTarget*>
+    GeneratorTargetMap;
+# else
+  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+  typedef cmsys::hash_map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
+# endif
+#else
+  typedef std::map<std::string,cmTarget *> TargetMap;
+  typedef std::map<std::string,cmGeneratorTarget *> GeneratorTargetMap;
+#endif
+  // Map efficiently from target name to cmTarget instance.
+  // Do not use this structure for looping over all targets.
+  // It contains both normal and globally visible imported targets.
+  TargetMap TargetSearchIndex;
+  GeneratorTargetMap GeneratorTargetSearchIndex;
+
   cmMakefile* TryCompileOuterMakefile;
   // If you add a new map here, make sure it is copied
   // in EnableLanguagesFromGenerator
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index f151d80..c058f8c 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -117,7 +117,7 @@
 {
   if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
     {
-    return this->SelectWindows10SDK(mf);
+    return this->SelectWindows10SDK(mf, false);
     }
   return true;
 }
@@ -145,17 +145,18 @@
     }
   if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
     {
-    return this->SelectWindows10SDK(mf);
+    return this->SelectWindows10SDK(mf, true);
     }
   return true;
 }
 
 //----------------------------------------------------------------------------
-bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf)
+bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
+                                                         bool required)
 {
   // Find the default version of the Windows 10 SDK.
   this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
-  if (this->WindowsTargetPlatformVersion.empty())
+  if (required && this->WindowsTargetPlatformVersion.empty())
     {
     std::ostringstream  e;
     e << "Could not find an appropriate version of the Windows 10 SDK"
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 76c15d9..57e6284 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -39,7 +39,7 @@
   bool IsWindowsStoreToolsetInstalled() const;
 
   virtual const char* GetIDEVersion() { return "14.0"; }
-  virtual bool SelectWindows10SDK(cmMakefile* mf);
+  virtual bool SelectWindows10SDK(cmMakefile* mf, bool required);
 
   // Used to verify that the Desktop toolset for the current generator is
   // installed on the machine.
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 15a83ee..2d78a41 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -1374,10 +1374,12 @@
         tei != exportSet->GetTargetExports()->end(); ++tei)
       {
       cmTargetExport const* te = *tei;
-      cmTarget* tgt = this->Makefile->FindTarget(te->TargetName);
+      cmTarget* tgt =
+        this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
       const bool newCMP0022Behavior =
-                      tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN
-                   && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+        (tgt &&
+         tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+         tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
 
       if(!newCMP0022Behavior)
         {
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 1158a27..5e88fa2 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -791,18 +791,10 @@
       }
 
     // Write a rule to run chrpath to set the install-tree RPATH
-    if(newRpath.empty())
-      {
-      os << indent << "file(RPATH_REMOVE\n"
-         << indent << "     FILE \"" << toDestDirPath << "\")\n";
-      }
-    else
-      {
-      os << indent << "file(RPATH_CHANGE\n"
-         << indent << "     FILE \"" << toDestDirPath << "\"\n"
-         << indent << "     OLD_RPATH \"" << oldRpath << "\"\n"
-         << indent << "     NEW_RPATH \"" << newRpath << "\")\n";
-      }
+    os << indent << "file(RPATH_CHANGE\n"
+       << indent << "     FILE \"" << toDestDirPath << "\"\n"
+       << indent << "     OLD_RPATH \"" << oldRpath << "\"\n"
+       << indent << "     NEW_RPATH \"" << newRpath << "\")\n";
     }
 }
 
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1d17032..912be0c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -455,11 +455,13 @@
 void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
 {
   this->GeneratorTargets.push_back(gt);
+  this->GlobalGenerator->IndexGeneratorTarget(gt);
 }
 
 void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
 {
   this->ImportedGeneratorTargets.push_back(gt);
+  this->GlobalGenerator->IndexGeneratorTarget(gt);
 }
 
 void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt)
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index e4026b0..71de7a7 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -146,16 +146,14 @@
         // replace formal arguments
         for (unsigned int j = 0; j < variables.size(); ++j)
           {
-          cmSystemTools::ReplaceString(arg.Value, variables[j].c_str(),
-                                       expandedArgs[j].c_str());
+          cmSystemTools::ReplaceString(arg.Value, variables[j],
+                                       expandedArgs[j]);
           }
         // replace argc
-        cmSystemTools::ReplaceString(arg.Value, "${ARGC}",argcDef.c_str());
+        cmSystemTools::ReplaceString(arg.Value, "${ARGC}", argcDef);
 
-        cmSystemTools::ReplaceString(arg.Value, "${ARGN}",
-                                     expandedArgn.c_str());
-        cmSystemTools::ReplaceString(arg.Value, "${ARGV}",
-                                     expandedArgv.c_str());
+        cmSystemTools::ReplaceString(arg.Value, "${ARGN}", expandedArgn);
+        cmSystemTools::ReplaceString(arg.Value, "${ARGV}", expandedArgv);
 
         // if the current argument of the current function has ${ARGV in it
         // then try replacing ARGV values
@@ -163,8 +161,8 @@
           {
           for (unsigned int t = 0; t < expandedArgs.size(); ++t)
             {
-            cmSystemTools::ReplaceString(arg.Value, argVs[t].c_str(),
-                                         expandedArgs[t].c_str());
+            cmSystemTools::ReplaceString(arg.Value, argVs[t],
+                                         expandedArgs[t]);
             }
           }
         }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1b0a99a..950b247 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -791,7 +791,24 @@
 
     if(issueMessage)
       {
-      e << "The target name \"" << target << "\" is unknown in this context.";
+      if (cmTarget const* t = this->FindTargetToUse(target))
+        {
+        if (t->IsImported())
+          {
+          e << "TARGET '" << target
+            << "' is IMPORTED and does not build here.";
+          }
+        else
+          {
+          e << "TARGET '" << target
+            << "' was not created in this directory.";
+          }
+        }
+      else
+        {
+        e << "No TARGET '" << target
+          << "' has been created in this directory.";
+        }
       IssueMessage(messageType, e.str());
       }
 
@@ -2111,6 +2128,7 @@
   cmTarget& target = it->second;
   target.SetType(type, name);
   target.SetMakefile(this);
+  this->GetGlobalGenerator()->IndexTarget(&it->second);
   return &it->second;
 }
 
@@ -2832,10 +2850,9 @@
   const char* last = in;
   std::string result;
   result.reserve(source.size());
-  std::stack<t_lookup> openstack;
+  std::vector<t_lookup> openstack;
   bool error = false;
   bool done = false;
-  openstack.push(t_lookup());
   cmake::MessageType mtype = cmake::LOG;
 
   cmState* state = this->GetCMakeInstance()->GetState();
@@ -2846,10 +2863,10 @@
     switch(inc)
       {
       case '}':
-        if(openstack.size() > 1)
+        if(!openstack.empty())
           {
-          t_lookup var = openstack.top();
-          openstack.pop();
+          t_lookup var = openstack.back();
+          openstack.pop_back();
           result.append(last, in - last);
           std::string const& lookup = result.substr(var.loc);
           const char* value = NULL;
@@ -2970,7 +2987,7 @@
             last = start;
             in = start - 1;
             lookup.loc = result.size();
-            openstack.push(lookup);
+            openstack.push_back(lookup);
             }
           break;
           }
@@ -2997,7 +3014,7 @@
             result.append("\r");
             last = next + 1;
             }
-          else if(nextc == ';' && openstack.size() == 1)
+          else if(nextc == ';' && openstack.empty())
             {
             // Handled in ExpandListArgument; pass the backslash literally.
             }
@@ -3065,7 +3082,7 @@
         /* FALLTHROUGH */
       default:
         {
-        if(openstack.size() > 1 &&
+        if(!openstack.empty() &&
            !(isalnum(inc) || inc == '_' ||
              inc == '/' || inc == '.' ||
              inc == '+' || inc == '-'))
@@ -3074,7 +3091,7 @@
           errorstr += inc;
           result.append(last, in - last);
           errorstr += "\') in a variable name: "
-                      "'" + result.substr(openstack.top().loc) + "'";
+                      "'" + result.substr(openstack.back().loc) + "'";
           mtype = cmake::FATAL_ERROR;
           error = true;
           }
@@ -3085,7 +3102,7 @@
     } while(!error && !done && *++in);
 
   // Check for open variable references yet.
-  if(!error && openstack.size() != 1)
+  if(!error && !openstack.empty())
     {
     // There's an open variable reference waiting.  Policy CMP0010 flags
     // whether this is an error or not.  The new parser now enforces
@@ -4202,6 +4219,7 @@
 
   // Add to the set of available imported targets.
   this->ImportedTargets[name] = target.get();
+  this->GetGlobalGenerator()->IndexTarget(target.get());
 
   // Transfer ownership to this cmMakefile object.
   this->ImportedTargetsOwned.push_back(target.get());
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index a861965..ca76c88 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -97,10 +97,18 @@
   } insideValues = NONE;
   std::string currentArgName;
 
-  // now iterate over the remaining arguments
-  // and fill in the values where applicable
+  // Flatten ;-lists in the arguments into a single list as was done
+  // by the original function(CMAKE_PARSE_ARGUMENTS).
+  list.clear();
   for(; argIter != argEnd; ++argIter)
     {
+    cmSystemTools::ExpandListArgument(*argIter, list);
+    }
+
+  // iterate over the arguments list and fill in the values where applicable
+  for (argIter = list.begin(), argEnd = list.end();
+       argIter != argEnd; ++argIter)
+    {
     const options_map::iterator optIter = options.find(*argIter);
     if (optIter != options.end())
       {
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 008272c..3ba7287 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -17,6 +17,7 @@
 #include <time.h>
 #include <string.h>
 #include <stdlib.h>
+#include <assert.h>
 #ifdef __QNX__
 # include <malloc.h> /* for malloc/free on QNX */
 #endif
@@ -660,14 +661,6 @@
     argv.push_back(a->c_str());
     }
   argv.push_back(0);
-  if ( captureStdOut )
-    {
-    *captureStdOut = "";
-    }
-  if (captureStdErr && captureStdErr != captureStdOut)
-    {
-    *captureStdErr = "";
-    }
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetCommand(cp, &*argv.begin());
@@ -681,7 +674,16 @@
     {
     cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
     cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
+    captureStdOut = 0;
+    captureStdErr = 0;
     }
+  else if (outputflag == OUTPUT_MERGE ||
+           (captureStdErr && captureStdErr == captureStdOut))
+    {
+    cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
+    captureStdErr = 0;
+    }
+  assert(!captureStdErr || captureStdErr != captureStdOut);
 
   cmsysProcess_SetTimeout(cp, timeout);
   cmsysProcess_Execute(cp);
@@ -696,65 +698,50 @@
     {
     while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0)
       {
-      if(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)
+      // Translate NULL characters in the output into valid text.
+      // Visual Studio 7 puts these characters in the output of its
+      // build process.
+      for(int i=0; i < length; ++i)
         {
-        // Translate NULL characters in the output into valid text.
-        // Visual Studio 7 puts these characters in the output of its
-        // build process.
-        for(int i=0; i < length; ++i)
+        if(data[i] == '\0')
           {
-          if(data[i] == '\0')
-            {
-            data[i] = ' ';
-            }
+          data[i] = ' ';
           }
         }
-      if(pipe == cmsysProcess_Pipe_STDOUT ||
-         (pipe == cmsysProcess_Pipe_STDERR &&
-          captureStdOut == captureStdErr))
+
+      if (pipe == cmsysProcess_Pipe_STDOUT)
         {
+        if (outputflag != OUTPUT_NONE)
+          {
+          cmSystemTools::Stdout(data, length);
+          }
         if (captureStdOut)
           {
           tempStdOut.insert(tempStdOut.end(), data, data+length);
           }
         }
-      else if(pipe == cmsysProcess_Pipe_STDERR)
+      else if (pipe == cmsysProcess_Pipe_STDERR)
         {
+        if (outputflag != OUTPUT_NONE)
+          {
+          cmSystemTools::Stderr(data, length);
+          }
         if (captureStdErr)
           {
           tempStdErr.insert(tempStdErr.end(), data, data+length);
           }
         }
-      if(outputflag != OUTPUT_NONE)
-        {
-        if(outputflag == OUTPUT_MERGE)
-          {
-          cmSystemTools::Stdout(data, length);
-          }
-        else
-          {
-          if(pipe == cmsysProcess_Pipe_STDERR)
-            {
-            cmSystemTools::Stderr(data, length);
-            }
-          else if(pipe == cmsysProcess_Pipe_STDOUT)
-            {
-            cmSystemTools::Stdout(data, length);
-            }
-          }
-        }
       }
     }
 
   cmsysProcess_WaitForExit(cp, 0);
-  if ( captureStdOut && tempStdOut.begin() != tempStdOut.end())
+  if (captureStdOut)
     {
-    captureStdOut->append(&*tempStdOut.begin(), tempStdOut.size());
+    captureStdOut->assign(tempStdOut.begin(), tempStdOut.end());
     }
-  if ( captureStdErr && captureStdErr != captureStdOut &&
-       tempStdErr.begin() != tempStdErr.end())
+  if (captureStdErr)
     {
-    captureStdErr->append(&*tempStdErr.begin(), tempStdErr.size());
+    captureStdErr->assign(tempStdErr.begin(), tempStdErr.end());
     }
 
   bool result = true;
@@ -2565,6 +2552,7 @@
     *changed = false;
     }
   int rp_count = 0;
+  bool remove_rpath = true;
   cmSystemToolsRPathInfo rp[2];
   {
   // Parse the ELF binary.
@@ -2622,6 +2610,7 @@
       // If it contains the new rpath instead then it is okay.
       if(cmSystemToolsFindRPath(se[i]->Value, newRPath) != std::string::npos)
         {
+        remove_rpath = false;
         continue;
         }
       if(emsg)
@@ -2642,13 +2631,30 @@
     rp[rp_count].Size = se[i]->Size;
     rp[rp_count].Name = se_name[i];
 
+    std::string::size_type prefix_len = pos;
+
+    // If oldRPath was at the end of the file's RPath, and newRPath is empty,
+    // we should remove the unnecessary ':' at the end.
+    if (newRPath.empty() &&
+        pos > 0 &&
+        se[i]->Value[pos - 1] == ':' &&
+        pos + oldRPath.length() == se[i]->Value.length())
+      {
+      prefix_len--;
+      }
+
     // Construct the new value which preserves the part of the path
     // not being changed.
-    rp[rp_count].Value = se[i]->Value.substr(0, pos);
+    rp[rp_count].Value = se[i]->Value.substr(0, prefix_len);
     rp[rp_count].Value += newRPath;
     rp[rp_count].Value += se[i]->Value.substr(pos+oldRPath.length(),
                                               oldRPath.npos);
 
+    if (!rp[rp_count].Value.empty())
+      {
+      remove_rpath = false;
+      }
+
     // Make sure there is enough room to store the new rpath and at
     // least one null terminator.
     if(rp[rp_count].Size < rp[rp_count].Value.length()+1)
@@ -2673,6 +2679,12 @@
     return true;
     }
 
+  // If the resulting rpath is empty, just remove the entire entry instead.
+  if (remove_rpath)
+    {
+    return cmSystemTools::RemoveRPath(file, emsg, changed);
+    }
+
   {
   // Open the file for update.
   cmsys::ofstream f(file.c_str(),
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 9cafbec..f511ae4 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -203,7 +203,7 @@
    * Output is controlled with outputflag. If outputflag is OUTPUT_NONE, no
    * user-viewable output from the program being run will be generated.
    * OUTPUT_MERGE is the legacy behaviour where stdout and stderr are merged
-   * into stdout.  OUTPUT_NORMAL passes through the output to stdout/stderr as
+   * into stdout.  OUTPUT_FORWARD copies the output to stdout/stderr as
    * it was received.  OUTPUT_PASSTHROUGH passes through the original handles.
    *
    * If timeout is specified, the command will be terminated after
@@ -223,7 +223,7 @@
    {
      OUTPUT_NONE = 0,
      OUTPUT_MERGE,
-     OUTPUT_NORMAL,
+     OUTPUT_FORWARD,
      OUTPUT_PASSTHROUGH
    };
   static bool RunSingleCommand(const char* command,
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 27ae685..09d4a90 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -762,13 +762,16 @@
   std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
 
   std::string useOfMfcValue = "false";
-  if(mfcFlagValue == "1")
+  if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
     {
-    useOfMfcValue = "Static";
-    }
-  else if(mfcFlagValue == "2")
-    {
-    useOfMfcValue = "Dynamic";
+    if(mfcFlagValue == "1")
+      {
+      useOfMfcValue = "Static";
+      }
+    else if(mfcFlagValue == "2")
+      {
+      useOfMfcValue = "Dynamic";
+      }
     }
   std::string mfcLine = "<UseOfMfc>";
   mfcLine += useOfMfcValue + "</UseOfMfc>\n";
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index fb7b1f5..e9d77b2 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -361,11 +361,10 @@
         }
 
       // Now run the real compiler command and return its result value.
-      if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, &stdErr, &ret, 0,
+      if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, 0, &ret, 0,
                                           cmSystemTools::OUTPUT_PASSTHROUGH))
         {
-        std::cerr << "Error running '" << orig_cmd[0] << "': "
-                  << stdErr << "\n";
+        std::cerr << "Error running '" << orig_cmd[0] << "'\n";
         return 1;
         }
       return ret;
@@ -555,7 +554,7 @@
     // Clock command
     else if (args[1] == "time" && args.size() > 2)
       {
-      std::string command = cmJoin(cmMakeRange(args).advance(2), " ");
+      std::vector<std::string> command(args.begin()+2, args.end());
 
       clock_t clock_start, clock_finish;
       time_t time_start, time_finish;
@@ -563,7 +562,7 @@
       time(&time_start);
       clock_start = clock();
       int ret =0;
-      cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &ret);
+      cmSystemTools::RunSingleCommand(command, 0, 0, &ret);
 
       clock_finish = clock();
       time(&time_finish);
@@ -621,7 +620,7 @@
       int retval = 0;
       int timeout = 0;
       if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval,
-             directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) )
+             directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, timeout) )
         {
         return retval;
         }
@@ -814,10 +813,8 @@
         {
         cm.SetGlobalGenerator(ggd);
         cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
-        snapshot.GetDirectory().SetCurrentBinary
-          (cmSystemTools::GetCurrentWorkingDirectory());
-        snapshot.GetDirectory().SetCurrentSource
-          (cmSystemTools::GetCurrentWorkingDirectory());
+        snapshot.GetDirectory().SetCurrentBinary(startOutDir);
+        snapshot.GetDirectory().SetCurrentSource(startDir);
         cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
         cmsys::auto_ptr<cmLocalGenerator> lgd(
               ggd->CreateLocalGenerator(mf.get()));
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 043b757..7bb0721 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1375,10 +1375,18 @@
     add_subdirectory(FindOpenSSL)
   endif()
 
+  if(CMake_TEST_FindPNG)
+    add_subdirectory(FindPNG)
+  endif()
+
   if(CMake_TEST_FindTIFF)
     add_subdirectory(FindTIFF)
   endif()
 
+  if(CMake_TEST_FindXalanC)
+    add_subdirectory(FindXalanC)
+  endif()
+
   if(CMake_TEST_FindXercesC)
     add_subdirectory(FindXercesC)
   endif()
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index dcba9ac..c2ecb0b 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -130,10 +130,15 @@
 add_library(testLibNoSONAME SHARED testLibNoSONAME.c)
 set_property(TARGET testLibNoSONAME PROPERTY NO_SONAME 1)
 
+cmake_policy(PUSH)
+cmake_policy(SET CMP0022 NEW)
 # Test exporting dependent libraries into different exports
 add_library(testLibRequired testLibRequired.c)
 add_library(testLibDepends testLibDepends.c)
 target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired)
+add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c)
+target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate)
+cmake_policy(POP)
 
 macro(add_include_lib _libName)
   file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "/* no content */\n")
@@ -270,6 +275,7 @@
     DESTINATION include/testSharedLibRequiredUser
 )
 
+cmake_policy(PUSH)
 cmake_policy(SET CMP0022 NEW)
 add_library(testSharedLibRequiredUser2 SHARED testSharedLibRequiredUser2.cpp)
 generate_export_header(testSharedLibRequiredUser2)
@@ -283,7 +289,7 @@
   "${CMAKE_CURRENT_BINARY_DIR}/testsharedlibrequireduser2_export.h"
     DESTINATION include/testSharedLibRequiredUser2
 )
-cmake_policy(SET CMP0022 OLD)
+cmake_policy(POP)
 
 add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp)
 set_property(TARGET testSharedLibDepends APPEND PROPERTY
@@ -311,6 +317,8 @@
 target_link_libraries(testSharedLibDepends LINK_INTERFACE_LIBRARIES
   $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:$<TARGET_NAME:testSharedLibRequired>>)
 
+cmake_policy(PUSH)
+cmake_policy(SET CMP0022 OLD)
 add_library(cmp0022OLD SHARED cmp0022_vs6_1.cpp)
 generate_export_header(cmp0022OLD BASE_NAME cmp0022)
 target_include_directories(cmp0022OLD PUBLIC
@@ -324,7 +332,7 @@
   "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
   "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/cmp0022>"
 )
-cmake_policy(SET CMP0022 OLD)
+cmake_policy(POP)
 install(FILES
   "${CMAKE_CURRENT_SOURCE_DIR}/cmp0022.h"
   "${CMAKE_CURRENT_BINARY_DIR}/cmp0022_export.h"
@@ -388,6 +396,10 @@
         INCLUDES DESTINATION
           $<INSTALL_PREFIX>/include/$<TARGET_PROPERTY:NAME>
 )
+install(TARGETS
+          testStaticLibRequiredPrivate
+        EXPORT RequiredExp DESTINATION lib
+)
 install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired)
 
 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest")
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
index fb5a002..3c7774ee 100644
--- a/Tests/ExportImport/Export/testLibDepends.c
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -16,5 +16,10 @@
 #endif
 
 extern int testLibRequired(void);
+extern int testStaticLibRequiredPrivate(void);
 
-int testLibDepends(void) { return testLibRequired(); }
+int testLibDepends(void) {
+  return testLibRequired()
+    + testStaticLibRequiredPrivate()
+    ;
+}
diff --git a/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c b/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
new file mode 100644
index 0000000..28a2675
--- /dev/null
+++ b/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
@@ -0,0 +1 @@
+int testStaticLibRequiredPrivate(void) { return 0; }
diff --git a/Tests/FindPNG/CMakeLists.txt b/Tests/FindPNG/CMakeLists.txt
new file mode 100644
index 0000000..c665b67
--- /dev/null
+++ b/Tests/FindPNG/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindPNG.Test COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/FindPNG/Test"
+  "${CMake_BINARY_DIR}/Tests/FindPNG/Test"
+  ${build_generator_args}
+  --build-project TestFindPNG
+  --build-options ${build_options}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/FindPNG/Test/CMakeLists.txt b/Tests/FindPNG/Test/CMakeLists.txt
new file mode 100644
index 0000000..ad50011
--- /dev/null
+++ b/Tests/FindPNG/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindPNG C)
+include(CTest)
+
+find_package(PNG REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_PNG_VERSION="${PNG_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt PNG::PNG)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${PNG_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${PNG_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindPNG/Test/main.c b/Tests/FindPNG/Test/main.c
new file mode 100644
index 0000000..27e1478
--- /dev/null
+++ b/Tests/FindPNG/Test/main.c
@@ -0,0 +1,20 @@
+#include <assert.h>
+#include <string.h>
+#include <png.h>
+
+int main()
+{
+  png_uint_32 png_version;
+  char png_version_string[16];
+
+  png_version = png_access_version_number ();
+
+  snprintf (png_version_string, 16, "%i.%i.%i",
+            png_version / 10000,
+            (png_version % 10000) / 100,
+            png_version % 100);
+
+  assert (strcmp(png_version_string, CMAKE_EXPECTED_PNG_VERSION) == 0);
+
+  return 0;
+}
diff --git a/Tests/FindXalanC/CMakeLists.txt b/Tests/FindXalanC/CMakeLists.txt
new file mode 100644
index 0000000..7872929
--- /dev/null
+++ b/Tests/FindXalanC/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindXalanC.Test COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/FindXalanC/Test"
+  "${CMake_BINARY_DIR}/Tests/FindXalanC/Test"
+  ${build_generator_args}
+  --build-project TestFindXalanC
+  --build-options ${build_options}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/FindXalanC/Test/CMakeLists.txt b/Tests/FindXalanC/Test/CMakeLists.txt
new file mode 100644
index 0000000..b445e0e
--- /dev/null
+++ b/Tests/FindXalanC/Test/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindXalanC CXX)
+include(CTest)
+
+# CMake does not actually provide FindXalanC publicly.
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/Modules)
+
+find_package(XalanC REQUIRED)
+
+add_executable(test_xalanc_tgt main.cxx)
+target_link_libraries(test_xalanc_tgt XalanC::XalanC)
+add_test(NAME test_xalanc_tgt COMMAND test_xalanc_tgt)
+
+add_executable(test_xalanc_var main.cxx)
+target_include_directories(test_xalanc_var PRIVATE ${XalanC_INCLUDE_DIRS})
+target_link_libraries(test_xalanc_var PRIVATE ${XalanC_LIBRARIES})
+add_test(NAME test_xalanc_var COMMAND test_xalanc_var)
diff --git a/Tests/FindXalanC/Test/main.cxx b/Tests/FindXalanC/Test/main.cxx
new file mode 100644
index 0000000..3b4a2df
--- /dev/null
+++ b/Tests/FindXalanC/Test/main.cxx
@@ -0,0 +1,10 @@
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xalanc/XalanTransformer/XalanTransformer.hpp>
+
+int main()
+{
+  xercesc::XMLPlatformUtils::Initialize();
+  xalanc::XalanTransformer::initialize();
+  xalanc::XalanTransformer::terminate();
+  xercesc::XMLPlatformUtils::Terminate();
+}
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index 753ce27..ecf38a6 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -223,5 +223,6 @@
   endif()
 
   add_subdirectory(Library)
+  add_subdirectory(Subdir)
   add_subdirectory(Executable)
 endif()
diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt
index 55f21ad..de08d86 100644
--- a/Tests/Fortran/Executable/CMakeLists.txt
+++ b/Tests/Fortran/Executable/CMakeLists.txt
@@ -3,6 +3,6 @@
 link_directories(${External_BINARY_DIR})
 
 add_executable(subdir_exe2 main.f90)
-target_link_libraries(subdir_exe2 subdir_mods)
+target_link_libraries(subdir_exe2 subdir_mods subdir_mods2)
 add_dependencies(subdir_exe2 ExternalTarget)
 target_link_libraries(subdir_exe2 myext)
diff --git a/Tests/Fortran/Executable/main.f90 b/Tests/Fortran/Executable/main.f90
index f21156c..640259c 100644
--- a/Tests/Fortran/Executable/main.f90
+++ b/Tests/Fortran/Executable/main.f90
@@ -1,6 +1,7 @@
 PROGRAM MAINF90
   USE libraryModuleA
   USE libraryModuleB
+  USE subdirModuleA
   USE externalMod
   CALL printExtModGreeting
 END PROGRAM MAINF90
diff --git a/Tests/Fortran/Subdir/CMakeLists.txt b/Tests/Fortran/Subdir/CMakeLists.txt
new file mode 100644
index 0000000..52683e5
--- /dev/null
+++ b/Tests/Fortran/Subdir/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(subdir_mods2 subdir.f90)
+target_include_directories(subdir_mods2 INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/Tests/Fortran/Subdir/subdir.f90 b/Tests/Fortran/Subdir/subdir.f90
new file mode 100644
index 0000000..68955f6
--- /dev/null
+++ b/Tests/Fortran/Subdir/subdir.f90
@@ -0,0 +1,2 @@
+MODULE subdirModuleA
+END MODULE
diff --git a/Tests/JavaJavah/C.cpp b/Tests/JavaJavah/C.cpp
new file mode 100644
index 0000000..ec75f42
--- /dev/null
+++ b/Tests/JavaJavah/C.cpp
@@ -0,0 +1,10 @@
+
+#include <jni.h>
+#include <stdio.h>
+
+#include "C.h"
+
+JNIEXPORT void JNICALL Java_C_printName(JNIEnv *, jobject)
+{
+  printf("C\n");
+}
diff --git a/Tests/JavaJavah/C.java b/Tests/JavaJavah/C.java
new file mode 100644
index 0000000..54b1be2
--- /dev/null
+++ b/Tests/JavaJavah/C.java
@@ -0,0 +1,19 @@
+class C
+{
+  public C()
+    {
+    }
+
+    public native void printName();
+
+    static {
+        try {
+
+            System.loadLibrary("B");
+
+        } catch (UnsatisfiedLinkError e) {
+            System.err.println("Native code library failed to load.\n" + e);
+            System.exit(1);
+        }
+    }
+}
diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt
index 83b0ad0..071bf20 100644
--- a/Tests/JavaJavah/CMakeLists.txt
+++ b/Tests/JavaJavah/CMakeLists.txt
@@ -9,10 +9,13 @@
 # JNI support
 find_package(JNI)
 
-add_jar(hello3 B.java HelloWorld2.java)
-create_javah(TARGET B_javah CLASSES B CLASSPATH hello3)
+add_jar(B1 B.java)
+add_jar(C1 C.java)
+create_javah(TARGET B_javah CLASSES B C CLASSPATH B1 C1)
 
-add_library(B SHARED B.cpp)
+add_jar(hello3 HelloWorld2.java)
+
+add_library(B SHARED B.cpp C.cpp)
 add_dependencies(B B_javah)
 
 target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java
index faf7277..5ff710f 100644
--- a/Tests/JavaJavah/HelloWorld2.java
+++ b/Tests/JavaJavah/HelloWorld2.java
@@ -5,6 +5,11 @@
         B b;
         b = new B();
         b.printName();
+
+        C c;
+        c = new C();
+        c.printName();
+
         System.out.println("Hello World!");
     }
 }
diff --git a/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt
index 3f82d8c..4a1077c 100644
--- a/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt
+++ b/Tests/RunCMake/CMP0040/CMP0040-NEW-missing-target-stderr.txt
@@ -1,4 +1,4 @@
 CMake Error at CMP0040-NEW-missing-target.cmake:3 \(add_custom_command\):
-  The target name "foobar" is unknown in this context.
+  No TARGET 'foobar' has been created in this directory.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt
index e791f0a..e3e3ff4 100644
--- a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt
+++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt
@@ -4,7 +4,7 @@
   policy details.  Use the cmake_policy command to set the policy and
   suppress this warning.
 +
-  The target name "foobar" is unknown in this context.
+  No TARGET 'foobar' has been created in this directory.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
 This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CommandLine/E_time-no-arg-result.txt b/Tests/RunCMake/CommandLine/E_time-no-arg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_time-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_time-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/E_time-no-arg-stderr.txt
new file mode 100644
index 0000000..50d9b03
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_time-no-arg-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Error: cmake version .*
+Usage: .* -E <command> \[arguments\.\.\.\]
+Available commands:
diff --git a/Tests/RunCMake/CommandLine/E_time-stdout.txt b/Tests/RunCMake/CommandLine/E_time-stdout.txt
new file mode 100644
index 0000000..a51446a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_time-stdout.txt
@@ -0,0 +1,3 @@
+^hello  world
+Elapsed time: [^
+]*$
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index e77ba1f..e3b73ff 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -12,6 +12,9 @@
 run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename)
 run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate)
 
+run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello  world")
+run_cmake_command(E_time-no-arg ${CMAKE_COMMAND} -E time)
+
 run_cmake_command(E___run_iwyu-no-iwyu ${CMAKE_COMMAND} -E __run_iwyu -- command-does-not-exist)
 run_cmake_command(E___run_iwyu-bad-iwyu ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist -- command-does-not-exist)
 run_cmake_command(E___run_iwyu-no--- ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist command-does-not-exist)
@@ -33,6 +36,11 @@
 run_cmake_command(build-bad-generator
   ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator)
 
+run_cmake_command(cache-bad-entry
+  ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-entry/)
+run_cmake_command(cache-empty-entry
+  ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/)
+
 function(run_BuildDir)
   # Use a single build tree for a few tests without cleaning.
   set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build)
diff --git a/Tests/RunCMake/CommandLine/cache-bad-entry-result.txt b/Tests/RunCMake/CommandLine/cache-bad-entry-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/cache-bad-entry-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/cache-bad-entry-stderr.txt b/Tests/RunCMake/CommandLine/cache-bad-entry-stderr.txt
new file mode 100644
index 0000000..150d2ca
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/cache-bad-entry-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Parse error in cache file .*/Tests/RunCMake/CommandLine/cache-bad-entry/CMakeCache.txt on line 7. Offending entry: BAD ENTRY.*
diff --git a/Tests/RunCMake/CommandLine/cache-bad-entry/CMakeCache.txt b/Tests/RunCMake/CommandLine/cache-bad-entry/CMakeCache.txt
new file mode 100644
index 0000000..75cd7c2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/cache-bad-entry/CMakeCache.txt
@@ -0,0 +1,10 @@
+# This is a comment
+
+// That was an empty line. This isn't.
+EMPTY_LINE:BOOL=FALSE
+
+// Uhoh! Here it comes
+BAD ENTRY
+
+// This is fine
+GOOD_ENTRY:BOOL=TRUE
diff --git a/Tests/RunCMake/CommandLine/cache-empty-entry-result.txt b/Tests/RunCMake/CommandLine/cache-empty-entry-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/cache-empty-entry-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/cache-empty-entry-stderr.txt b/Tests/RunCMake/CommandLine/cache-empty-entry-stderr.txt
new file mode 100644
index 0000000..54f4452
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/cache-empty-entry-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Parse error in cache file .*/Tests/RunCMake/CommandLine/cache-empty-entry/CMakeCache.txt on line 5. Offending entry:.*
diff --git a/Tests/RunCMake/CommandLine/cache-empty-entry/CMakeCache.txt b/Tests/RunCMake/CommandLine/cache-empty-entry/CMakeCache.txt
new file mode 100644
index 0000000..44da1c9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/cache-empty-entry/CMakeCache.txt
@@ -0,0 +1,7 @@
+// This is valid
+VALID:BOOL=TRUE
+
+// This isn't
+
+// One final entry
+FINAL:BOOL=TRUE
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake
new file mode 100644
index 0000000..8d8d000
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_cache_variables.cmake
@@ -0,0 +1,16 @@
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(NCURSES QUIET ncurses)
+
+if (NCURSES_FOUND)
+  foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR)
+    get_property("${variable}"
+      CACHE     "NCURSES_${variable}"
+      PROPERTY  TYPE
+      SET)
+    if (NOT ${variable})
+      message(FATAL_ERROR "Failed to set cache entry for NCURSES_${variable}")
+    endif ()
+  endforeach ()
+else ()
+  message(STATUS "skipping test; ncurses not found")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index bb04aa2..24089e0 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -14,4 +14,5 @@
 find_package(PkgConfig)
 if (PKG_CONFIG_FOUND)
   run_cmake(FindPkgConfig_GET_VARIABLE)
+  run_cmake(FindPkgConfig_cache_variables)
 endif ()
diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
index 2f5c938..397c63d 100644
--- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
@@ -8,3 +8,5 @@
 run_cmake(OutputAndTarget)
 run_cmake(SourceByproducts)
 run_cmake(SourceUsesTerminal)
+run_cmake(TargetImported)
+run_cmake(TargetNotInDir)
diff --git a/Tests/RunCMake/add_custom_command/TargetImported-result.txt b/Tests/RunCMake/add_custom_command/TargetImported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetImported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/TargetImported-stderr.txt b/Tests/RunCMake/add_custom_command/TargetImported-stderr.txt
new file mode 100644
index 0000000..44c4ad8
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetImported-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TargetImported.cmake:2 \(add_custom_command\):
+  TARGET 'TargetImported' is IMPORTED and does not build here.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/add_custom_command/TargetImported.cmake b/Tests/RunCMake/add_custom_command/TargetImported.cmake
new file mode 100644
index 0000000..c0f2d66
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetImported.cmake
@@ -0,0 +1,2 @@
+add_library(TargetImported UNKNOWN IMPORTED)
+add_custom_command(TARGET TargetImported COMMAND ${CMAKE_COMMAND} -E echo tada)
diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir-result.txt b/Tests/RunCMake/add_custom_command/TargetNotInDir-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetNotInDir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir-stderr.txt b/Tests/RunCMake/add_custom_command/TargetNotInDir-stderr.txt
new file mode 100644
index 0000000..91876a0
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetNotInDir-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TargetNotInDir.cmake:2 \(add_custom_command\):
+  TARGET 'TargetNotInDir' was not created in this directory.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir.cmake b/Tests/RunCMake/add_custom_command/TargetNotInDir.cmake
new file mode 100644
index 0000000..a551026
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetNotInDir.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(TargetNotInDir)
+add_custom_command(TARGET TargetNotInDir COMMAND ${CMAKE_COMMAND} -E echo tada)
diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir/CMakeLists.txt b/Tests/RunCMake/add_custom_command/TargetNotInDir/CMakeLists.txt
new file mode 100644
index 0000000..3d51d27
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetNotInDir/CMakeLists.txt
@@ -0,0 +1 @@
+add_custom_target(TargetNotInDir)
diff --git a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake
index 9a727dd..72c82ab 100644
--- a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake
@@ -13,3 +13,22 @@
 
 TEST(MY_INSTALL_DESTINATION UNDEFINED)
 TEST(MY_INSTALL_OPTIONAL TRUE)
+
+macro(foo)
+  set(_options )
+  set(_oneValueArgs FOO)
+  set(_multiValueArgs )
+  cmake_parse_arguments(_FOO2 "${_options}"
+                              "${_oneValueArgs}"
+                              "${_multiValueArgs}"
+                              "${ARGN}")
+  cmake_parse_arguments(_FOO1 "${_options}"
+                              "${_oneValueArgs}"
+                              "${_multiValueArgs}"
+                              ${ARGN})
+endmacro()
+
+foo(FOO foo)
+
+TEST(_FOO1_FOO foo)
+TEST(_FOO2_FOO foo)
diff --git a/Tests/RunCMake/ctest_submit/CDashSubmitQuiet-stderr.txt b/Tests/RunCMake/ctest_submit/CDashSubmitQuiet-stderr.txt
index adf334b..4825d7a 100644
--- a/Tests/RunCMake/ctest_submit/CDashSubmitQuiet-stderr.txt
+++ b/Tests/RunCMake/ctest_submit/CDashSubmitQuiet-stderr.txt
@@ -1,3 +1,3 @@
  *Error when uploading file: .*/Configure.xml
- *Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?|The requested URL returned error:.*)
+ *Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
  *Problems when submitting via HTTP
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt
index 64c3011..b9d9394 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt
+++ b/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt
@@ -1,2 +1,2 @@
-Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?|The requested URL returned error:.*)
+Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
    Problems when submitting via FTP
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-http-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-http-stderr.txt
index 73f0138..f52d2d8 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-http-stderr.txt
+++ b/Tests/RunCMake/ctest_submit/FailDrop-http-stderr.txt
@@ -1,2 +1,2 @@
-Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?|The requested URL returned error:.*)
+Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
    Problems when submitting via HTTP
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-https-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-https-stderr.txt
index a1ba4f6..24083f2 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-https-stderr.txt
+++ b/Tests/RunCMake/ctest_submit/FailDrop-https-stderr.txt
@@ -1,2 +1,2 @@
-Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?|The requested URL returned error:.*|Protocol "https" not supported or disabled in .*|.* was built with SSL disabled.*)
+Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*|Protocol "https" not supported or disabled in .*|.* was built with SSL disabled.*)
    Problems when submitting via HTTP
diff --git a/Tests/RunCMake/if/MatchesSelf.cmake b/Tests/RunCMake/if/MatchesSelf.cmake
new file mode 100644
index 0000000..3131ac4
--- /dev/null
+++ b/Tests/RunCMake/if/MatchesSelf.cmake
@@ -0,0 +1,4 @@
+foreach(n 0 1 2 3 4 5 6 7 8 9 COUNT)
+  if(CMAKE_MATCH_${n} MATCHES "x")
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake
index 3f4d2a2..077d00a 100644
--- a/Tests/RunCMake/if/RunCMakeTest.cmake
+++ b/Tests/RunCMake/if/RunCMakeTest.cmake
@@ -5,5 +5,7 @@
 run_cmake(IsDirectoryLong)
 run_cmake(elseif-message)
 
+run_cmake(MatchesSelf)
+
 run_cmake(TestNameThatExists)
 run_cmake(TestNameThatDoesNotExist)
diff --git a/Tests/RunCMake/install/CMP0062-NEW.cmake b/Tests/RunCMake/install/CMP0062-NEW.cmake
index a696f56..9e7a5fb 100644
--- a/Tests/RunCMake/install/CMP0062-NEW.cmake
+++ b/Tests/RunCMake/install/CMP0062-NEW.cmake
@@ -1,4 +1,4 @@
-
+cmake_policy(VERSION 3.2)
 cmake_policy(SET CMP0062 NEW)
 
 add_library(iface INTERFACE)
diff --git a/Tests/RunCMake/install/CMP0062-OLD.cmake b/Tests/RunCMake/install/CMP0062-OLD.cmake
index 94b809a..8874923 100644
--- a/Tests/RunCMake/install/CMP0062-OLD.cmake
+++ b/Tests/RunCMake/install/CMP0062-OLD.cmake
@@ -1,4 +1,4 @@
-
+cmake_policy(VERSION 3.2)
 cmake_policy(SET CMP0062 OLD)
 
 add_library(iface INTERFACE)
diff --git a/Tests/RunCMake/install/CMP0062-WARN.cmake b/Tests/RunCMake/install/CMP0062-WARN.cmake
index 0435a64..018f822 100644
--- a/Tests/RunCMake/install/CMP0062-WARN.cmake
+++ b/Tests/RunCMake/install/CMP0062-WARN.cmake
@@ -1,3 +1,4 @@
+cmake_policy(VERSION 3.2)
 
 add_library(iface INTERFACE)
 export(TARGETS iface FILE "${CMAKE_CURRENT_BINARY_DIR}/exported.cmake")
diff --git a/Tests/RunCMake/install/CMakeLists.txt b/Tests/RunCMake/install/CMakeLists.txt
index 4b3de84..6dd8cdf 100644
--- a/Tests/RunCMake/install/CMakeLists.txt
+++ b/Tests/RunCMake/install/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.4)
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/install/EXPORT-OldIFace.cmake b/Tests/RunCMake/install/EXPORT-OldIFace.cmake
new file mode 100644
index 0000000..033f684
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-OldIFace.cmake
@@ -0,0 +1,7 @@
+enable_language(C)
+set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+add_subdirectory(EXPORT-OldIFace)
+add_library(foo SHARED empty.c)
+target_link_libraries(foo bar)
+install(TARGETS foo DESTINATION lib EXPORT fooExport)
+install(EXPORT fooExport DESTINATION lib/cmake/foo EXPORT_LINK_INTERFACE_LIBRARIES)
diff --git a/Tests/RunCMake/install/EXPORT-OldIFace/CMakeLists.txt b/Tests/RunCMake/install/EXPORT-OldIFace/CMakeLists.txt
new file mode 100644
index 0000000..32292e2
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-OldIFace/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(bar SHARED ../empty.c)
+install(TARGETS bar DESTINATION lib EXPORT fooExport)
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index 2c1b29d..c2347d8 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -10,6 +10,7 @@
 run_cmake(DIRECTORY-DESTINATION-bad)
 run_cmake(FILES-DESTINATION-bad)
 run_cmake(TARGETS-DESTINATION-bad)
+run_cmake(EXPORT-OldIFace)
 run_cmake(CMP0062-OLD)
 run_cmake(CMP0062-NEW)
 run_cmake(CMP0062-WARN)
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
index 8307607..1466fbf 100644
--- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
@@ -8,3 +8,5 @@
 run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses)
 run_cmake(SubDirTarget)
 run_cmake(SharedDepNotTarget)
+run_cmake(StaticPrivateDepNotExported)
+run_cmake(StaticPrivateDepNotTarget)
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
new file mode 100644
index 0000000..6bb44ab
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
@@ -0,0 +1 @@
+CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in the export set.
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake
new file mode 100644
index 0000000..9b97918
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported.cmake
@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0022 NEW)
+enable_language(C)
+add_library(foo STATIC empty.c)
+add_library(not_exported STATIC empty.c)
+target_link_libraries(foo PRIVATE not_exported)
+install(TARGETS foo EXPORT Exp DESTINATION lib)
+install(EXPORT Exp DESTINATION lib/cmake/Exp)
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake
new file mode 100644
index 0000000..7122ae9
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotTarget.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0022 NEW)
+enable_language(C)
+add_library(foo STATIC empty.c)
+target_link_libraries(foo PRIVATE not_a_target)
+install(TARGETS foo EXPORT Exp DESTINATION lib)
+install(EXPORT Exp DESTINATION lib/cmake/Exp)
diff --git a/Tests/Wrapping/CMakeLists.txt b/Tests/Wrapping/CMakeLists.txt
index cbb28a1..aca36bc 100644
--- a/Tests/Wrapping/CMakeLists.txt
+++ b/Tests/Wrapping/CMakeLists.txt
@@ -85,16 +85,18 @@
 # Since FLTK_FLUID_EXE is supposed to create a .cxx/.h from a .fl/.fld,
 # create an empty one so that the dependencies can be met.
 #
-set (FLTK_SRCS
-  fltk1.fl
-  )
 add_executable(fakefluid fakefluid.cxx)
 set (FLTK_WRAP_UI "On")
 set (FLTK_FLUID_EXECUTABLE fakefluid)
-fltk_wrap_ui (wraplibFLTK ${FLTK_SRCS})
+fltk_wrap_ui (wraplibFLTK fltk1.fl)
 add_library(wraplibFLTK ${wraplibFLTK_FLTK_UI_SRCS})
 add_dependencies(wraplibFLTK fakefluid)
 add_dependencies(fakefluid Wrap)
+fltk_wrap_ui (wrapFLTK fltk2.fl)
+add_executable(wrapFLTK wrapFLTK.c ${wrapFLTK_FLTK_UI_SRCS})
+target_link_libraries(wrapFLTK wraplibFLTK)
+add_dependencies(wrapFLTK fakefluid)
+
 #
 # Mangled Mesa
 #
diff --git a/Tests/Wrapping/fltk2.fl b/Tests/Wrapping/fltk2.fl
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/Wrapping/fltk2.fl
diff --git a/Tests/Wrapping/wrapFLTK.c b/Tests/Wrapping/wrapFLTK.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/Tests/Wrapping/wrapFLTK.c
@@ -0,0 +1 @@
+int main(void) { return 0; }
diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt
index 8b3e325..cf6bb72 100644
--- a/Utilities/CMakeLists.txt
+++ b/Utilities/CMakeLists.txt
@@ -33,3 +33,7 @@
   # Normal documentation build.
   add_subdirectory(Sphinx)
 endif()
+
+if(WIX_CUSTOM_ACTION_ENABLED)
+  add_subdirectory(Release/WiX)
+endif()
diff --git a/Utilities/Release/WiX/CMakeLists.txt b/Utilities/Release/WiX/CMakeLists.txt
new file mode 100644
index 0000000..cc0dbe1
--- /dev/null
+++ b/Utilities/Release/WiX/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_subdirectory(CustomAction)
+
+if(CMAKE_CONFIGURATION_TYPES)
+  set(CUSTOM_ACTION_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/custom_action_dll-$<CONFIG>.wxs")
+else()
+  set(CUSTOM_ACTION_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/custom_action_dll.wxs")
+endif()
+
+file(GENERATE
+  OUTPUT "${CUSTOM_ACTION_OUTPUT}"
+  INPUT "${CMAKE_CURRENT_SOURCE_DIR}/custom_action_dll.wxs.in"
+  )
diff --git a/Utilities/Release/WiX/CustomAction/CMakeLists.txt b/Utilities/Release/WiX/CustomAction/CMakeLists.txt
new file mode 100644
index 0000000..7efd01e
--- /dev/null
+++ b/Utilities/Release/WiX/CustomAction/CMakeLists.txt
@@ -0,0 +1,13 @@
+foreach(CONFIG DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
+  string(REPLACE "/MD" "/MT"
+    "CMAKE_CXX_FLAGS_${CONFIG}"
+    "${CMAKE_CXX_FLAGS_${CONFIG}}"
+  )
+endforeach()
+
+add_library(CMakeWiXCustomActions MODULE
+  detect_nsis_overwrite.cpp
+  exports.def
+)
+
+target_link_libraries(CMakeWiXCustomActions PRIVATE msi)
diff --git a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
new file mode 100644
index 0000000..dad1ae5
--- /dev/null
+++ b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
@@ -0,0 +1,45 @@
+#include <windows.h>
+#include <msi.h>
+#include <msiquery.h>
+
+#include <string>
+#include <vector>
+
+std::wstring get_property(MSIHANDLE msi_handle, std::wstring const& name)
+{
+  DWORD size = 0;
+
+  UINT status = MsiGetPropertyW(msi_handle, name.c_str(), L"", &size);
+
+  if(status == ERROR_MORE_DATA)
+    {
+    std::vector<wchar_t> buffer(size + 1);
+    MsiGetPropertyW(msi_handle, name.c_str(), &buffer[0], &size);
+    return std::wstring(&buffer[0]);
+    }
+  else
+    {
+    return std::wstring();
+    }
+}
+
+void set_property(MSIHANDLE msi_handle,
+  std::wstring const& name, std::wstring const& value)
+{
+  MsiSetPropertyW(msi_handle, name.c_str(), value.c_str());
+}
+
+extern "C" UINT __stdcall DetectNsisOverwrite(MSIHANDLE msi_handle)
+{
+  std::wstring install_root = get_property(msi_handle, L"INSTALL_ROOT");
+
+  std::wstring uninstall_exe = install_root + L"\\uninstall.exe";
+
+  bool uninstall_exe_exists =
+      GetFileAttributesW(uninstall_exe.c_str()) != INVALID_FILE_ATTRIBUTES;
+
+  set_property(msi_handle, L"CMAKE_NSIS_OVERWRITE_DETECTED",
+    uninstall_exe_exists ? L"1" : L"0");
+
+  return ERROR_SUCCESS;
+}
diff --git a/Utilities/Release/WiX/CustomAction/exports.def b/Utilities/Release/WiX/CustomAction/exports.def
new file mode 100644
index 0000000..0e448b2
--- /dev/null
+++ b/Utilities/Release/WiX/CustomAction/exports.def
@@ -0,0 +1,2 @@
+EXPORTS
+	DetectNsisOverwrite=DetectNsisOverwrite
diff --git a/Utilities/Release/WiX/cmake_nsis_overwrite_dialog.wxs b/Utilities/Release/WiX/cmake_nsis_overwrite_dialog.wxs
new file mode 100644
index 0000000..8fe60f2
--- /dev/null
+++ b/Utilities/Release/WiX/cmake_nsis_overwrite_dialog.wxs
@@ -0,0 +1,21 @@
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+	<Fragment>
+		<UI>
+	            <Dialog Id="CMakeNsisOverwriteDialog" Width="310" Height="120" Title="NSIS Installation Conflict">
+			<Control Id="OK" Type="PushButton" X="122" Y="90" Width="56" Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUIOK)">
+	                    <Publish Event="EndDialog" Value="Return">1</Publish>
+	                </Control>
+	                <Control Id="Text" Type="Text" X="48" Y="22" Width="260" Height="60">
+				<Text>
+					Uninstall.exe was detected in your chosen installation prefix.
+					This indicates a conflicting NSIS based installation of CMake.
+
+					Please uninstall your old CMake installation or choose a different
+					installation directory.
+				</Text>
+			</Control>
+	                <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24" ToolTip="!(loc.InvalidDirDlgIconTooltip)" FixedSize="yes" IconSize="32" Text="!(loc.InvalidDirDlgIcon)" />
+	            </Dialog>
+		</UI>
+	</Fragment>
+</Wix>
diff --git a/Utilities/Release/WiX/custom_action_dll.wxs.in b/Utilities/Release/WiX/custom_action_dll.wxs.in
new file mode 100644
index 0000000..021e63c
--- /dev/null
+++ b/Utilities/Release/WiX/custom_action_dll.wxs.in
@@ -0,0 +1,6 @@
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+	<Fragment>
+		<Binary Id="CMakeCustomActionsDll"
+			SourceFile="$<TARGET_FILE:CMakeWiXCustomActions>"/>
+	</Fragment>
+</Wix>
diff --git a/Utilities/Release/WiX/install_dir.wxs b/Utilities/Release/WiX/install_dir.wxs
index 883efba..49b74e3 100644
--- a/Utilities/Release/WiX/install_dir.wxs
+++ b/Utilities/Release/WiX/install_dir.wxs
@@ -9,6 +9,9 @@
 			<Property Id="WixUI_Mode" Value="InstallDir" />
 
 			<DialogRef Id="CMakeExtraDialog" />
+			<?ifdef CHECK_NSIS ?>
+				<DialogRef Id="CMakeNsisOverwriteDialog" />
+			<?endif ?>
 
 			<DialogRef Id="BrowseDlg" />
 			<DialogRef Id="DiskCostDlg" />
@@ -36,7 +39,11 @@
 			<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
 			<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
 			<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
-			<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
+			<?ifdef CHECK_NSIS ?>
+				<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="CMakeDetectNsisOverwrite" Order="4">1</Publish>
+				<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="CMakeNsisOverwriteDialog" Order="5">CMAKE_NSIS_OVERWRITE_DETECTED="1"</Publish>
+			<?endif ?>
+			<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="6"><![CDATA[(WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1") AND CMAKE_NSIS_OVERWRITE_DETECTED<>1]]></Publish>
 			<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
 			<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
 
@@ -57,5 +64,9 @@
 		</UI>
 
 		<UIRef Id="WixUI_Common" />
+
+		<?ifdef CHECK_NSIS ?>
+			<CustomAction Id="CMakeDetectNsisOverwrite" BinaryKey="CMakeCustomActionsDll" DllEntry="DetectNsisOverwrite"/>
+		<?endif ?>
 	</Fragment>
 </Wix>
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
index 171811a..f5e325e 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.4)
+ set(VERSION 3.5)
 endif()
 if(NOT DEFINED PROJECT_PREFIX)
   set(PROJECT_PREFIX cmake-${VERSION})
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index 1baca35..257ba62 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -156,6 +156,14 @@
     if("x${m}" MATCHES "^x(.+)\\.([1-9])\\.rst$")
       set(name "${CMAKE_MATCH_1}")
       set(sec "${CMAKE_MATCH_2}")
+      if(NOT CMakeHelp_STANDALONE)
+        if(name STREQUAL "ccmake" AND NOT BUILD_CursesDialog)
+          continue()
+        endif()
+        if(name STREQUAL "cmake-gui" AND NOT BUILD_QtDialog)
+          continue()
+        endif()
+      endif()
       CMake_OPTIONAL_COMPONENT(sphinx-man)
       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/${name}.${sec}
               DESTINATION ${CMAKE_MAN_DIR}/man${sec}