diff options
68 files changed, 725 insertions, 204 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c81b37..b26172d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1051,7 +1051,7 @@ t:windows-vs2019-x64: t:windows-vs2022-x64-nmake: extends: - .windows_vs2022_x64_nmake - - .cmake_test_windows_nmake + - .cmake_test_windows_external - .windows_x86_64_tags_concurrent_vs2022 - .cmake_junit_artifacts - .run_dependent @@ -1065,7 +1065,7 @@ t:windows-vs2022-x64-nmake: t:windows-vs2022-x64-jom: extends: - .windows_vs2022_x64_jom - - .cmake_test_windows_jom + - .cmake_test_windows_external - .windows_x86_64_tags_concurrent_vs2022 - .cmake_junit_artifacts - .run_dependent @@ -1079,7 +1079,7 @@ t:windows-vs2022-x64-jom: t:windows-borland5.5: extends: - .windows_borland5.5 - - .cmake_test_windows_borland + - .cmake_test_windows_external - .windows_x86_64_tags_concurrent - .cmake_junit_artifacts - .run_dependent @@ -1093,7 +1093,7 @@ t:windows-borland5.5: t:windows-borland5.8: extends: - .windows_borland5.8 - - .cmake_test_windows_borland + - .cmake_test_windows_external - .windows_x86_64_tags_concurrent - .cmake_junit_artifacts - .run_dependent @@ -1195,7 +1195,7 @@ t:mingw_osdn_io-msys_makefiles: t:windows-msvc-v71-nmake: extends: - .windows_msvc_v71_nmake - - .cmake_test_windows_msvc + - .cmake_test_windows_external - .windows_x86_64_tags_concurrent - .cmake_junit_artifacts - .run_dependent @@ -1209,7 +1209,7 @@ t:windows-msvc-v71-nmake: t:windows-openwatcom1.9: extends: - .windows_openwatcom1.9 - - .cmake_test_windows_openwatcom + - .cmake_test_windows_external - .windows_x86_64_tags_concurrent - .cmake_junit_artifacts - .run_dependent diff --git a/.gitlab/ci/borland-env.ps1 b/.gitlab/ci/borland-env.ps1 new file mode 100755 index 0000000..b3b532e --- /dev/null +++ b/.gitlab/ci/borland-env.ps1 @@ -0,0 +1,3 @@ +Invoke-Expression -Command .gitlab/ci/borland.ps1 +$pwdpath = $pwd.Path +Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\bcc\bin;$env:PATH" diff --git a/.gitlab/ci/download_python3.cmake b/.gitlab/ci/download_python3.cmake deleted file mode 100644 index 0f5b18b..0000000 --- a/.gitlab/ci/download_python3.cmake +++ /dev/null @@ -1,41 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -set(version "3.8.6") -set(sha256sum "376e18eef7e3ea467f0e3af041b01fc7e2f12855506c2ab2653ceb5e0951212e") -set(dirname "python-${version}-embed-win-x86_64") -set(tarball "${dirname}.tar.xz") - -# Download the file. -file(DOWNLOAD - "https://cmake.org/files/dependencies/${tarball}" - ".gitlab/${tarball}" - STATUS download_status - EXPECTED_HASH "SHA256=${sha256sum}") - -# Check the download status. -list(GET download_status 0 res) -if (res) - list(GET download_status 1 err) - message(FATAL_ERROR - "Failed to download ${tarball}: ${err}") -endif () - -# Extract the file. -execute_process( - COMMAND - "${CMAKE_COMMAND}" - -E tar - xzf "${tarball}" - WORKING_DIRECTORY ".gitlab" - RESULT_VARIABLE res - ERROR_VARIABLE err - ERROR_STRIP_TRAILING_WHITESPACE) -if (res) - message(FATAL_ERROR - "Failed to extract ${tarball}: ${err}") -endif () - -# Move to a predictable directory. -file(RENAME - ".gitlab/${dirname}" - ".gitlab/python3") diff --git a/.gitlab/ci/env_windows_borland5.5.ps1 b/.gitlab/ci/env_windows_borland5.5.ps1 new file mode 100755 index 0000000..0d2e46b --- /dev/null +++ b/.gitlab/ci/env_windows_borland5.5.ps1 @@ -0,0 +1 @@ +. .gitlab/ci/borland-env.ps1 diff --git a/.gitlab/ci/env_windows_borland5.8.ps1 b/.gitlab/ci/env_windows_borland5.8.ps1 new file mode 100755 index 0000000..0d2e46b --- /dev/null +++ b/.gitlab/ci/env_windows_borland5.8.ps1 @@ -0,0 +1 @@ +. .gitlab/ci/borland-env.ps1 diff --git a/.gitlab/ci/env_windows_msvc_v71_nmake.ps1 b/.gitlab/ci/env_windows_msvc_v71_nmake.ps1 new file mode 100755 index 0000000..cb3806d --- /dev/null +++ b/.gitlab/ci/env_windows_msvc_v71_nmake.ps1 @@ -0,0 +1,2 @@ +Invoke-Expression -Command .gitlab/ci/msvc.ps1 +Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 diff --git a/.gitlab/ci/env_windows_openwatcom1.9.ps1 b/.gitlab/ci/env_windows_openwatcom1.9.ps1 new file mode 100755 index 0000000..49c28f7 --- /dev/null +++ b/.gitlab/ci/env_windows_openwatcom1.9.ps1 @@ -0,0 +1 @@ +. .gitlab/ci/openwatcom-env.ps1 diff --git a/.gitlab/ci/env_windows_vs2022_x64_jom.ps1 b/.gitlab/ci/env_windows_vs2022_x64_jom.ps1 new file mode 100755 index 0000000..c933421 --- /dev/null +++ b/.gitlab/ci/env_windows_vs2022_x64_jom.ps1 @@ -0,0 +1,4 @@ +Invoke-Expression -Command .gitlab/ci/jom.ps1 +$pwdpath = $pwd.Path +Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\jom;$env:PATH" +Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 diff --git a/.gitlab/ci/env_windows_vs2022_x64_nmake.ps1 b/.gitlab/ci/env_windows_vs2022_x64_nmake.ps1 new file mode 100755 index 0000000..62463cd --- /dev/null +++ b/.gitlab/ci/env_windows_vs2022_x64_nmake.ps1 @@ -0,0 +1 @@ +Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 diff --git a/.gitlab/ci/openwatcom-env.ps1 b/.gitlab/ci/openwatcom-env.ps1 new file mode 100755 index 0000000..14ea523 --- /dev/null +++ b/.gitlab/ci/openwatcom-env.ps1 @@ -0,0 +1,7 @@ +Invoke-Expression -Command .gitlab/ci/openwatcom.ps1 +$pwdpath = $pwd.Path +Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\watcom\binnt;$pwdpath\.gitlab\watcom\binw;$env:PATH" +Set-Item -Force -Path "env:INCLUDE" -Value "$pwdpath\.gitlab\watcom\h;$pwdpath\.gitlab\watcom\h\nt" +Set-Item -Force -Path "env:EDPATH" -Value "$pwdpath\.gitlab\watcom\eddat" +Set-Item -Force -Path "env:WATCOM" -Value "$pwdpath\.gitlab\watcom" +Set-Item -Force -Path "env:WLINKTMP" -Value "." diff --git a/.gitlab/ci/python-env.ps1 b/.gitlab/ci/python-env.ps1 index 4e897d8..ce16493 100755 --- a/.gitlab/ci/python-env.ps1 +++ b/.gitlab/ci/python-env.ps1 @@ -1,4 +1,4 @@ $pwdpath = $pwd.Path -cmake -P .gitlab/ci/download_python3.cmake +& "$pwsh" -File ".gitlab/ci/python.ps1" Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\python3;$env:PATH" python --version diff --git a/.gitlab/ci/python.ps1 b/.gitlab/ci/python.ps1 new file mode 100755 index 0000000..27f1807 --- /dev/null +++ b/.gitlab/ci/python.ps1 @@ -0,0 +1,30 @@ +$erroractionpreference = "stop" + +$version = "3.11.3" + +if ("$env:PROCESSOR_ARCHITECTURE" -eq "AMD64") { + $sha256sum = "7419B2E98516FBD0B66A1237B80187FFB21D32E47B4A4235C2D9D6379597070F" + $arch = "amd64" +} elseif ("$env:PROCESSOR_ARCHITECTURE" -eq "ARM64") { + $sha256sum = "03BAD6A7C898FC8F693982437AAB6DB698107B82EA93F76424195AE2C161246C" + $arch = "arm64" +} else { + throw ('unknown PROCESSOR_ARCHITECTURE: ' + "$env:PROCESSOR_ARCHITECTURE") +} + +$filename = "python-$version-embed-$arch" +$tarball = "$filename.zip" + +$outdir = $pwd.Path +$outdir = "$outdir\.gitlab" +$ProgressPreference = 'SilentlyContinue' +Invoke-WebRequest -Uri "https://cmake.org/files/dependencies/internal/$tarball" -OutFile "$outdir\$tarball" +$hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256 +if ($hash.Hash -ne $sha256sum) { + exit 1 +} + +Add-Type -AssemblyName System.IO.Compression.FileSystem +[System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir\python3") +Remove-Item "$outdir\python3\*._pth" # Avoid sys.path specific to embedded python. +Remove-Item "$outdir\$tarball" diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index ded3e65..f1e86ad 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -349,6 +349,10 @@ - . .gitlab/ci/qt-env.ps1 - . .gitlab/ci/python-env.ps1 +.before_script_windows_external: &before_script_windows_external + - . .gitlab/ci/env.ps1 + - . .gitlab/ci/python-env.ps1 + .cmake_build_windows: stage: build @@ -381,69 +385,7 @@ stage: test-ext script: - - . .gitlab/ci/env.ps1 - - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake - - interruptible: true - -.cmake_test_windows_nmake: - stage: test-ext - - script: - - . .gitlab/ci/env.ps1 - - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake - - interruptible: true - -.cmake_test_windows_jom: - stage: test-ext - - script: - - . .gitlab/ci/env.ps1 - - Invoke-Expression -Command .gitlab/ci/jom.ps1 - - $pwdpath = $pwd.Path - - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\jom;$env:PATH" - - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake - - interruptible: true - -.cmake_test_windows_borland: - stage: test-ext - - script: - - . .gitlab/ci/env.ps1 - - Invoke-Expression -Command .gitlab/ci/borland.ps1 - - $pwdpath = $pwd.Path - - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\bcc\bin;$env:PATH" - - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake - - interruptible: true - -.cmake_test_windows_msvc: - stage: test-ext - - script: - - . .gitlab/ci/env.ps1 - - Invoke-Expression -Command .gitlab/ci/msvc.ps1 - - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake - - interruptible: true - -.cmake_test_windows_openwatcom: - stage: test-ext - - script: - - . .gitlab/ci/env.ps1 - - Invoke-Expression -Command .gitlab/ci/openwatcom.ps1 - - $pwdpath = $pwd.Path - - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\watcom\binnt;$pwdpath\.gitlab\watcom\binw;$env:PATH" - - Set-Item -Force -Path "env:INCLUDE" -Value "$pwdpath\.gitlab\watcom\h;$pwdpath\.gitlab\watcom\h\nt" - - Set-Item -Force -Path "env:EDPATH" -Value "$pwdpath\.gitlab\watcom\eddat" - - Set-Item -Force -Path "env:WATCOM" -Value "$pwdpath\.gitlab\watcom" - - Set-Item -Force -Path "env:WLINKTMP" -Value "." + - *before_script_windows_external - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake interruptible: true diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index a11becb..7590ee3 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -372,7 +372,7 @@ optional argument topic will be appended to the argument list." (interactive "s") (let* ((bufname (if buffer buffer (concat "*CMake" type (if topic "-") topic "*"))) (buffer (if (get-buffer bufname) (get-buffer bufname) (generate-new-buffer bufname))) - (command (concat cmake-mode-cmake-executable " " type " " topic)) + (command (concat cmake-mode-cmake-executable " " type " " (shell-quote-argument topic))) ;; Turn of resizing of mini-windows for shell-command. (resize-mini-windows nil) ) @@ -391,7 +391,7 @@ optional argument topic will be appended to the argument list." (interactive "s") (let* ((bufname (if buffer buffer (concat "*CMake" type (if topic "-") topic "*"))) (buffer (if (get-buffer bufname) (get-buffer bufname) (generate-new-buffer bufname))) - (command (concat cmake-mode-cmake-executable " " type " " topic)) + (command (concat cmake-mode-cmake-executable " " type " " (shell-quote-argument topic))) ;; Turn of resizing of mini-windows for shell-command. (resize-mini-windows nil) ) diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index 0ccebc6..869d0c2 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -11,6 +11,11 @@ Adds options to the :prop_dir:`COMPILE_OPTIONS` directory property. These options are used when compiling targets from the current directory and below. +.. note:: + + These options are not used when linking. + See the :command:`add_link_options` command for that. + Arguments ^^^^^^^^^ @@ -48,5 +53,15 @@ See Also * The command :command:`target_compile_options` adds target-specific options. +* This command adds compile options for all languages. + Use the :genex:`COMPILE_LANGUAGE` generator expression to specify + per-language compile options. + * The source file property :prop_sf:`COMPILE_OPTIONS` adds options to one source file. + +* :command:`add_link_options` adds options for linking. + +* :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst index c09e106..df72715 100644 --- a/Help/command/add_link_options.rst +++ b/Help/command/add_link_options.rst @@ -38,3 +38,7 @@ See Also * :command:`link_libraries` * :command:`target_link_libraries` * :command:`target_link_options` + +* :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index f3ac97b..7cfb24b 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -15,6 +15,11 @@ are used when compiling the given ``<target>``, which must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. +.. note:: + + These options are not used when linking the target. + See the :command:`target_link_options` command for that. + Arguments ^^^^^^^^^ @@ -60,3 +65,7 @@ See Also * :command:`target_link_options` * :command:`target_precompile_headers` * :command:`target_sources` + +* :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/command/target_link_options.rst b/Help/command/target_link_options.rst index 0d026f2..dca9598 100644 --- a/Help/command/target_link_options.rst +++ b/Help/command/target_link_options.rst @@ -62,3 +62,7 @@ See Also * :command:`target_link_directories` * :command:`target_precompile_headers` * :command:`target_sources` + +* :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` + add language-wide flags passed to all invocations of the compiler. + This includes invocations that drive compiling and those that drive linking. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 158bf62..8c7189a 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.27 .. toctree:: :maxdepth: 1 + CMP0149: Visual Studio generators select latest Windows SDK by default. </policy/CMP0149> CMP0148: The FindPythonInterp and FindPythonLibs modules are removed. </policy/CMP0148> CMP0147: Visual Studio generators build custom commands in parallel. </policy/CMP0147> CMP0146: The FindCUDA module is removed. </policy/CMP0146> diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 9feb4d2..a831fa6 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -273,7 +273,7 @@ supported out of the box. Other versions may require one to set Cross Compiling for Windows 10 Universal Applications ----------------------------------------------------- -A toolchain file to configure a Visual Studio generator for a +A toolchain file to configure :ref:`Visual Studio Generators` for a Windows 10 Universal Application may look like this: .. code-block:: cmake @@ -283,9 +283,10 @@ Windows 10 Universal Application may look like this: A Windows 10 Universal Application targets both Windows Store and Windows Phone. Specify the :variable:`CMAKE_SYSTEM_VERSION` variable -to be ``10.0`` to build with the latest available Windows 10 SDK. -Specify a more specific version (e.g. ``10.0.10240.0`` for RTM) -to build with the corresponding SDK. +to be ``10.0`` or higher. + +CMake selects a Windows SDK as described by documentation of the +:variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable. Cross Compiling for Windows Phone --------------------------------- diff --git a/Help/policy/CMP0149.rst b/Help/policy/CMP0149.rst new file mode 100644 index 0000000..714eeaf --- /dev/null +++ b/Help/policy/CMP0149.rst @@ -0,0 +1,47 @@ +CMP0149 +------- + +.. versionadded:: 3.27 + +:ref:`Visual Studio Generators` select latest Windows SDK by default. + +Visual Studio Generators select a Windows SDK version to put in the +``WindowsTargetPlatformVersion`` setting in ``.vcxproj`` files. +CMake sets the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` +variable to the selected SDK version. + +Prior to CMake 3.27, the SDK version was always selected by the value of +the :variable:`CMAKE_SYSTEM_VERSION` variable. Users or toolchain files +could set that variable to one of the exact Windows SDK versions available +on the host system. Since :variable:`CMAKE_SYSTEM_VERSION` defaults to +:variable:`CMAKE_HOST_SYSTEM_VERSION`, and it is not guaranteed that a +matching Windows SDK version is available, CMake had to fall back to +using the latest Windows SDK version if no exact match was available. +This approach was problematic: + +* The latest Windows SDK might or might not be selected based on whether + the host version of Windows happens to match an available SDK version. + +* An old Windows SDK version might be selected that has not been updated + for newer language standards such as C11. + +CMake 3.27 and higher prefer to ignore the exact value of +:variable:`CMAKE_SYSTEM_VERSION` and by default select the latest SDK +version available. An exact SDK version may be specified explicitly +using a ``version=`` field in the :variable:`CMAKE_GENERATOR_PLATFORM` +variable. See :ref:`Visual Studio Platform Selection`. + +This policy provides compatibility for projects, toolchain files, and +build scripts that have not been ported away from using +:variable:`CMAKE_SYSTEM_VERSION` to specify an exact SDK version. + +The ``OLD`` behavior for this policy is to use the exact value of +:variable:`CMAKE_SYSTEM_VERSION` if possible. The ``NEW`` behavior +for this policy is to ignore it. + +This policy was introduced in CMake version 3.27. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike many policies, CMake version |release| does *not* warn +when this policy is not set and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst index 0dec250..8b032ad 100644 --- a/Help/prop_tgt/COMPILE_OPTIONS.rst +++ b/Help/prop_tgt/COMPILE_OPTIONS.rst @@ -6,7 +6,7 @@ List of options to pass to the compiler. This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options specified so far for its target. Use the :command:`target_compile_options` command to append more options. -The options will be added after after flags in the +The options will be added after flags in the :variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variables, but before those propagated from dependencies by the :prop_tgt:`INTERFACE_COMPILE_OPTIONS` property. diff --git a/Help/release/3.26.rst b/Help/release/3.26.rst index 67ace4a..9e9327e 100644 --- a/Help/release/3.26.rst +++ b/Help/release/3.26.rst @@ -175,8 +175,8 @@ Updates Changes made since CMake 3.26.0 include the following. -3.26.1, 3.26.2 --------------- +3.26.1, 3.26.2, 3.26.3 +---------------------- * These versions made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes diff --git a/Help/release/dev/vs-sdk-selection.rst b/Help/release/dev/vs-sdk-selection.rst new file mode 100644 index 0000000..856a203 --- /dev/null +++ b/Help/release/dev/vs-sdk-selection.rst @@ -0,0 +1,7 @@ +vs-sdk-selection +---------------- + +* The :ref:`Visual Studio Generators` for VS 2015 and above learned to + select the Windows SDK version explicitly using a ``version=`` field + in the :variable:`CMAKE_GENERATOR_PLATFORM` variable. + See :ref:`Visual Studio Platform Selection`. diff --git a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst index acb7b2e..416ff60 100644 --- a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst +++ b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst @@ -26,8 +26,46 @@ Platform specification is supported only on specific generators: See native build system documentation for allowed platform names. +.. _`Visual Studio Platform Selection`: + Visual Studio Platform Selection ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -On :ref:`Visual Studio Generators` the selected platform name -is provided in the :variable:`CMAKE_VS_PLATFORM_NAME` variable. +The :ref:`Visual Studio Generators` support platform specification +using one of these forms: + +* ``platform`` +* ``platform[,key=value]*`` +* ``key=value[,key=value]*`` + +The ``platform`` specifies the target platform (VS target architecture), +such as ``x64``, ``ARM64``, or ``Win32``. The selected platform +name is provided in the :variable:`CMAKE_VS_PLATFORM_NAME` variable. + +The ``key=value`` pairs form a comma-separated list of options to +specify generator-specific details of the platform selection. +Supported pairs are: + +``version=<version>`` + .. versionadded:: 3.27 + + Specify the Windows SDK version to use. This is supported by VS 2015 and + above when targeting Windows 10.0+ or Windows Store. CMake will set the + :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable to the + selected SDK version. + + The ``<version>`` may be one of: + + ``10.0`` + Specify that any 10.0 SDK version may be used, and let Visual Studio + pick one. This is supported by VS 2019 and above. + + ``10.0.<build>.<increment>`` + Specify the exact 4-component SDK version, e.g., ``10.0.19041.0``. + The specified version of the SDK must be installed. It may not exceed + the value of :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM`, + if that variable is set. + + If the ``version`` field is not specified, CMake selects a version as + described in the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` + variable documentation. diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 4b39b1d..909a001 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -1,9 +1,10 @@ CMAKE_<LANG>_FLAGS ------------------ -Flags for all build types. - -``<LANG>`` flags used regardless of the value of :variable:`CMAKE_BUILD_TYPE`. +Language-wide flags for language ``<LANG>`` used when building for +all configurations. These flags will be passed to all invocations +of the compiler. This includes invocations that drive compiling +and those that drive linking. For each language, if this variable is not defined, it is initialized and stored in the cache using values from environment variables in @@ -27,7 +28,10 @@ combination with CMake's builtin defaults for the toolchain: This value is a command-line string fragment. Therefore, multiple options should be separated by spaces, and options with spaces should be quoted. -The flags in this variable will be passed to the compiler before those -in the per-configuration :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variant, -and before flags added by the :command:`add_compile_options` or -:command:`target_compile_options` commands. +The flags in this variable will be passed before those in the +per-configuration :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable. +On invocations driving compiling, flags from both variables will be passed +before flags added by commands such as :command:`add_compile_options` and +:command:`target_compile_options`. On invocations driving linking, +they will be passed before flags added by commands such as +:command:`add_link_options` and :command:`target_link_options`. diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst index f0900fd..5daa4c0 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst @@ -1,9 +1,16 @@ CMAKE_<LANG>_FLAGS_<CONFIG> --------------------------- -Flags for language ``<LANG>`` when building for the ``<CONFIG>`` configuration. +Language-wide flags for language ``<LANG>`` used when building for +the ``<CONFIG>`` configuration. These flags will be passed to all +invocations of the compiler in the corresponding configuration. +This includes invocations that drive compiling and those that drive +linking. -The flags in this variable will be passed to the compiler after those -in the :variable:`CMAKE_<LANG>_FLAGS` variable, but before flags added -by the :command:`add_compile_options` or :command:`target_compile_options` -commands. +The flags in this variable will be passed after those in the +:variable:`CMAKE_<LANG>_FLAGS` variable. On invocations driving compiling, +flags from both variables will be passed before flags added by commands +such as :command:`add_compile_options` and :command:`target_compile_options`. +On invocations driving linking, they will be passed before flags added by +commands such as :command:`add_link_options` and +:command:`target_link_options`. diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst index eb71049..2c14d39 100644 --- a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst +++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION.rst @@ -5,11 +5,30 @@ CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION Visual Studio Windows Target Platform Version. -When targeting Windows 10 and above Visual Studio 2015 and above support -specification of a target Windows version to select a corresponding SDK. -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 +When targeting Windows 10 and above, :ref:`Visual Studio Generators` for +VS 2015 and above support specification of a Windows SDK version: + +* If :variable:`CMAKE_GENERATOR_PLATFORM` specifies a ``version=`` field, + as documented by :ref:`Visual Studio Platform Selection`, that SDK + version is selected. + +* Otherwise, if the ``WindowsSDKVersion`` environment variable + is set to an available SDK version, that version is selected. + This is intended for use in environments established by ``vcvarsall.bat`` + or similar scripts. + + .. versionadded:: 3.27 + This is enabled by policy :policy:`CMP0149`. + +* Otherwise, if :variable:`CMAKE_SYSTEM_VERSION` is set to an available + SDK version, that version is selected. + + .. versionchanged:: 3.27 + This is disabled by policy :policy:`CMP0149`. + +* Otherwise, CMake uses the latest Windows SDK version available. + +The chosen Windows target version number is provided in ``CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION``. If no Windows 10 SDK is available this value will be empty. diff --git a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst index f1a1977..727ccc9 100644 --- a/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst +++ b/Help/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM.rst @@ -10,5 +10,5 @@ be set to a false value (e.g. ``OFF``, ``FALSE``, or ``0``) or the SDK version to use as the maximum (e.g. ``10.0.14393.0``). If unset, the default depends on which version of Visual Studio is targeted by the current generator. -This can be used in conjunction with :variable:`CMAKE_SYSTEM_VERSION`, which -CMake uses to select :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`. +This can be used to exclude Windows SDK versions from consideration for +:variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION`. diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 4169734..3fd54cc 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -163,7 +163,6 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) PROJECT IntelFortranImplicit SOURCE_DIR ${CMAKE_ROOT}/Modules/IntelVSImplicitPath BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath - IntelFortranImplicit CMAKE_FLAGS "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE _output) diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index f0a63a8..7239424 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -15,7 +15,14 @@ if("${CMAKE_GENERATOR}" STREQUAL "Xcode") message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}") endif() set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift) - _cmake_find_compiler_path(Swift) + execute_process(COMMAND xcrun --find swiftc + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err RESULT_VARIABLE _xcrun_result) + if(_xcrun_result EQUAL 0 AND EXISTS "${_xcrun_out}") + set(CMAKE_Swift_COMPILER "${_xcrun_out}") + else() + _cmake_find_compiler_path(Swift) + endif() elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja") if(CMAKE_Swift_COMPILER) _cmake_find_compiler_path(Swift) @@ -52,9 +59,6 @@ if(NOT CMAKE_Swift_COMPILER_ID_RUN) if("${CMAKE_GENERATOR}" STREQUAL "Xcode") list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") - - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwift[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) endif() # Try to identify the compiler. diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 7af1017..19bef94 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -386,10 +386,10 @@ set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) set(BLAS95_LIBRARIES) set(_blas_fphsa_req_var BLAS_LIBRARIES) -if(NOT $ENV{BLA_VENDOR} STREQUAL "") - set(BLA_VENDOR $ENV{BLA_VENDOR}) -else() - if(NOT BLA_VENDOR) +if(NOT BLA_VENDOR) + if(NOT "$ENV{BLA_VENDOR}" STREQUAL "") + set(BLA_VENDOR "$ENV{BLA_VENDOR}") + else() set(BLA_VENDOR "All") endif() endif() diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index 67bf424..4423ebb 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -1036,12 +1036,20 @@ if(CUDAToolkit_FOUND) endif() endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.0.0) + _CUDAToolkit_find_and_add_import_lib(nvJitLink) + _CUDAToolkit_find_and_add_import_lib(nvJitLink_static DEPS cudart_static_deps) + endif() + _CUDAToolkit_find_and_add_import_lib(culibos) # it's a static library - foreach (cuda_lib cublasLt cufft curand cusparse nppc nvjpeg) + foreach (cuda_lib cublasLt cufft curand nppc nvjpeg) _CUDAToolkit_find_and_add_import_lib(${cuda_lib}) _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS culibos) endforeach() + _CUDAToolkit_find_and_add_import_lib(cusparse DEPS nvJitLink) + _CUDAToolkit_find_and_add_import_lib(cusparse_static DEPS nvJitLink_static culibos) + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.0.0) # cublas depends on cublasLt # https://docs.nvidia.com/cuda/archive/11.0/cublas/index.html#static-library @@ -1129,16 +1137,11 @@ if(CUDAToolkit_FOUND) if(NOT TARGET CUDA::nvptxcompiler_static) _CUDAToolkit_find_and_add_import_lib(nvptxcompiler_static DEPS cuda_driver) if(TARGET CUDA::nvptxcompiler_static) - target_link_libraries(CUDA::nvptxcompiler_static INTERFACE Threads::Threads) + target_link_libraries(CUDA::nvptxcompiler_static INTERFACE CUDA::cudart_static_deps) endif() endif() endif() - if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.0.0) - _CUDAToolkit_find_and_add_import_lib(nvJitLink DEPS cuda_driver) - _CUDAToolkit_find_and_add_import_lib(nvJitLink_static DEPS cuda_driver) - endif() - _CUDAToolkit_find_and_add_import_lib(nvrtc_builtins DEPS cuda_driver) _CUDAToolkit_find_and_add_import_lib(nvrtc DEPS nvrtc_builtins nvJitLink) if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.5.0) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 1eecb1c..17117bd 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -304,10 +304,12 @@ endif() # Search for different LAPACK distributions if BLAS is found if(NOT LAPACK_NOT_FOUND_MESSAGE) set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) - if(NOT $ENV{BLA_VENDOR} STREQUAL "") - set(BLA_VENDOR $ENV{BLA_VENDOR}) - elseif(NOT BLA_VENDOR) - set(BLA_VENDOR "All") + if(NOT BLA_VENDOR) + if(NOT "$ENV{BLA_VENDOR}" STREQUAL "") + set(BLA_VENDOR "$ENV{BLA_VENDOR}") + else() + set(BLA_VENDOR "All") + endif() endif() # LAPACK in the Intel MKL 10+ library? diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 4e8374c..45dc9ac 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -210,7 +210,7 @@ endif () # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES if(OPENSSL_USE_STATIC_LIBS) set(_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - if(WIN32) + if(MSVC) set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) else() set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) @@ -230,7 +230,7 @@ else() set(_OPENSSL_FIND_PATH_SUFFIX "include") endif() -if (WIN32) +if (MSVC) # http://www.slproweb.com/products/Win32OpenSSL.html set(_OPENSSL_ROOT_HINTS ${OPENSSL_ROOT_DIR} diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2ff41fa..350e111 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 26) -set(CMake_VERSION_PATCH 20230401) +set(CMake_VERSION_PATCH 20230406) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 1e01dd6..321f377 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -525,6 +525,30 @@ bool cmGlobalVisualStudio10Generator::InitializeAndroid(cmMakefile* mf) return false; } +bool cmGlobalVisualStudio10Generator::InitializePlatform(cmMakefile* mf) +{ + if (this->SystemName == "Windows" || this->SystemName == "WindowsStore") { + if (!this->InitializePlatformWindows(mf)) { + return false; + } + } else if (!this->SystemName.empty() && + !this->VerifyNoGeneratorPlatformVersion(mf)) { + return false; + } + return this->cmGlobalVisualStudio8Generator::InitializePlatform(mf); +} + +bool cmGlobalVisualStudio10Generator::InitializePlatformWindows(cmMakefile*) +{ + return true; +} + +bool cmGlobalVisualStudio10Generator::VerifyNoGeneratorPlatformVersion( + cmMakefile*, cm::optional<std::string>) const +{ + return true; +} + bool cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset( std::string& toolset) const { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index deed206..6917ffc 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -183,6 +183,11 @@ protected: virtual bool InitializeTegraAndroid(cmMakefile* mf); virtual bool InitializeAndroid(cmMakefile* mf); + bool InitializePlatform(cmMakefile* mf) override; + virtual bool InitializePlatformWindows(cmMakefile* mf); + virtual bool VerifyNoGeneratorPlatformVersion( + cmMakefile* mf, cm::optional<std::string> reason = cm::nullopt) const; + virtual bool ProcessGeneratorToolsetField(std::string const& key, std::string const& value); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 7424ca3..4300d5c 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -12,6 +12,7 @@ #include "cmGlobalVisualStudioGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmPolicies.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -137,12 +138,36 @@ bool cmGlobalVisualStudio14Generator::MatchesGeneratorName( return false; } -bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf) +bool cmGlobalVisualStudio14Generator::InitializePlatformWindows(cmMakefile* mf) { if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) { - return this->SelectWindows10SDK(mf, false); + return this->SelectWindows10SDK(mf); } - return true; + return this->VerifyNoGeneratorPlatformVersion(mf); +} + +bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion( + cmMakefile* mf, cm::optional<std::string> reason) const +{ + if (!this->GeneratorPlatformVersion) { + return true; + } + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given platform specification containing a\n" + " version=" << *this->GeneratorPlatformVersion << "\n" + "field. The version field is not supported when targeting\n" + " " << this->SystemName << " " << this->SystemVersion << "\n" + ; + /* clang-format on */ + if (reason) { + e << *reason << "."; + } + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return false; } bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf) @@ -162,9 +187,6 @@ bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf) mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } - if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) { - return this->SelectWindows10SDK(mf, true); - } return true; } @@ -173,19 +195,51 @@ bool cmGlobalVisualStudio14Generator::InitializeAndroid(cmMakefile*) return true; } -bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, - bool required) +bool cmGlobalVisualStudio14Generator::ProcessGeneratorPlatformField( + std::string const& key, std::string const& value) +{ + if (key == "version") { + this->GeneratorPlatformVersion = value; + return true; + } + return false; +} + +bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf) { + if (this->GeneratorPlatformVersion && + this->GeneratorPlatformVersion->empty()) { + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Generator\n ", this->GetName(), + "\ngiven platform specification with empty\n version=\n" + "field.")); + return false; + } + // Find the default version of the Windows 10 SDK. std::string const version = this->GetWindows10SDKVersion(mf); - if (required && version.empty()) { - std::ostringstream e; - e << "Could not find an appropriate version of the Windows 10 SDK" - << " installed on this machine"; - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); - return false; + if (version.empty()) { + if (this->GeneratorPlatformVersion) { + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Generator\n ", this->GetName(), + "\ngiven platform specification with\n version=", + *this->GeneratorPlatformVersion, + "\nfield, but no Windows SDK with that version was found.")); + return false; + } + + if (this->SystemName == "WindowsStore") { + mf->IssueMessage( + MessageType::FATAL_ERROR, + "Could not find an appropriate version of the Windows 10 SDK" + " installed on this machine"); + return false; + } } + this->SetWindowsTargetPlatformVersion(version, mf); return true; } @@ -302,6 +356,16 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( cmMakefile* mf) { #if defined(_WIN32) && !defined(__CYGWIN__) + // Accept specific version requests as-is. + if (this->GeneratorPlatformVersion) { + std::string const& ver = *this->GeneratorPlatformVersion; + + // VS 2019 and above support specifying plain "10.0". + if (this->Version >= VSVersion::VS16 && ver == "10.0") { + return ver; + } + } + std::vector<std::string> win10Roots; { @@ -360,10 +424,35 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( // Sort the results to make sure we select the most recent one. std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater); - // Look for a SDK exactly matching the requested target version. - for (std::string const& i : sdks) { - if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { - return i; + // Look for a SDK exactly matching the requested version, if any. + if (this->GeneratorPlatformVersion) { + for (std::string const& i : sdks) { + if (cmSystemTools::VersionCompareEqual( + i, *this->GeneratorPlatformVersion)) { + return i; + } + } + // An exact version was requested but not found. + // Our caller will issue the error message. + return std::string(); + } + + if (mf->GetPolicyStatus(cmPolicies::CMP0149) == cmPolicies::NEW) { + if (cm::optional<std::string> const envVer = + cmSystemTools::GetEnvVar("WindowsSDKVersion")) { + // Look for a SDK exactly matching the environment variable. + for (std::string const& i : sdks) { + if (cmSystemTools::VersionCompareEqual(i, *envVer)) { + return i; + } + } + } + } else { + // Look for a SDK exactly matching the target Windows version. + for (std::string const& i : sdks) { + if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { + return i; + } } } diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 7fb9b4b..f59a323 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -7,6 +7,8 @@ #include <memory> #include <string> +#include <cm/optional> + #include "cmGlobalVisualStudio12Generator.h" class cmGlobalGeneratorFactory; @@ -30,7 +32,6 @@ protected: cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name, std::string const& platformInGeneratorName); - bool InitializeWindows(cmMakefile* mf) override; bool InitializeWindowsStore(cmMakefile* mf) override; bool InitializeAndroid(cmMakefile* mf) override; bool SelectWindowsStoreToolset(std::string& toolset) const override; @@ -39,6 +40,14 @@ protected: // of the toolset is installed bool IsWindowsStoreToolsetInstalled() const; + bool InitializePlatformWindows(cmMakefile* mf) override; + bool VerifyNoGeneratorPlatformVersion( + cmMakefile* mf, + cm::optional<std::string> reason = cm::nullopt) const override; + + bool ProcessGeneratorPlatformField(std::string const& key, + std::string const& value) override; + // Used to adjust the max-SDK-version calculation to accommodate user // configuration. std::string GetWindows10SDKMaxVersion(cmMakefile* mf) const; @@ -47,7 +56,7 @@ protected: // version of the toolset. virtual std::string GetWindows10SDKMaxVersionDefault(cmMakefile* mf) const; - virtual bool SelectWindows10SDK(cmMakefile* mf, bool required); + virtual bool SelectWindows10SDK(cmMakefile* mf); void SetWindowsTargetPlatformVersion(std::string const& version, cmMakefile* mf); @@ -61,4 +70,6 @@ protected: private: class Factory; friend class Factory; + + cm::optional<std::string> GeneratorPlatformVersion; }; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 2e2c8b6..2aba46f 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -94,7 +94,9 @@ bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p, return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform(p, mf); } - this->GeneratorPlatform = p; + if (!this->ParseGeneratorPlatform(p, mf)) { + return false; + } // FIXME: Add CMAKE_GENERATOR_PLATFORM field to set the framework. // For now, just report the generator's default, if any. @@ -114,12 +116,100 @@ bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p, *targetFrameworkTargetsVersion); } + if (!this->InitializePlatform(mf)) { + return false; + } + // The generator name does not contain the platform name, and so supports // explicit platform specification. We handled that above, so pass an // empty platform name to our base class implementation so it does not error. return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf); } +bool cmGlobalVisualStudio8Generator::ParseGeneratorPlatform( + std::string const& p, cmMakefile* mf) +{ + this->GeneratorPlatform.clear(); + + std::vector<std::string> const fields = cmTokenize(p, ","); + auto fi = fields.begin(); + if (fi == fields.end()) { + return true; + } + + // The first field may be the VS platform. + if (fi->find('=') == fi->npos) { + this->GeneratorPlatform = *fi; + ++fi; + } + + std::set<std::string> handled; + + // The rest of the fields must be key=value pairs. + for (; fi != fields.end(); ++fi) { + std::string::size_type pos = fi->find('='); + if (pos == fi->npos) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given platform specification\n" + " " << p << "\n" + "that contains a field after the first ',' with no '='." + ; + /* clang-format on */ + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return false; + } + std::string const key = fi->substr(0, pos); + std::string const value = fi->substr(pos + 1); + if (!handled.insert(key).second) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given platform specification\n" + " " << p << "\n" + "that contains duplicate field key '" << key << "'." + ; + /* clang-format on */ + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return false; + } + if (!this->ProcessGeneratorPlatformField(key, value)) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given platform specification\n" + " " << p << "\n" + "that contains invalid field '" << *fi << "'." + ; + /* clang-format on */ + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return false; + } + } + + return true; +} + +bool cmGlobalVisualStudio8Generator::ProcessGeneratorPlatformField( + std::string const& key, std::string const& value) +{ + static_cast<void>(key); + static_cast<void>(value); + return false; +} + +bool cmGlobalVisualStudio8Generator::InitializePlatform(cmMakefile*) +{ + return true; +} + cm::optional<std::string> const& cmGlobalVisualStudio8Generator::GetTargetFrameworkVersion() const { diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index fe57c54..5555e9b 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -60,6 +60,11 @@ protected: cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name, std::string const& platformInGeneratorName); + virtual bool InitializePlatform(cmMakefile* mf); + + virtual bool ProcessGeneratorPlatformField(std::string const& key, + std::string const& value); + void AddExtraIDETargets() override; std::string FindDevEnvCommand() override; @@ -96,4 +101,7 @@ protected: cm::optional<std::string> DefaultTargetFrameworkVersion; cm::optional<std::string> DefaultTargetFrameworkIdentifier; cm::optional<std::string> DefaultTargetFrameworkTargetsVersion; + +private: + bool ParseGeneratorPlatform(std::string const& is, cmMakefile* mf); }; diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 415eb7c..f28419a 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -885,7 +885,8 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset( return AuxToolset::PropsMissing; } -bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf) +bool cmGlobalVisualStudioVersionedGenerator::InitializePlatformWindows( + cmMakefile* mf) { // If the Win 8.1 SDK is installed then we can select a SDK matching // the target Windows version. @@ -894,13 +895,14 @@ bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf) if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 && !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) { this->SetWindowsTargetPlatformVersion("8.1", mf); - return true; + return this->VerifyNoGeneratorPlatformVersion( + mf, "with the Windows 8.1 SDK installed"); } - return cmGlobalVisualStudio14Generator::InitializeWindows(mf); + return cmGlobalVisualStudio14Generator::InitializePlatformWindows(mf); } // Otherwise we must choose a Win 10 SDK even if we are not targeting // Windows 10. - return this->SelectWindows10SDK(mf, false); + return this->SelectWindows10SDK(mf); } bool cmGlobalVisualStudioVersionedGenerator::SelectWindowsStoreToolset( diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index 45aca74..fb4b1d7 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -61,7 +61,6 @@ protected: VSVersion version, cmake* cm, const std::string& name, std::string const& platformInGeneratorName); - bool InitializeWindows(cmMakefile* mf) override; bool SelectWindowsStoreToolset(std::string& toolset) const override; // Used to verify that the Desktop toolset for the current generator is @@ -72,6 +71,8 @@ protected: // of the toolset is installed bool IsWindowsStoreToolsetInstalled() const; + bool InitializePlatformWindows(cmMakefile* mf) override; + // Check for a Win 8 SDK known to the registry or VS installer tool. bool IsWin81SDKInstalled() const; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 37d697f..fe88382 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -447,6 +447,9 @@ class cmMakefile; 27, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0148, \ "The FindPythonInterp and FindPythonLibs modules are removed.", 3, \ + 27, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0149, \ + "Visual Studio generators select latest Windows SDK by default.", 3, \ 27, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) diff --git a/Tests/RunCMake/Autogen/MocPredefs.cmake b/Tests/RunCMake/Autogen/MocPredefs.cmake index 7a89bb5..8307e04 100644 --- a/Tests/RunCMake/Autogen/MocPredefs.cmake +++ b/Tests/RunCMake/Autogen/MocPredefs.cmake @@ -1,4 +1,3 @@ -cmake_policy(SET CMP0129 NEW) enable_language(CXX) find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 080740c..f05f784 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -15,6 +15,9 @@ macro(add_RunCMake_test test) else() set(Test_Dir ${test}) endif() + if(CMAKE_C_COMPILER_ID STREQUAL "LCC") + list(APPEND TEST_ARGS -DRunCMake_TEST_LCC=1) + endif() add_test(NAME RunCMake.${test} COMMAND ${CMAKE_CMAKE_COMMAND} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig} @@ -41,6 +44,11 @@ function(add_RunCMake_test_group test types) file(REMOVE_RECURSE "${TEST_CONFIG_DIR}") file(MAKE_DIRECTORY "${TEST_CONFIG_DIR}") + set(TEST_ARGS "") + if(CMAKE_C_COMPILER_ID STREQUAL "LCC") + list(APPEND TEST_ARGS -DRunCMake_TEST_LCC=1) + endif() + foreach(type IN LISTS types) # generate prerequirements config file in cmake as ctest doesn't have as # much system information so it is easier to set programs and environment @@ -68,6 +76,7 @@ function(add_RunCMake_test_group test types) -DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${type}/${test} + ${TEST_ARGS} -Dconfig_file=${TEST_CONFIG_DIR}/${type}_config.cmake -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake" ) diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index f210474..18a673e 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,9 +1,5 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) -if(POLICY CMP0129) - cmake_policy(SET CMP0129 NEW) -endif() - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "") project(${RunCMake_TEST} CXX) diff --git a/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt b/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt index 30cb9ae..67eae65 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt +++ b/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt @@ -1,9 +1,3 @@ cmake_minimum_required(VERSION 3.13) - -if(POLICY CMP0129) - cmake_policy(SET CMP0129 NEW) -endif() - project(${RunCMake_TEST} LANGUAGES NONE) - include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt new file mode 100644 index 0000000..b2098bd --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification + + Test Platform,nocomma + + that contains a field after the first ',' with no '='\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadFieldNoComma.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt new file mode 100644 index 0000000..654f920 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification + + Test Platform,unknown= + + that contains invalid field 'unknown='\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadFieldUnknown.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt new file mode 100644 index 0000000..1b7804d --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification with empty + + version= + + field\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionEmpty.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt new file mode 100644 index 0000000..d82eb0b --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification with + + version=1\.2\.3\.4 + + field, but no Windows SDK with that version was found\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt new file mode 100644 index 0000000..d3c62e3 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt @@ -0,0 +1,19 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification (containing a + + version=8\.1 + + field\. The version field is not supported when targeting + + Windows 8\.1( + + with the Windows 8\.1 SDK installed\.)?|with + + version=8\.1 + + field, but no Windows SDK with that version was found\.)$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake index a7519c3..233eb0a 100644 --- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake @@ -26,3 +26,86 @@ else() run_cmake(BadPlatformToolchain) unset(RunCMake_TEST_OPTIONS) endif() + +if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$") + unset(ENV{WindowsSDKVersion}) + + set(RunCMake_GENERATOR_PLATFORM "Test Platform,nocomma") + run_cmake(BadFieldNoComma) + set(RunCMake_GENERATOR_PLATFORM "Test Platform,unknown=") + run_cmake(BadFieldUnknown) + set(RunCMake_GENERATOR_PLATFORM "version=") + run_cmake(BadVersionEmpty) + set(RunCMake_GENERATOR_PLATFORM "version=1.2.3.4") + run_cmake(BadVersionMissing) + set(RunCMake_GENERATOR_PLATFORM "version=8.1") + run_cmake_with_options(BadVersionPlatform -DCMAKE_SYSTEM_VERSION=8.1) + + if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio (1[45]) ") + set(expect_version "10.0") + set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0) + unset(RunCMake_GENERATOR_PLATFORM) + endif() + + set(kits "") + cmake_host_system_information(RESULT kitsRoot10 + QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Microsoft/Windows Kits/Installed Roots" + VALUE "KitsRoot10" + VIEW 64_32 + ERROR_VARIABLE kitsRoot10Error + ) + if(NOT kitsRoot10Error AND IS_DIRECTORY "${kitsRoot10}/include") + cmake_path(SET kitsInclude "${kitsRoot10}/include") + file(GLOB kits RELATIVE "${kitsInclude}" "${kitsInclude}/*/um/windows.h") + list(TRANSFORM kits REPLACE "/.*" "") + endif() + if(kits) + message(STATUS "Available Kits: ${kits}") + if(RunCMake_GENERATOR MATCHES "^Visual Studio 14 ") + set(kitMax 10.0.14393.0) + else() + set(kitMax "") + endif() + if(kitMax) + set(kitsIn "${kits}") + set(kits "") + foreach(kit IN LISTS kitsIn) + if(kit VERSION_LESS_EQUAL "${kitMax}") + list(APPEND kits "${kit}") + else() + message(STATUS "Excluding Kit ${kit} > ${kitMax}") + endif() + endforeach() + endif() + elseif(NOT RunCMake_GENERATOR MATCHES "^Visual Studio 14 ") + message(FATAL_ERROR "Could not find any Windows SDKs to drive test cases.") + endif() + + if(kits) + foreach(expect_version IN LISTS kits) + set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0) + unset(RunCMake_GENERATOR_PLATFORM) + endforeach() + foreach(expect_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-OLD-${expect_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${expect_version} -DCMAKE_POLICY_DEFAULT_CMP0149=OLD) + endforeach() + if(kits MATCHES "(^|;)([0-9.]+)$") + set(expect_version "${CMAKE_MATCH_2}") + foreach(test_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-NEW-${test_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${test_version} -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) + endforeach() + endif() + foreach(expect_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-WindowsSDKVersion-${expect_version}") + set(ENV{WindowsSDKVersion} "${expect_version}\\") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) + unset(ENV{WindowsSDKVersion}) + endforeach() + endif() +endif() diff --git a/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake b/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake new file mode 100644 index 0000000..6c3c8e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake @@ -0,0 +1,9 @@ +if(actual_stdout MATCHES "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION='([^']+)'") + set(actual_version "${CMAKE_MATCH_1}") + if(NOT "${actual_version}" STREQUAL "${expect_version}") + set(RunCMake_TEST_FAILED "Actual SDK version '${actual_version}' did not match expected '${expect_version}'") + return() + endif() +else() + set(RunCMake_TEST_FAILED "No CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION found in output.") +endif() diff --git a/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake b/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake new file mode 100644 index 0000000..5c30e2b --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake @@ -0,0 +1,5 @@ +cmake_policy(GET CMP0149 cmp0149) +message(STATUS "CMP0149='${cmp0149}'") +message(STATUS "CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}'") +message(STATUS "ENV{WindowsSDKVersion}='$ENV{WindowsSDKVersion}'") +message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION='${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}'") diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index e1c923d..8e85f6c 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -11,8 +11,12 @@ foreach( endforeach() function(run_cmake test) - if(DEFINED ENV{RunCMake_TEST_FILTER} AND NOT test MATCHES "$ENV{RunCMake_TEST_FILTER}") - return() + if(DEFINED ENV{RunCMake_TEST_FILTER}) + set(test_and_variant "${test}${RunCMake_TEST_VARIANT_DESCRIPTION}") + if(NOT test_and_variant MATCHES "$ENV{RunCMake_TEST_FILTER}") + return() + endif() + unset(test_and_variant) endif() set(top_src "${RunCMake_SOURCE_DIR}") @@ -94,7 +98,7 @@ function(run_cmake test) if(APPLE) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) endif() - if(NOT RunCMake_TEST_NO_CMP0129 AND CMAKE_C_COMPILER_ID STREQUAL "LCC") + if(RunCMake_TEST_LCC AND NOT RunCMake_TEST_NO_CMP0129) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0129=NEW) endif() if(RunCMake_MAKE_PROGRAM) @@ -174,6 +178,7 @@ function(run_cmake test) "|icp?c: remark #10441: The Intel\\(R\\) C\\+\\+ Compiler Classic \\(ICC\\) is deprecated" "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" + "|[^\n]*xcodebuild[^\n]*DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default" "|[^\n]*xcodebuild[^\n]*DVTPlugInManager" "|[^\n]*xcodebuild[^\n]*DVTSDK: Warning: SDK path collision for path" "|[^\n]*xcodebuild[^\n]*Requested but did not find extension point with identifier" |