From bebef8885c8874b363e8e5eac3cb4667224160a3 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 20 Feb 2026 11:42:34 +0100 Subject: [PATCH 1/2] Fix CMake version deprecation warning when using CMake 4 We allow a max version of 3.31 which should not break policies Signed-off-by: Duncan Ogilvie --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 692629fc1b..edeae34e61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ # We specify a minimum requirement of 3.10.2, but for now use 3.5.1 here # until our infrastructure catches up. -cmake_minimum_required(VERSION 3.5.1) +cmake_minimum_required(VERSION 3.5.1...3.31) include(CMakePackageConfigHelpers) From 28c9e58d5d37b7aadc9c837c84afe3b6b84d50f2 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 20 Feb 2026 11:43:01 +0100 Subject: [PATCH 2/2] Fix COMPILER_ID variable being set to MSVC with clang.exe on Windows Closes #9896 Signed-off-by: Duncan Ogilvie --- CMakeLists.txt | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edeae34e61..91420c10bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,11 +78,23 @@ endif() option(DISABLE_PACKAGE_CONFIG_AND_INSTALL "Disable package configuration, target export and installation" ${MBEDTLS_AS_SUBPROJECT}) -if (CMAKE_C_SIMULATE_ID) +# CMAKE_C_COMPILER_ID identifies the compiler family/ABI target, but not the +# command-line frontend. For Clang on Windows, this stays "Clang" for both +# clang.exe (GNU-style flags) and clang-cl.exe (MSVC-style flags). +# Use CMAKE_C_COMPILER_FRONTEND_VARIANT to select the expected flag syntax. +set(COMPILER_ID ${CMAKE_C_COMPILER_ID}) + +if (CMAKE_C_COMPILER_ID MATCHES "Clang") + if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + set(COMPILER_ID MSVC) + elseif (NOT CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" AND CMAKE_C_SIMULATE_ID) + # Fallback for old CMake versions that don't report + # CMAKE_C_COMPILER_FRONTEND_VARIANT. + set(COMPILER_ID ${CMAKE_C_SIMULATE_ID}) + endif() +elseif (CMAKE_C_SIMULATE_ID) set(COMPILER_ID ${CMAKE_C_SIMULATE_ID}) -else() - set(COMPILER_ID ${CMAKE_C_COMPILER_ID}) -endif(CMAKE_C_SIMULATE_ID) +endif() string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${COMPILER_ID}") string(REGEX MATCH "GNU" CMAKE_COMPILER_IS_GNU "${COMPILER_ID}")