Merge topic 'test-clang-15'

91987aec24 Tests: Add missing return types to C function prototypes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !7260
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 1b81778..b92c679 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -1351,6 +1351,14 @@
       list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
     endif()
 
+    # Override the sub-build's configuration types for multi-config generators.
+    # This ensures we are not affected by any custom setting from the project
+    # and can always request a known configuration further below.
+    get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+    if(is_multi_config)
+      list(APPEND subCMakeOpts "-DCMAKE_CONFIGURATION_TYPES:STRING=Release")
+    endif()
+
   else()
     # Likely we've been invoked via CMake's script mode where no
     # generator is set (and hence CMAKE_MAKE_PROGRAM could not be
@@ -1395,7 +1403,8 @@
   # If we've already previously done these steps, they will not cause
   # anything to be updated, so extra rebuilds of the project won't occur.
   # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project
-  # has this set to something not findable on the PATH.
+  # has this set to something not findable on the PATH. We also ensured above
+  # that the Release config will be defined for multi-config generators.
   configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FetchContent/CMakeLists.cmake.in"
                  "${ARG_SUBBUILD_DIR}/CMakeLists.txt")
   execute_process(
@@ -1411,7 +1420,7 @@
     message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}")
   endif()
   execute_process(
-    COMMAND ${CMAKE_COMMAND} --build .
+    COMMAND ${CMAKE_COMMAND} --build . --config Release
     RESULT_VARIABLE result
     ${outputOptions}
     WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index c285898..4433f06 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 23)
-set(CMake_VERSION_PATCH 20220513)
+set(CMake_VERSION_PATCH 20220516)
 #set(CMake_VERSION_RC 0)
 set(CMake_VERSION_IS_DIRTY 0)
 
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index d5d08b8..00c65ed 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -171,14 +171,15 @@
     code.clear();
   }
 
-  if (arch.empty() && gencode.empty()) {
-    return;
-  }
-
   // Create a CodeGeneration field with [arch],[code] syntax in each entry.
   // CUDA will convert it to `-gencode=arch=[arch],code="[code],[arch]"`.
   FlagValue& result = this->FlagMap["CodeGeneration"];
 
+  // If there are no flags, leave the CodeGeneration field empty.
+  if (arch.empty() && gencode.empty()) {
+    return;
+  }
+
   // First entries for the -arch=<arch> [-code=<code>,...] pair.
   if (!arch.empty()) {
     std::string arch_name = arch[0];