Merge branch 'implicit-includes-cray-hlist' into release-3.15

Merge-request: !3532
diff --git a/Help/command/execute_process.rst b/Help/command/execute_process.rst
index e6ad037..14f879d 100644
--- a/Help/command/execute_process.rst
+++ b/Help/command/execute_process.rst
@@ -80,7 +80,9 @@
 
 ``COMMAND_ECHO <where>``
  The command being run will be echo'ed to ``<where>`` with ``<where>``
- being set to ``STDERR``|``STDOUT``|``NONE``.
+ being set to one of ``STDERR``, ``STDOUT`` or ``NONE``.
+ See the :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ECHO` variable for a way
+ to control the default behavior when this option is not present.
 
 ``ENCODING <name>``
  On Windows, the encoding that is used to decode output from the process.
diff --git a/Help/command/list.rst b/Help/command/list.rst
index 4444af7..39e7e2a 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -207,84 +207,81 @@
                         [OUTPUT_VARIABLE <output variable>])
 
 Transforms the list by applying an action to all or, by specifying a
-``<SELECTOR>``, to the selected elements of the list, storing result in-place
-or in the specified output variable.
+``<SELECTOR>``, to the selected elements of the list, storing the result
+in-place or in the specified output variable.
 
 .. note::
 
-   ``TRANSFORM`` sub-command does not change the number of elements of the
+   The ``TRANSFORM`` sub-command does not change the number of elements in the
    list. If a ``<SELECTOR>`` is specified, only some elements will be changed,
-   the other ones will remain same as before the transformation.
+   the other ones will remain the same as before the transformation.
 
-``<ACTION>`` specify the action to apply to the elements of list.
-The actions have exactly the same semantics as sub-commands of
-:command:`string` command.
-
-The ``<ACTION>`` may be one of:
+``<ACTION>`` specifies the action to apply to the elements of the list.
+The actions have exactly the same semantics as sub-commands of the
+:command:`string` command.  ``<ACTION>`` must be one of the following:
 
 ``APPEND``, ``PREPEND``: Append, prepend specified value to each element of
 the list.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> <APPEND|PREPEND> <value> ...)
+    list(TRANSFORM <list> <APPEND|PREPEND> <value> ...)
 
 ``TOUPPER``, ``TOLOWER``: Convert each element of the list to upper, lower
 characters.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> <TOLOWER|TOUPPER> ...)
+    list(TRANSFORM <list> <TOLOWER|TOUPPER> ...)
 
 ``STRIP``: Remove leading and trailing spaces from each element of the
 list.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> STRIP ...)
+    list(TRANSFORM <list> STRIP ...)
 
 ``GENEX_STRIP``: Strip any
 :manual:`generator expressions <cmake-generator-expressions(7)>` from each
 element of the list.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> GENEX_STRIP ...)
+    list(TRANSFORM <list> GENEX_STRIP ...)
 
 ``REPLACE``: Match the regular expression as many times as possible and
 substitute the replacement expression for the match for each element
 of the list
 (Same semantic as ``REGEX REPLACE`` from :command:`string` command).
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> REPLACE <regular_expression>
-                                <replace_expression> ...)
+    list(TRANSFORM <list> REPLACE <regular_expression>
+                                  <replace_expression> ...)
 
-``<SELECTOR>`` select which elements of the list will be transformed. Only one
-type of selector can be specified at a time.
-
-The ``<SELECTOR>`` may be one of:
+``<SELECTOR>`` determines which elements of the list will be transformed.
+Only one type of selector can be specified at a time.  When given,
+``<SELECTOR>`` must be one of the following:
 
 ``AT``: Specify a list of indexes.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> <ACTION> AT <index> [<index> ...] ...)
+    list(TRANSFORM <list> <ACTION> AT <index> [<index> ...] ...)
 
 ``FOR``: Specify a range with, optionally, an increment used to iterate over
 the range.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> <ACTION> FOR <start> <stop> [<step>] ...)
+    list(TRANSFORM <list> <ACTION> FOR <start> <stop> [<step>] ...)
 
 ``REGEX``: Specify a regular expression. Only elements matching the regular
 expression will be transformed.
 
-.. code-block:: cmake
+  .. code-block:: cmake
 
-  list(TRANSFORM <list> <ACTION> REGEX <regular_expression> ...)
+    list(TRANSFORM <list> <ACTION> REGEX <regular_expression> ...)
 
 
 Ordering
diff --git a/Help/command/message.rst b/Help/command/message.rst
index 3f9216a..5dca6b4 100644
--- a/Help/command/message.rst
+++ b/Help/command/message.rst
@@ -53,12 +53,12 @@
 
 The CMake command-line tool displays ``STATUS`` to ``TRACE`` messages on stdout
 with the message preceded by two hyphens and a space.  All other message types
-are sent to stderr and are not prefixed with hyphens.  The CMake GUI displays
-all messages in its log area.  The interactive dialogs (:manual:`ccmake(1)`
-and :manual:`cmake-gui(1)`) show ``STATUS`` to ``TRACE`` messages one at a
-time on a status line and other messages in interactive pop-up boxes.
-The ``--loglevel`` command-line option to each of these tools can be used to
-control which messages will be shown.
+are sent to stderr and are not prefixed with hyphens.  The
+:manual:`CMake GUI <cmake-gui(1)>` displays all messages in its log area.
+The :manual:`curses interface <ccmake(1)>` shows ``STATUS`` to ``TRACE``
+messages one at a time on a status line and other messages in an
+interactive pop-up box.  The ``--loglevel`` command-line option to each of
+these tools can be used to control which messages will be shown.
 
 CMake Warning and Error message text displays using a simple markup
 language.  Non-indented text is formatted in line-wrapped paragraphs
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index df4531b..7435d9a 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -101,6 +101,14 @@
 The :variable:`CMAKE_CROSSCOMPILING` variable is set to true when CMake is
 cross-compiling.
 
+Note that using the :variable:`CMAKE_SOURCE_DIR` or :variable:`CMAKE_BINARY_DIR`
+variables inside a toolchain file is typically undesirable.  The toolchain
+file is used in contexts where these variables have different values when used
+in different places (e.g. as part of a call to :command:`try_compile`).  In most
+cases, where there is a need to evaluate paths inside a toolchain file, the more
+appropriate variable to use would be :variable:`CMAKE_CURRENT_LIST_DIR`, since
+it always has an unambiguous, predictable value.
+
 Cross Compiling for Linux
 -------------------------
 
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 13cba71..7b5399d 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -200,11 +200,11 @@
  from the top of a binary tree for a CMake project it will dump
  additional information such as the cache, log files etc.
 
-``--loglevel=<error|warning|notice|status|verbose|debug|trace>``
+``--loglevel=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE>``
  Set the log level.
 
  The :command:`message` command will only output messages of the specified
- log level or higher.  The default log level is ``status``.
+ log level or higher.  The default log level is ``STATUS``.
 
 ``--debug-trycompile``
  Do not delete the :command:`try_compile` build tree.
@@ -290,7 +290,8 @@
   value of ``1`` can be used to limit to a single job.
 
 ``--target <tgt>..., -t <tgt>...``
-  Build ``<tgt>`` instead of default targets.  May be specified multiple times.
+  Build ``<tgt>`` instead of the default target.  Multiple targets may be
+  given, separated by spaces.
 
 ``--config <cfg>``
   For multi-configuration tools, choose configuration ``<cfg>``.
@@ -333,16 +334,16 @@
   Project binary directory to install. This is required and must be first.
 
 ``--config <cfg>``
-  For multi-configuration tools, choose configuration ``<cfg>``.
+  For multi-configuration generators, choose configuration ``<cfg>``.
 
 ``--component <comp>``
   Component-based install. Only install component ``<comp>``.
 
 ``--prefix <prefix>``
-  The installation prefix :variable:`CMAKE_INSTALL_PREFIX`.
+  Override the installation prefix, :variable:`CMAKE_INSTALL_PREFIX`.
 
 ``--strip``
-  Strip before installing by setting ``CMAKE_INSTALL_DO_STRIP``.
+  Strip before installing.
 
 ``-v, --verbose``
   Enable verbose output.
diff --git a/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst b/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst
index 893a298..b6f6160 100644
--- a/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst
+++ b/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst
@@ -13,5 +13,5 @@
 Arguments to :prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES` may use
 :manual:`generator expressions <cmake-generator-expressions(7)>`.
 
-This property only works for the the Makefile generators.
+This property only works for the Makefile generators.
 It is ignored on other generators.
diff --git a/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst b/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst
index 4a3121c..76561d8 100644
--- a/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst
+++ b/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst
@@ -1,6 +1,6 @@
 CMAKE_EXECUTE_PROCESS_COMMAND_ECHO
 ----------------------------------
 
-If this variable is set to ``STDERR``|``STDOUT``|``NONE`` then commands in
-:command:`execute_process` calls will be printed to either stderr or stdout
-or not at all.
+If this variable is set to ``STDERR``, ``STDOUT`` or ``NONE`` then commands
+in :command:`execute_process` calls will be printed to either stderr or
+stdout or not at all.
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index a48d33c..e47f3a4 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -129,7 +129,7 @@
     if("${_compileid}" MATCHES "V([0-9]+\\.[0-9]+\\.[0-9]+)")
       set(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION ${CMAKE_MATCH_1})
     endif()
-    string(REGEX MATCHALL "([A-Za-z0-9]+)" _all_compileid_matches "${_compileid}")
+    string(REGEX MATCHALL "([A-Za-z0-9-]+)" _all_compileid_matches "${_compileid}")
     if(_all_compileid_matches)
       list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID)
     endif()
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 8f5747a..542a6fe 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -165,6 +165,9 @@
 # elif defined(__ICCRL78__)
 #  define ARCHITECTURE_ID "RL78"
 
+# elif defined(__ICCRISCV__)
+#  define ARCHITECTURE_ID "RISCV"
+
 # elif defined(__ICCAVR__)
 #  define ARCHITECTURE_ID "AVR"
 
diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake
index 71f2ac6..437678e 100644
--- a/Modules/Compiler/IAR-ASM.cmake
+++ b/Modules/Compiler/IAR-ASM.cmake
@@ -22,6 +22,11 @@
   __compiler_iar_ilink(ASM)
   set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
 
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISC-V")
+  set(CMAKE_ASM_COMPILE_OBJECT  "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+  __compiler_iar_ilink(ASM)
+  set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
+
 elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
   set(CMAKE_ASM_COMPILE_OBJECT  "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
   __compiler_iar_xlink(ASM)
diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake
index 4b02a9a..18a4a75 100644
--- a/Modules/Compiler/IAR-C.cmake
+++ b/Modules/Compiler/IAR-C.cmake
@@ -46,6 +46,10 @@
   __compiler_iar_ilink(C)
   __compiler_check_default_language_standard(C 1.10 90 1.10 99 4.10 11)
 
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV")
+  __compiler_iar_ilink(C)
+  __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11)
+
 elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
   __compiler_iar_xlink(C)
   __compiler_check_default_language_standard(C 7.10 99)
diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake
index 22ec118..e8f1142 100644
--- a/Modules/Compiler/IAR-CXX.cmake
+++ b/Modules/Compiler/IAR-CXX.cmake
@@ -55,6 +55,10 @@
   __compiler_iar_ilink(CXX)
   __compiler_check_default_language_standard(CXX 1.10 98 4.10 14)
 
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV")
+  __compiler_iar_ilink(CXX)
+  __compiler_check_default_language_standard(CXX 1.10 98 1.10 14)
+
 elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
   __compiler_iar_xlink(CXX)
   __compiler_check_default_language_standard(CXX 7.10 98)
diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake
index 6b09c40..57ca1c9 100644
--- a/Modules/Compiler/IAR-DetermineCompiler.cmake
+++ b/Modules/Compiler/IAR-DetermineCompiler.cmake
@@ -31,7 +31,7 @@
 #  define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000)
 #  define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000)
 #  define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
-# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__))
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__))
 #  define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100)
 #  define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100))
 #  define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__)
diff --git a/Modules/Compiler/IAR-FindBinUtils.cmake b/Modules/Compiler/IAR-FindBinUtils.cmake
index 3f13dce..b7d4664 100644
--- a/Modules/Compiler/IAR-FindBinUtils.cmake
+++ b/Modules/Compiler/IAR-FindBinUtils.cmake
@@ -13,7 +13,8 @@
 if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" OR
    "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX" OR
    "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850" OR
-   "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78")
+   "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78" OR
+   "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV")
 
   string(TOLOWER "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" _archid_lower)
 
diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake
index 433eae7..dfece22 100644
--- a/Modules/FindPostgreSQL.cmake
+++ b/Modules/FindPostgreSQL.cmake
@@ -172,14 +172,21 @@
 # any PostgreSQL_LIBRARY that is already specified and skip the search.
 if(PostgreSQL_LIBRARY)
   set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}")
+  get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH)
 else()
   __postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND})
   __postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d)
   include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
   select_library_configurations(PostgreSQL)
   mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG)
+  if(PostgreSQL_LIBRARY_RELEASE)
+    get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH)
+  elseif(PostgreSQL_LIBRARY_DEBUG)
+    get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH)
+  else()
+    set(PostgreSQL_LIBRARY_DIR "")
+  endif()
 endif()
-get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
 
 if (PostgreSQL_INCLUDE_DIR)
   # Some platforms include multiple pg_config.hs for multi-lib configurations
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index df0f33f..4eba4ff 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1681,6 +1681,7 @@
   cmDeleteAll(this->LocalGenerators);
   this->LocalGenerators.clear();
 
+  this->AliasTargets.clear();
   this->ExportSets.clear();
   this->TargetDependencies.clear();
   this->TargetSearchIndex.clear();
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index d27da3e..8d2add6 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -90,12 +90,17 @@
     }
 
     if (item.Target) {
-      bool skip = true;
-      if (item.Target->GetType() == cmStateEnums::STATIC_LIBRARY) {
-        if ((!item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS")) &&
-            item.Target->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) {
-          skip = false;
-        }
+      bool skip = false;
+      switch (item.Target->GetType()) {
+        case cmStateEnums::MODULE_LIBRARY:
+        case cmStateEnums::INTERFACE_LIBRARY:
+          skip = true;
+          break;
+        case cmStateEnums::STATIC_LIBRARY:
+          skip = item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
+          break;
+        default:
+          break;
       }
       if (skip) {
         continue;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 64026ca..a6348b3 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -96,7 +96,7 @@
     "Generate graphviz of dependencies, see "
     "CMakeGraphVizOptions.cmake for more." },
   { "--system-information [file]", "Dump information about this system." },
-  { "--loglevel=<error|warn|notice|status|verbose|debug|trace>",
+  { "--loglevel=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE>",
     "Set the verbosity of messages from CMake files." },
   { "--debug-trycompile",
     "Do not delete the try_compile build tree. Only "