Merge branch 'swift-rpath' into release-3.16

Merge-request: !3965
diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt
index 40f1c1a..42bf52b 100644
--- a/Help/command/FIND_XXX.txt
+++ b/Help/command/FIND_XXX.txt
@@ -79,15 +79,16 @@
    |prefix_XXX_SUBDIR| for each ``<prefix>`` in
    :variable:`CMAKE_SYSTEM_PREFIX_PATH`
 
-1. If called from within a find module loaded by
+1. If called from within a find module or any other script loaded by a call to
    :command:`find_package(<PackageName>)`, search prefixes unique to the
-   current package being found.  Specifically look in the
+   current package being found.  Specifically, look in the
    :variable:`<PackageName>_ROOT` CMake variable and the
    :envvar:`<PackageName>_ROOT` environment variable.
-   The package root variables are maintained as a stack so if called from
-   nested find modules, root paths from the parent's find module will be
-   searched after paths from the current module,
-   i.e. ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
+   The package root variables are maintained as a stack, so if called from
+   nested find modules or config packages, root paths from the parent's find
+   module or config package will be searched after paths from the current
+   module or package.  In other words, the search order would be
+   ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
    ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
    This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
    the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
diff --git a/Help/command/file.rst b/Help/command/file.rst
index c06451a..83e4516 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -138,7 +138,7 @@
   file(GET_RUNTIME_DEPENDENCIES
     [RESOLVED_DEPENDENCIES_VAR <deps_var>]
     [UNRESOLVED_DEPENDENCIES_VAR <unresolved_deps_var>]
-    [CONFLICTING_DEPENDENICES_PREFIX <conflicting_deps_prefix>]
+    [CONFLICTING_DEPENDENCIES_PREFIX <conflicting_deps_prefix>]
     [EXECUTABLES [<executable_files>...]]
     [LIBRARIES [<library_files>...]]
     [MODULES [<module_files>...]]
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index 2186bd8..546b00f 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -81,6 +81,7 @@
 
   find_package(<PackageName> [version] [EXACT] [QUIET]
                [REQUIRED] [[COMPONENTS] [components...]]
+               [OPTIONAL_COMPONENTS components...]
                [CONFIG|NO_MODULE]
                [NO_POLICY_SCOPE]
                [NAMES name1 [name2 ...]]
diff --git a/Help/command/math.rst b/Help/command/math.rst
index 3cbe719..ddb1ec6 100644
--- a/Help/command/math.rst
+++ b/Help/command/math.rst
@@ -8,7 +8,8 @@
   math(EXPR <variable> "<expression>" [OUTPUT_FORMAT <format>])
 
 Evaluates a mathematical ``<expression>`` and sets ``<variable>`` to the
-resulting value.
+resulting value.  The result of the expression must be representable as a
+64-bit signed integer.
 
 The mathematical expression must be given as a string (i.e. enclosed in
 double quotation marks). An example is ``"5 * (10 + 13)"``.
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 6e7f9b5..ba9887c 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -211,7 +211,7 @@
   .. code-block:: cmake
 
     target_compile_definitions(myapp
-      PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:COMPILING_CXX_WITH_CLANG>
+      PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang,Clang>>:COMPILING_CXX_WITH_CLANG>
               $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Intel>>:COMPILING_CXX_WITH_INTEL>
               $<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:Clang>>:COMPILING_C_WITH_CLANG>
     )
diff --git a/Help/policy/CMP0074.rst b/Help/policy/CMP0074.rst
index 896936b..63ebf7b 100644
--- a/Help/policy/CMP0074.rst
+++ b/Help/policy/CMP0074.rst
@@ -7,9 +7,9 @@
 searches prefixes specified by the :variable:`<PackageName>_ROOT` CMake
 variable and the :envvar:`<PackageName>_ROOT` environment variable.
 Package roots are maintained as a stack so nested calls to all ``find_*``
-commands inside find modules also search the roots as prefixes.  This policy
-provides compatibility with projects that have not been updated to avoid using
-``<PackageName>_ROOT`` variables for other purposes.
+commands inside find modules and config packages also search the roots as
+prefixes.  This policy provides compatibility with projects that have not been
+updated to avoid using ``<PackageName>_ROOT`` variables for other purposes.
 
 The ``OLD`` behavior for this policy is to ignore ``<PackageName>_ROOT``
 variables.  The ``NEW`` behavior for this policy is to use
diff --git a/Help/policy/CMP0097.rst b/Help/policy/CMP0097.rst
index 8a5ff88..4840aa6 100644
--- a/Help/policy/CMP0097.rst
+++ b/Help/policy/CMP0097.rst
@@ -14,7 +14,7 @@
 
 The ``OLD`` behavior for this policy is for ``GIT_SUBMODULES`` when set to
 an empty string to initialize and update all git submodules.
-The ``New`` behavior for this policy is for ``GIT_SUBMODULES`` when set to
+The ``NEW`` behavior for this policy is for ``GIT_SUBMODULES`` when set to
 an empty string to initialize and update no git submodules.
 
 This policy was introduced in CMake version 3.16.  Use the
diff --git a/Help/release/3.16.rst b/Help/release/3.16.rst
index 7992f2d..570f536 100644
--- a/Help/release/3.16.rst
+++ b/Help/release/3.16.rst
@@ -75,28 +75,27 @@
 
 * The :command:`find_file`, :command:`find_library`, :command:`find_path`,
   :command:`find_package`, and :command:`find_program` commands have learned to
-  check the following variables to control searching
+  check the following variables to control the default behavior for groups of
+  search locations:
 
-  * :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` - Controls the searching
-    the cmake-specific environment variables.
+  * :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` - Controls the default
+    behavior of searching the :variable:`<PackageName>_ROOT` variables.
 
-  * :variable:`CMAKE_FIND_USE_CMAKE_PATH` - Controls the searching the
-    cmake-specific cache variables.
+  * :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` - Controls the default
+    behavior of searching the CMake-specific environment variables.
 
-  * :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` - Controls the searching
-    cmake platform specific variables.
+  * :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` - Controls the default
+    behavior of searching the standard system environment variables.
 
-  * :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` - Controls the searching of
-    :variable:`<PackageName>_ROOT` variables.
+  * :variable:`CMAKE_FIND_USE_CMAKE_PATH` - Controls the default behavior of
+    searching the CMake-specific cache variables.
 
-  * :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` - Controls the searching
-    the standard system environment variables.
+  * :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` - Controls the default
+    behavior of searching the platform-specific CMake variables.
 
-* The :command:`find_package` command has learned to check the following
-  variables to control searching
-
-  * :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` - Controls the searching the
-    cmake user registry.
+* The :command:`find_package` command has learned to check the
+  :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable to control the default
+  behavior of searching the CMake user package registry.
 
 * The :command:`message` command learned indentation control with the new
   :variable:`CMAKE_MESSAGE_INDENT` variable.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
index ffb8a2c..4ee9d8b 100644
--- a/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
+++ b/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
@@ -8,8 +8,8 @@
 By default this variable is not set. If neither
 :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` nor
 ``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` is set, then
-:command:`find_package()` will use the `User Package Registry` unless the
-`NO_CMAKE_PACKAGE_REGISTRY` option is provided.
+:command:`find_package()` will use the :ref:`User Package Registry`
+unless the ``NO_CMAKE_PACKAGE_REGISTRY`` option is provided.
 
 ``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` is ignored if
 :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` is set.
diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst
index 2db5081..9ebf672 100644
--- a/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst
+++ b/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst
@@ -1,15 +1,20 @@
 CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
 -------------------------------------
 
-Controls the searching the cmake-specific environment variables by the
-:command:`find_program`, :command:`find_library`, :command:`find_file`,
-:command:`find_path`, and command:`find_package` commands.
+Controls the default behavior of the following commands for whether or not to
+search paths provided by cmake-specific environment variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
 This is useful in cross-compiling environments.
 
 By default this variable is not set, which is equivalent to it having
-a value of ``TRUE``.  Explicit options given to the :command:`find_program`,
-:command:`find_library`, :command:`find_file`, and :command:`find_path`
-commands take precedence over this variable.
+a value of ``TRUE``.  Explicit options given to the above commands
+take precedence over this variable.
 
 See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst
index 4ca7ad1..62ae3cb 100644
--- a/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst
+++ b/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst
@@ -1,15 +1,20 @@
 CMAKE_FIND_USE_CMAKE_PATH
 -------------------------
 
-Controls the searching the cmake-specific cache variables by the
-:command:`find_program`, :command:`find_library`, :command:`find_file`,
-:command:`find_path`, and command:`find_package` commands.
+Controls the default behavior of the following commands for whether or not to
+search paths provided by cmake-specific cache variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
 This is useful in cross-compiling environments.
 
 By default this variable is not set, which is equivalent to it having
-a value of ``TRUE``.  Explicit options given to the :command:`find_program`,
-:command:`find_library`, :command:`find_file`, and :command:`find_path`
-commands take precedence over this variable.
+a value of ``TRUE``.  Explicit options given to the above commands
+take precedence over this variable.
 
 See also the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst
index d3259ae..b484a6a 100644
--- a/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst
+++ b/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst
@@ -1,15 +1,20 @@
 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH
 --------------------------------
 
-Controls the searching cmake platform specific variables by the
-:command:`find_program`, :command:`find_library`, :command:`find_file`,
-:command:`find_path`, and command:`find_package` commands.
+Controls the default behavior of the following commands for whether or not to
+search paths provided by platform-specific cmake variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
 This is useful in cross-compiling environments.
 
 By default this variable is not set, which is equivalent to it having
-a value of ``TRUE``.  Explicit options given to the :command:`find_program`,
-:command:`find_library`, :command:`find_file`, and :command:`find_path`
-commands take precedence over this variable.
+a value of ``TRUE``.  Explicit options given to the above commands
+take precedence over this variable.
 
 See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
diff --git a/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
index 75e910f..a9c8469 100644
--- a/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
+++ b/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
@@ -1,28 +1,28 @@
 CMAKE_FIND_USE_PACKAGE_REGISTRY
 -------------------------------
 
-Controls the searching the :ref:`User Package Registry` by the :command:`find_package`
-command.
+Controls the default behavior of the :command:`find_package` command for
+whether or not to search paths provided by the :ref:`User Package Registry`.
 
 By default this variable is not set and the behavior will fall back
-to that determined by the deprecated :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
-variable.  If that is also not set, then `find_package()` will use the
-`User Package Registry` unless the `NO_CMAKE_PACKAGE_REGISTRY` option
+to that determined by the deprecated
+:variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` variable.  If that is
+also not set, then :command:`find_package` will use the
+:ref:`User Package Registry` unless the ``NO_CMAKE_PACKAGE_REGISTRY`` option
 is provided.
 
-This variable takes precedence over :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
-when both are set.
+This variable takes precedence over
+:variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` when both are set.
 
 In some cases, for example to locate only system wide installations, it
 is not desirable to use the :ref:`User Package Registry` when searching
-for packages. If the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
+for packages.  If the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
 variable is ``FALSE``, all the :command:`find_package` commands will skip
 the :ref:`User Package Registry` as if they were called with the
 ``NO_CMAKE_PACKAGE_REGISTRY`` argument.
 
-See also :ref:`Disabling the Package Registry`.
-
-See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+See also :ref:`Disabling the Package Registry` and the
+:variable:`CMAKE_FIND_USE_CMAKE_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
 :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
diff --git a/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst
index e17fdcc..25a25f3 100644
--- a/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst
+++ b/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst
@@ -1,15 +1,18 @@
 CMAKE_FIND_USE_PACKAGE_ROOT_PATH
 --------------------------------
 
-Controls the searching of :variable:`<PackageName>_ROOT` variables by the
-:command:`find_program`, :command:`find_library`, :command:`find_file`,
-:command:`find_path`, and command:`find_package` commands.
-This is useful in cross-compiling environments.
+Controls the default behavior of the following commands for whether or not to
+search paths provided by :variable:`<PackageName>_ROOT` variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
 
 By default this variable is not set, which is equivalent to it having
-a value of ``TRUE``.  Explicit options given to the :command:`find_program`,
-:command:`find_library`, :command:`find_file`, and :command:`find_path`
-commands take precedence over this variable.
+a value of ``TRUE``.  Explicit options given to the above commands
+take precedence over this variable.
 
 See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
diff --git a/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst b/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst
index 71432f6..0713709 100644
--- a/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst
+++ b/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst
@@ -1,15 +1,20 @@
 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
 --------------------------------------
 
-Controls the searching the standard system environment variables by the
-:command:`find_program`, :command:`find_library`, :command:`find_file`,
-:command:`find_path`, and command:`find_package` commands.
+Controls the default behavior of the following commands for whether or not to
+search paths provided by standard system environment variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
 This is useful in cross-compiling environments.
 
 By default this variable is not set, which is equivalent to it having
-a value of ``TRUE``.  Explicit options given to the :command:`find_program`,
-:command:`find_library`, :command:`find_file`, and :command:`find_path`
-commands take precedence over this variable.
+a value of ``TRUE``.  Explicit options given to the above commands
+take precedence over this variable.
 
 See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
 :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake
index aa40b59..d652ffa 100644
--- a/Modules/CMakePrintHelpers.cmake
+++ b/Modules/CMakePrintHelpers.cmake
@@ -22,9 +22,9 @@
 scope keywords must be used.  Example::
 
   cmake_print_properties(TARGETS foo bar PROPERTIES
-                         LOCATION INTERFACE_INCLUDE_DIRS)
+                         LOCATION INTERFACE_INCLUDE_DIRECTORIES)
 
-This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for
+This will print the LOCATION and INTERFACE_INCLUDE_DIRECTORIES properties for
 both targets foo and bar.
 
 ::
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index c13c03f..1f0e8f3 100644
--- a/Modules/CMakeSwiftInformation.cmake
+++ b/Modules/CMakeSwiftInformation.cmake
@@ -76,7 +76,7 @@
 endif()
 
 if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY)
-  set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
+  set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
 endif()
 
 if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
@@ -84,11 +84,11 @@
 endif()
 
 if(NOT CMAKE_Swift_LINK_EXECUTABLE)
-  set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
+  set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
 endif()
 
 if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY)
-  set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
+  set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
 
   set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
   set(CMAKE_Swift_ARCHIVE_FINISH "")
diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake
index ad40522..e3e7273 100644
--- a/Modules/FindCurses.cmake
+++ b/Modules/FindCurses.cmake
@@ -51,9 +51,11 @@
 # may be ncursesw
 if(NOT CURSES_NEED_WIDE)
   set(NCURSES_LIBRARY_NAME "ncurses")
+  set(CURSES_FORM_LIBRARY_NAME "form")
 else()
   set(NCURSES_LIBRARY_NAME "ncursesw")
-  # Also, if we are searchig fo wide curses - we are actually searching
+  set(CURSES_FORM_LIBRARY_NAME "formw")
+  # Also, if we are searching for wide curses - we are actually searching
   # for ncurses, we don't know about any other unicode version.
   set(CURSES_NEED_NCURSES TRUE)
 endif()
@@ -223,8 +225,8 @@
   endif()
 endif()
 
-find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
-find_library(CURSES_FORM_LIBRARY form )
+find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" HINTS "${_cursesLibDir}")
+find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" )
 
 # Previous versions of FindCurses provided these values.
 if(NOT DEFINED FORM_LIBRARY)
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index ab9d73a..90d1c3e 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -36,6 +36,9 @@
   Variable indicating if OpenMP support for ``<lang>`` was detected.
 ``OpenMP_<lang>_FLAGS``
   OpenMP compiler flags for ``<lang>``, separated by spaces.
+``OpenMP_<lang>_INCLUDE_DIRS``
+  Directories that must be added to the header search path for ``<lang>``
+  when using OpenMP.
 
 For linking with OpenMP code written in ``<lang>``, the following
 variables are provided:
@@ -73,6 +76,14 @@
 The specification date is formatted as given in the OpenMP standard:
 ``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of
 the OpenMP specification implemented by the ``<lang>`` compiler.
+
+For some compilers, it may be necessary to add a header search path to find
+the relevant OpenMP headers.  This location may be language-specific.  Where
+this is needed, the module may attempt to find the location, but it can be
+provided directly by setting the ``OpenMP_<lang>_INCLUDE_DIR`` cache variable.
+Note that this variable is an _input_ control to the module.  Project code
+should use the ``OpenMP_<lang>_INCLUDE_DIRS`` _output_ variable if it needs
+to know what include directories are needed.
 #]=======================================================================]
 
 cmake_policy(PUSH)
@@ -261,11 +272,27 @@
       mark_as_advanced(OpenMP_libomp_LIBRARY)
 
       if(OpenMP_libomp_LIBRARY)
+        # Try without specifying include directory first. We only want to
+        # explicitly add a search path if the header can't be found on the
+        # default header search path already.
         try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC}
           CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}"
           LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY}
           OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT
         )
+        if(NOT OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG})
+          find_path(OpenMP_${LANG}_INCLUDE_DIR omp.h)
+          mark_as_advanced(OpenMP_${LANG}_INCLUDE_DIR)
+          set(OpenMP_${LANG}_INCLUDE_DIR "${OpenMP_${LANG}_INCLUDE_DIR}" PARENT_SCOPE)
+          if(OpenMP_${LANG}_INCLUDE_DIR)
+            try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC}
+              CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}"
+                          "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}"
+              LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY}
+              OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT
+            )
+          endif()
+        endif()
         if(OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG})
           set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE)
           set("${OPENMP_LIB_NAMES_VAR}" "libomp" PARENT_SCOPE)
@@ -325,10 +352,15 @@
 function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE)
   _OPENMP_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenMPCheckVersion _OPENMP_TEST_SRC)
 
+  unset(_includeDirFlags)
+  if(OpenMP_${LANG}_INCLUDE_DIR)
+    set(_includeDirFlags "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}")
+  endif()
+
   set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin")
   string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}")
   try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}"
-              CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}"
+              CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags}
               COPY_FILE ${BIN_FILE}
               OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT)
 
@@ -491,6 +523,11 @@
       foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_LIB_NAMES)
         list(APPEND OpenMP_${LANG}_LIBRARIES "${OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY}")
       endforeach()
+      if(OpenMP_${LANG}_INCLUDE_DIR)
+        set(OpenMP_${LANG}_INCLUDE_DIRS ${OpenMP_${LANG}_INCLUDE_DIR})
+      else()
+        set(OpenMP_${LANG}_INCLUDE_DIRS "")
+      endif()
 
       if(NOT TARGET OpenMP::OpenMP_${LANG})
         add_library(OpenMP::OpenMP_${LANG} INTERFACE IMPORTED)
@@ -501,6 +538,10 @@
           INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${_OpenMP_${LANG}_OPTIONS}>")
         unset(_OpenMP_${LANG}_OPTIONS)
       endif()
+      if(OpenMP_${LANG}_INCLUDE_DIRS)
+        set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
+          INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${OpenMP_${LANG}_INCLUDE_DIRS}>")
+      endif()
       if(OpenMP_${LANG}_LIBRARIES)
         set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
           INTERFACE_LINK_LIBRARIES "${OpenMP_${LANG}_LIBRARIES}")
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index 3cc08a1..2bdfaf3 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -8,7 +8,7 @@
 Find Python interpreter, compiler and development environment (include
 directories and libraries).
 
-Three components are supported:
+The following components are supported:
 
 * ``Interpreter``: search for Python interpreter.
 * ``Compiler``: search for Python compiler. Only offered by IronPython.
@@ -16,7 +16,7 @@
   libraries).
 * ``NumPy``: search for NumPy include directories.
 
-If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed.
+If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
 
 To ensure consistent versions between components ``Interpreter``, ``Compiler``,
 ``Development`` and ``NumPy``, specify all components at the same time::
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 0cecdc6..3cc7d56 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -8,7 +8,7 @@
 Find Python 2 interpreter, compiler and development environment (include
 directories and libraries).
 
-Three components are supported:
+The following components are supported:
 
 * ``Interpreter``: search for Python 2 interpreter
 * ``Compiler``: search for Python 2 compiler. Only offered by IronPython.
@@ -16,7 +16,7 @@
   libraries)
 * ``NumPy``: search for NumPy include directories.
 
-If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed.
+If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
 
 To ensure consistent versions between components ``Interpreter``, ``Compiler``,
 ``Development`` and ``NumPy``, specify all components at the same time::
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 1edb9c9..066d0df 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -8,7 +8,7 @@
 Find Python 3 interpreter, compiler and development environment (include
 directories and libraries).
 
-Three components are supported:
+The following components are supported:
 
 * ``Interpreter``: search for Python 3 interpreter
 * ``Compiler``: search for Python 3 compiler. Only offered by IronPython.
@@ -16,7 +16,7 @@
   libraries)
 * ``NumPy``: search for NumPy include directories.
 
-If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed.
+If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
 
 To ensure consistent versions between components ``Interpreter``, ``Compiler``,
 ``Development`` and ``NumPy``, specify all components at the same time::
diff --git a/Modules/Platform/Apple-Apple-Swift.cmake b/Modules/Platform/Apple-Apple-Swift.cmake
new file mode 100644
index 0000000..7ca3e36
--- /dev/null
+++ b/Modules/Platform/Apple-Apple-Swift.cmake
@@ -0,0 +1 @@
+set(CMAKE_Swift_SYSROOT_FLAG "-sdk")
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index ad3debb..6b71e8a 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -341,7 +341,7 @@
     char fmt[512] =
       "Press [enter] to edit option Press [d] to delete an entry";
     if (process) {
-      memset(fmt, ' ', 27);
+      memset(fmt, ' ', 57);
     }
     printw(fmt_s, fmt);
     curses_move(y - 3, 0);
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index eb59b4f..7bb5209 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -224,7 +224,8 @@
     std::array<std::string, MAX_VERSION_COMPONENTS> version_components;
 
     if (cmp0096 == cmPolicies::OLD || cmp0096 == cmPolicies::WARN) {
-      char vb[MAX_VERSION_COMPONENTS][std::numeric_limits<unsigned>::digits10];
+      char vb[MAX_VERSION_COMPONENTS]
+             [std::numeric_limits<unsigned>::digits10 + 2];
       unsigned v[MAX_VERSION_COMPONENTS] = { 0, 0, 0, 0 };
       const int vc = std::sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1],
                                  &v[2], &v[3]);
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 127421a..f8b8981 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -1342,10 +1342,9 @@
   auto findHeader = [this,
                      &headerHandle](std::string const& basePath) -> bool {
     bool found = false;
-    std::string const baseCollapsed =
-      this->Gen()->CollapseFullPathTS(cmStrCat(basePath, '.'));
     for (std::string const& ext : this->BaseConst().HeaderExtensions) {
-      std::string const testPath = cmStrCat(baseCollapsed, ext);
+      std::string const testPath =
+        this->Gen()->CollapseFullPathTS(cmStrCat(basePath, '.', ext));
       cmFileTime fileTime;
       if (!fileTime.Load(testPath)) {
         // File not found
@@ -1377,8 +1376,7 @@
       }
     }
     if (!found) {
-      this->SearchLocations.emplace_back(
-        cmQtAutoGen::ParentDir(baseCollapsed));
+      this->SearchLocations.emplace_back(cmQtAutoGen::ParentDir(basePath));
     }
     return found;
   };
diff --git a/Tests/FindOpenMP/Test/CMakeLists.txt b/Tests/FindOpenMP/Test/CMakeLists.txt
index 2692947..ebdb6b8 100644
--- a/Tests/FindOpenMP/Test/CMakeLists.txt
+++ b/Tests/FindOpenMP/Test/CMakeLists.txt
@@ -42,6 +42,7 @@
   separate_arguments(_OpenMP_${c}_OPTIONS NATIVE_COMMAND "${OpenMP_${c}_FLAGS}")
   target_compile_options(test_var_${c} PRIVATE "${_OpenMP_${c}_OPTIONS}")
   target_link_libraries(test_var_${c} PRIVATE "${OpenMP_${c}_FLAGS}")
+  target_include_directories(test_var_${c} PRIVATE ${OpenMP_${c}_INCLUDE_DIRS})
   set_property(TARGET test_var_${c} PROPERTY LINKER_LANGUAGE ${c})
   add_test(NAME test_var_${c} COMMAND test_var_${c})
 
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
index f664db9..4a92a45 100644
--- a/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
+++ b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
@@ -1,3 +1,2 @@
-.*/Framework:( Mach-O universal binary with [^
-]*)? Mach-O[^
+.*/Framework( \(for architecture [^\)]+\))?:[ 	]+Mach-O[^
 ]* dynamically linked shared library.*
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
index 4b5f761..dd64717 100644
--- a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
+++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
@@ -1,2 +1 @@
-/Framework: (Mach-O universal binary with [^
-]*)?current ar archive random library
+/Framework( \(for architecture [^\)]+\))?:[ 	]+current ar archive random library
diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake
index c7e1319..965fbf4 100644
--- a/Tests/RunCMake/Framework/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake
@@ -25,7 +25,7 @@
   set(RunCMake_TEST_NO_CLEAN 1)
   set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake")
   list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}")
-  if(NOT ${UseProperty})
+  if(NOT UseProperty)
     list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FRAMEWORK=YES")
   endif()
 
diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake
index 8f43a51..6914699 100644
--- a/Tests/RunCMake/project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/project/RunCMakeTest.cmake
@@ -22,6 +22,7 @@
 run_cmake(VersionMissingLanguages)
 run_cmake(VersionMissingValueOkay)
 run_cmake(VersionTwice)
+run_cmake(VersionMax)
 
 run_cmake(CMP0048-OLD)
 run_cmake(CMP0048-OLD-VERSION)
diff --git a/Tests/RunCMake/project/VersionMax.cmake b/Tests/RunCMake/project/VersionMax.cmake
new file mode 100644
index 0000000..e955364
--- /dev/null
+++ b/Tests/RunCMake/project/VersionMax.cmake
@@ -0,0 +1,32 @@
+cmake_policy(SET CMP0048 NEW)
+cmake_policy(SET CMP0096 OLD)
+
+enable_language(C)
+include(CheckTypeSize)
+check_type_size(unsigned __sizeOfUnsigned BUILTIN_TYPES_ONLY LANGUAGE C)
+
+# We can't use math() to compute this because it only supports up to
+# 64-bit signed integers, so hard-code the types we expect to encounter
+if(__sizeOfUnsigned EQUAL 0)
+  message(STATUS "Multi-architecture build, skipping project version check")
+  return()
+elseif(__sizeOfUnsigned EQUAL 4)
+  set(maxVal 4294967295)
+elseif(__sizeOfUnsigned EQUAL 8)
+  set(maxVal 18446744073709551615)
+else()
+  message(FATAL_ERROR
+    "Test needs to be updated for unsigned integer size ${__sizeOfUnsigned}")
+endif()
+
+# The real value of this test is when an address sanitizer is enabled.
+# It catches situations where the size of the buffer used to compute or
+# hold the version components as strings is too small.
+project(ProjectA VERSION ${maxVal}.${maxVal}.${maxVal}.${maxVal} LANGUAGES NONE)
+
+if(NOT ${PROJECT_VERSION_MAJOR} EQUAL ${maxVal})
+  message(FATAL_ERROR "Project version number parsing failed round trip.\n"
+    "Expected: ${maxVal}\n"
+    "Computed: ${PROJECT_VERSION_MAJOR}"
+  )
+endif()
diff --git a/bootstrap b/bootstrap
index 1f5f066..883b165 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1092,7 +1092,7 @@
           "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
           cmake_c_compiler="${compiler}"
           cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}"
-          break 3
+          break 4
         fi
       done
     done
@@ -1203,7 +1203,7 @@
           "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
           cmake_cxx_compiler="${compiler}"
           cmake_cxx_flags="${cmake_cxx_flags} ${std_flag} ${thread_flag} "
-          break 3
+          break 4
         fi
       done
     done