c++modules: Relax clang EcoStd prereqs

The path-detection routine which sets a default value for
'CMAKE_CXX_STDLIB_MODULES_JSON' is too strict. If the variable is
already set then no additional detection is needed by cmake.

This is relevant when compiling with clang and linking against
Microsoft's STL.
This commit is contained in:
Marcel Laverdet committed 2026-05-13 18:52:19 +02:00
1 parent 0bc5ae8c75
commit 82b1e97362
1 file changed
+10 -10
+10 -10
View File
@@ -1,14 +1,14 @@
function (_cmake_cxx_find_modules_json)
if (CMAKE_CXX_STANDARD_LIBRARY STREQUAL "libc++")
set(_clang_modules_json_impl "libc++")
elseif (CMAKE_CXX_STANDARD_LIBRARY STREQUAL "libstdc++")
set(_clang_modules_json_impl "libstdc++")
else ()
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "Only `libc++` and `libstdc++` are supported" PARENT_SCOPE)
return ()
endif ()
if (NOT CMAKE_CXX_STDLIB_MODULES_JSON)
if (CMAKE_CXX_STANDARD_LIBRARY STREQUAL "libc++")
set(_clang_modules_json_impl "libc++")
elseif (CMAKE_CXX_STANDARD_LIBRARY STREQUAL "libstdc++")
set(_clang_modules_json_impl "libstdc++")
else ()
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "Only `libc++` and `libstdc++` are supported" PARENT_SCOPE)
return ()
endif ()
execute_process(
COMMAND
"${CMAKE_CXX_COMPILER}"
@@ -32,7 +32,7 @@ function (_cmake_cxx_find_modules_json)
# The original PR had a key spelling mismatch internally. Do not support it
# and instead require a release known to have the fix.
# https://github.com/llvm/llvm-project/pull/83036
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "LLVM 18.1.2 is required for `${_clang_modules_json_impl}.modules.json` format fix" PARENT_SCOPE)
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "LLVM 18.1.2 is required for 'import std' json format fix" PARENT_SCOPE)
return ()
endif ()
endfunction ()