Merge topic 'ninja-swift-verbosity'

c5ef7fac23 Swift/Ninja: Add description to Swift object build steps

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9451
diff --git a/.gitlab/ci/cmake-env.ps1 b/.gitlab/ci/cmake-env.ps1
new file mode 100755
index 0000000..505fa44
--- /dev/null
+++ b/.gitlab/ci/cmake-env.ps1
@@ -0,0 +1,5 @@
+$pwdpath = $pwd.Path
+& "$pwsh" -File ".gitlab/ci/cmake.ps1"
+Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\cmake\bin;$env:PATH"
+cmake --version
+$cmake = "cmake"
diff --git a/.gitlab/ci/cmake-env.sh b/.gitlab/ci/cmake-env.sh
new file mode 100644
index 0000000..686a78f
--- /dev/null
+++ b/.gitlab/ci/cmake-env.sh
@@ -0,0 +1,3 @@
+.gitlab/ci/cmake.sh
+export PATH="$PWD/.gitlab/cmake/bin:$PATH"
+cmake --version
diff --git a/.gitlab/ci/ninja-env.sh b/.gitlab/ci/ninja-env.sh
new file mode 100644
index 0000000..744b9f3
--- /dev/null
+++ b/.gitlab/ci/ninja-env.sh
@@ -0,0 +1,3 @@
+.gitlab/ci/ninja.sh
+export PATH=$PWD/.gitlab:$PATH
+ninja --version
diff --git a/.gitlab/ci/sccache-env.ps1 b/.gitlab/ci/sccache-env.ps1
new file mode 100755
index 0000000..66dc6eb
--- /dev/null
+++ b/.gitlab/ci/sccache-env.ps1
@@ -0,0 +1 @@
+Set-Item -Force -Path "env:PATH" -Value "$env:PATH;$env:SCCACHE_PATH"
diff --git a/.gitlab/ci/sccache-env.sh b/.gitlab/ci/sccache-env.sh
new file mode 100644
index 0000000..4b170a4
--- /dev/null
+++ b/.gitlab/ci/sccache-env.sh
@@ -0,0 +1,2 @@
+.gitlab/ci/sccache.sh
+export PATH="$PWD/.gitlab:$PATH"
diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml
index dc32016..03778c2 100644
--- a/.gitlab/os-linux.yml
+++ b/.gitlab/os-linux.yml
@@ -511,12 +511,8 @@
 
 .before_script_linux: &before_script_linux
     - source .gitlab/ci/env.sh
-    - .gitlab/ci/cmake.sh
-    - export PATH=$PWD/.gitlab/cmake/bin:$PATH
-    - .gitlab/ci/ninja.sh
-    - export PATH=$PWD/.gitlab:$PATH
-    - cmake --version
-    - ninja --version
+    - source .gitlab/ci/cmake-env.sh
+    - source .gitlab/ci/ninja-env.sh
 
 .cmake_prep_source_linux:
     stage: prep
@@ -591,8 +587,7 @@
         - mkdir -p build/
         - cp Utilities/Release/linux/$CMAKE_ARCH/cache.txt build/CMakeCache.txt
         # Make sccache available.
-        - .gitlab/ci/sccache.sh
-        - export PATH=$PWD/.gitlab:$PATH
+        - source .gitlab/ci/sccache-env.sh
         # Append sccache settings to the cache.
         - echo "CMAKE_C_COMPILER_LAUNCHER:STRING=sccache" >> build/CMakeCache.txt
         - echo "CMAKE_CXX_COMPILER_LAUNCHER:STRING=sccache" >> build/CMakeCache.txt
diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml
index 23c68d5..894d624 100644
--- a/.gitlab/os-macos.yml
+++ b/.gitlab/os-macos.yml
@@ -175,12 +175,8 @@
 
 .before_script_macos: &before_script_macos
     - source .gitlab/ci/env.sh
-    - .gitlab/ci/cmake.sh
-    - export PATH=$PWD/.gitlab/cmake/bin:$PATH
-    - .gitlab/ci/ninja.sh
-    - export PATH=$PWD/.gitlab:$PATH
-    - cmake --version
-    - ninja --version
+    - source .gitlab/ci/cmake-env.sh
+    - source .gitlab/ci/ninja-env.sh
     # Download Qt
     - cmake -P .gitlab/ci/download_qt.cmake
     - export CMAKE_PREFIX_PATH=$PWD/.gitlab/qt${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}
diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml
index 3cd6e56..1372136 100644
--- a/.gitlab/os-windows.yml
+++ b/.gitlab/os-windows.yml
@@ -386,12 +386,8 @@
 
 .before_script_windows: &before_script_windows
     - . .gitlab/ci/env.ps1
-    - $pwdpath = $pwd.Path
-    - (& "$pwsh" -File ".gitlab/ci/cmake.ps1")
-    - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\cmake\bin;$env:PATH"
-    - $cmake = "cmake"
+    - . .gitlab/ci/cmake-env.ps1
     - . .gitlab/ci/ninja-env.ps1
-    - cmake --version
     - . .gitlab/ci/qt-env.ps1
     - . .gitlab/ci/python-env.ps1
 
@@ -404,7 +400,7 @@
 
     script:
         - *before_script_windows
-        - Set-Item -Force -Path "env:PATH" -Value "$env:PATH;$env:SCCACHE_PATH"
+        - . .gitlab/ci/sccache-env.ps1
         - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1
         - sccache --start-server
         - sccache --show-stats
diff --git a/Modules/CheckForPthreads.c b/Modules/CheckForPthreads.c
index e70ceb1..ea1f7ac 100644
--- a/Modules/CheckForPthreads.c
+++ b/Modules/CheckForPthreads.c
@@ -1,6 +1,6 @@
 #include <pthread.h>
 
-void* start_routine(void* args)
+static void* start_routine(void* args)
 {
   return args;
 }
diff --git a/Modules/Compiler/MSVC-CXX-CXXImportStd.cmake b/Modules/Compiler/MSVC-CXX-CXXImportStd.cmake
index 9966b9b..f253f9e 100644
--- a/Modules/Compiler/MSVC-CXX-CXXImportStd.cmake
+++ b/Modules/Compiler/MSVC-CXX-CXXImportStd.cmake
@@ -6,6 +6,7 @@
     PATHS
       "$ENV{INCLUDE}"
       "${CMAKE_CXX_COMPILER}/../../.."
+      "${CMAKE_CXX_COMPILER}/../.."    # msvc-wine layout
     PATH_SUFFIXES
       ../modules
     NO_CACHE)
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index bc17f19..44d09f5 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -439,7 +439,7 @@
 nvidia-ML
 """""""""
 
-The `NVIDIA Management Library <https://developer.nvidia.com/nvidia-management-library-nvml>`_.
+The `NVIDIA Management Library <https://developer.nvidia.com/management-library-nvml>`_.
 This is a shared library only.
 
 Targets Created:
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index f3bacc3..450acf4 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -158,6 +158,17 @@
       string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
     endif()
 
+    # pkg-config <0.29.1 and pkgconf <1.5.1 prints quoted variables without unquoting
+    # unquote only if quotes are first and last characters
+    if((PKG_CONFIG_VERSION_STRING VERSION_LESS 0.29.1) OR
+        (PKG_CONFIG_VERSION_STRING VERSION_GREATER_EQUAL 1.0 AND PKG_CONFIG_VERSION_STRING VERSION_LESS 1.5.1))
+      if (_pkgconfig_invoke_result MATCHES "^\"(.*)\"$")
+        set(_pkgconfig_invoke_result "${CMAKE_MATCH_1}")
+      elseif(_pkgconfig_invoke_result MATCHES "^'(.*)'$")
+        set(_pkgconfig_invoke_result "${CMAKE_MATCH_1}")
+      endif()
+    endif()
+
     # pkg-config can represent "spaces within an argument" by backslash-escaping the space.
     # UNIX_COMMAND mode treats backslash-escaped spaces as "not a space that delimits arguments".
     separate_arguments(_pkgconfig_invoke_result UNIX_COMMAND "${_pkgconfig_invoke_result}")
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 0603ec0..0dc7d96 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 29)
-set(CMake_VERSION_PATCH 20240422)
+set(CMake_VERSION_PATCH 20240424)
 #set(CMake_VERSION_RC 0)
 set(CMake_VERSION_IS_DIRTY 0)
 
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 7dd5ffa..8067694 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1095,7 +1095,7 @@
   bool& keepLastKnownFileType, const std::vector<std::string>& enabled_langs)
 {
   std::string ext = cmSystemTools::LowerCase(_ext);
-  std::string sourcecode = "sourcecode";
+  std::string sourcecode = "default";
 
   if (ext == "o"_s) {
     keepLastKnownFileType = true;
@@ -1110,42 +1110,42 @@
     sourcecode = "file.storyboard";
     // NOLINTNEXTLINE(bugprone-branch-clone)
   } else if (ext == "mm"_s && !cm::contains(enabled_langs, "OBJCXX")) {
-    sourcecode += ".cpp.objcpp";
+    sourcecode = "sourcecode.cpp.objcpp";
     // NOLINTNEXTLINE(bugprone-branch-clone)
   } else if (ext == "m"_s && !cm::contains(enabled_langs, "OBJC")) {
-    sourcecode += ".c.objc";
+    sourcecode = "sourcecode.c.objc";
   } else if (ext == "swift"_s) {
-    sourcecode += ".swift";
+    sourcecode = "sourcecode.swift";
   } else if (ext == "plist"_s) {
-    sourcecode += ".text.plist";
+    sourcecode = "sourcecode.text.plist";
   } else if (ext == "h"_s) {
-    sourcecode += ".c.h";
+    sourcecode = "sourcecode.c.h";
   } else if (ext == "hxx"_s || ext == "hpp"_s || ext == "txx"_s ||
              ext == "pch"_s || ext == "hh"_s || ext == "inl"_s) {
-    sourcecode += ".cpp.h";
+    sourcecode = "sourcecode.cpp.h";
   } else if (ext == "png"_s || ext == "gif"_s || ext == "jpg"_s) {
     keepLastKnownFileType = true;
     sourcecode = "image";
   } else if (ext == "txt"_s) {
-    sourcecode += ".text";
+    sourcecode = "sourcecode.text";
   } else if (lang == "CXX"_s) {
-    sourcecode += ".cpp.cpp";
+    sourcecode = "sourcecode.cpp.cpp";
   } else if (lang == "C"_s) {
-    sourcecode += ".c.c";
+    sourcecode = "sourcecode.c.c";
   } else if (lang == "OBJCXX"_s) {
-    sourcecode += ".cpp.objcpp";
+    sourcecode = "sourcecode.cpp.objcpp";
   } else if (lang == "OBJC"_s) {
-    sourcecode += ".c.objc";
+    sourcecode = "sourcecode.c.objc";
   } else if (lang == "Fortran"_s) {
-    sourcecode += ".fortran.f90";
+    sourcecode = "sourcecode.fortran.f90";
   } else if (lang == "ASM"_s) {
-    sourcecode += ".asm";
+    sourcecode = "sourcecode.asm";
   } else if (ext == "metal"_s) {
-    sourcecode += ".metal";
+    sourcecode = "sourcecode.metal";
   } else if (ext == "mig"_s) {
-    sourcecode += ".mig";
+    sourcecode = "sourcecode.mig";
   } else if (ext == "tbd"_s) {
-    sourcecode += ".text-based-dylib-definition";
+    sourcecode = "sourcecode.text-based-dylib-definition";
   } else if (ext == "a"_s) {
     keepLastKnownFileType = true;
     sourcecode = "archive.ar";
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_MULTIPLE_VALUES.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_MULTIPLE_VALUES.cmake
new file mode 100644
index 0000000..19ee908
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_MULTIPLE_VALUES.cmake
@@ -0,0 +1,31 @@
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+if(WIN32)
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch")
+else()
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch")
+endif()
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(BLETCH QUIET bletch)
+
+if (NOT BLETCH_FOUND)
+  message(FATAL_ERROR "Failed to find embedded package bletch via CMAKE_PREFIX_PATH")
+endif ()
+
+set(expected_value "item1;item2;item3;item with spaces")
+pkg_get_variable(bletchvar1 bletch multiple_values1)
+pkg_get_variable(bletchvar2 bletch multiple_values2)
+
+string(FIND "${bletchvar1}" ";" IS_VARIABLE_A_LIST1)
+string(FIND "${bletchvar2}" ";" IS_VARIABLE_A_LIST2)
+
+if (IS_VARIABLE_A_LIST1 EQUAL -1 OR IS_VARIABLE_A_LIST2 EQUAL -1)
+  message(FATAL_ERROR "Failed to fetch variable multiple_values from embedded package bletch as a list")
+endif()
+
+if (NOT (bletchvar1 STREQUAL expected_value AND bletchvar2 STREQUAL expected_value))
+  message(NOTICE "multiple_values1=${bletchvar1} and expected_value=${expected_value}")
+  message(NOTICE "multiple_values2=${bletchvar2} and expected_value=${expected_value}")
+  message(FATAL_ERROR "Failed to fetch variable multiple_values from embedded package bletch with escaped spaces")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 7af425a..3466636 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -54,6 +54,7 @@
   run_cmake(FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES)
   run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH)
   run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH)
+  run_cmake(FindPkgConfig_GET_VARIABLE_MULTIPLE_VALUES)
   run_cmake(FindPkgConfig_cache_variables)
   run_cmake(FindPkgConfig_IMPORTED_TARGET)
   run_cmake(FindPkgConfig_VERSION_OPERATORS)
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc
index 04d2c1b..87c3613 100644
--- a/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc
+++ b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc
@@ -4,9 +4,11 @@
 includedir=${prefix}/include
 
 jackpot=bletch-lives
+multiple_values1="item1 item2 item3 item\ with\ spaces"
+multiple_values2='item1 item2 item3 item\ with\ spaces'
 
 Name: Bletch
-Description: Dummy packaget to test variable support
+Description: Dummy package to test variable support
 Version: 1.0
 Libs: -L${libdir} -lbletch
 Cflags: -Dbletch_version=1
diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
index 1847bc9..48b4680 100644
--- a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
@@ -1,4 +1,4 @@
-set(expect-default "explicitFileType = sourcecode")
+set(expect-default "explicitFileType = default")
 set(expect-explicit "explicitFileType = sourcecode.c.h")
 set(expect-lastKnown "lastKnownFileType = sourcecode.c.h")
 foreach(src default explicit lastKnown)