From dafb8410551375450d6872ed30bc0f3eebdabc36 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Wed, 1 Oct 2025 16:44:11 -0700 Subject: [PATCH] Upgrade to CMake 3.21 (#631) --- CMakeLists.txt | 14 ++++++-------- CMakePresets.json | 11 +++-------- DirectXTex/DirectXTexDDS.cpp | 2 +- DirectXTex/DirectXTexUtil.cpp | 2 +- README.md | 2 ++ Texconv/texconv.cpp | 2 +- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89592d9..65ca521 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -cmake_minimum_required (VERSION 3.20) +cmake_minimum_required (VERSION 3.21) set(DIRECTXTEX_VERSION 2.0.8) @@ -509,13 +509,11 @@ if(BUILD_TOOLS AND WIN32) target_compile_definitions(texconv PRIVATE USE_XBOX_EXTS) target_link_libraries(texconv PUBLIC $ $) - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21") - add_custom_command(TARGET texconv POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - $ $ - COMMAND_EXPAND_LISTS - ) - endif() + add_custom_command(TARGET texconv POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + $ $ + COMMAND_EXPAND_LISTS + ) endif() endif() diff --git a/CMakePresets.json b/CMakePresets.json index 52e3ca3..5d1fc2b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 2, + "version": 3, "configurePresets": [ { "name": "base", @@ -8,7 +8,7 @@ "generator": "Ninja", "hidden": true, "binaryDir": "${sourceDir}/out/build/${presetName}", - "cacheVariables": { "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" } + "installDir": "${sourceDir}/out/install/${presetName}" }, { @@ -183,12 +183,7 @@ }, { "name": "VCPKG", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "type": "FILEPATH" - } - }, + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "hidden": true }, { diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index a6f7235..d691f8e 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -325,7 +325,7 @@ namespace _Inout_ uint32_t& convFlags) noexcept { if (!pSource) - return E_INVALIDARG; + return E_POINTER; metadata = {}; if (ddPixelFormat) diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index 6798047..bcdbf81 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -27,7 +27,7 @@ static_assert(WIN10_DXGI_FORMAT_V208 == DXGI_FORMAT_V208, "Windows SDK mismatch static_assert(WIN10_DXGI_FORMAT_V408 == DXGI_FORMAT_V408, "Windows SDK mismatch detected"); #endif -#if defined(NTDDI_WIN11_GE) && !defined(_GAMING_XBOX) +#if defined(NTDDI_WIN11_GE) && !defined(_GAMING_XBOX) && !defined(__MINGW32__) static_assert(WIN11_DXGI_FORMAT_A4B4G4R4_UNORM == DXGI_FORMAT_A4B4G4R4_UNORM, "Windows SDK mismatch detected"); #endif diff --git a/README.md b/README.md index 23da6a7..6accf7b 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ FOR SECURITY ADVISORIES, see [GitHub](https://github.com/microsoft/DirectXTex/se For a full change history, see [CHANGELOG.md](https://github.com/microsoft/DirectXTex/blob/main/CHANGELOG.md). +* The CMake projects require 3.21 or later. VS 2019 users will need to install a standalone version of CMake 3.21 or later and add it to their PATH. + * Starting with the March 2025 release, Windows 7 and Windows 8.0 support has been retired. * Starting with the July 2022 release, the ``bool forceSRGB`` parameter for the **CreateTextureEx** and **CreateShaderResourceViewEx** functions is now a ``CREATETEX_FLAGS`` typed enum bitmask flag parameter. This may have a _breaking change_ impact to client code. Replace ``true`` with ``CREATETEX_FORCE_SRGB`` and ``false`` with ``CREATETEX_DEFAULT``. diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index 282fb69..2188803 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -3856,7 +3856,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) { options.pstrName = const_cast(L"HeifCompressionMethod"); varValues.vt = VT_UI1; - #if defined(NTDDI_WIN10_CU) + #if defined(NTDDI_WIN10_CU) && !defined(__MINGW32__) varValues.bVal = WICHeifCompressionNone; #else varValues.bVal = 0x1 /* WICHeifCompressionNone */;