mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-04 06:40:24 +00:00
Clang: Add support for import std when targeting the MSVC ABI
When Clang targets the MSVC ABI, discover the MSVC standard library's import-std metadata discovery through the MSVC module logic. Also extend the latter to use `CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES` and honor `CMAKE_CXX_STDLIB_MODULES_JSON`. Closes: #26761 Signed-off-by: Sharadh Rajaraman <r.sharadh@outlook.sg>
This commit is contained in:
committed by
Brad King
parent
b9bb2b1256
commit
1610aa22f4
@@ -1,4 +1,4 @@
|
||||
set(CMake_TEST_MODULE_COMPILATION "named,compile_commands,collation,partitions,internal_partitions,export_bmi,install_bmi,shared,bmionly,build_database" CACHE STRING "")
|
||||
set(CMake_TEST_MODULE_COMPILATION "named,compile_commands,collation,partitions,internal_partitions,export_bmi,install_bmi,shared,bmionly,build_database,import_std23" CACHE STRING "")
|
||||
if("$ENV{CMAKE_CI_BUILD_NAME}" MATCHES "(^|_)cl(_|$)")
|
||||
set(CMAKE_Fortran_COMPILER "flang" CACHE STRING "")
|
||||
set(CMAKE_Fortran_COMPILER_ID "LLVMFlang" CACHE STRING "")
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" OR
|
||||
CMAKE_CXX_STANDARD_LIBRARY STREQUAL "msvc" OR
|
||||
CMAKE_CXX_COMPILER_TARGET MATCHES "(^|-)windows-msvc($|-)")
|
||||
include(Compiler/MSVC-CXX-CXXImportStd)
|
||||
return()
|
||||
endif()
|
||||
|
||||
function (_cmake_cxx_find_modules_json)
|
||||
if (NOT CMAKE_CXX_STDLIB_MODULES_JSON)
|
||||
if (CMAKE_CXX_STANDARD_LIBRARY STREQUAL "libc++")
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
function (_cmake_cxx_find_modules_json)
|
||||
if (CMAKE_CXX_STDLIB_MODULES_JSON)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
find_file(_msvc_modules_json_file
|
||||
NAME modules.json
|
||||
HINTS
|
||||
"$ENV{VCToolsInstallDir}/modules"
|
||||
PATHS
|
||||
"$ENV{INCLUDE}"
|
||||
"${CMAKE_CXX_COMPILER}/../../.."
|
||||
"${CMAKE_CXX_COMPILER}/../.." # msvc-wine layout
|
||||
PATH_SUFFIXES
|
||||
../modules
|
||||
NO_CACHE)
|
||||
|
||||
# Without this file, we do not have modules installed.
|
||||
if (NOT EXISTS "${_msvc_modules_json_file}")
|
||||
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "Could not find `modules.json` resource" PARENT_SCOPE)
|
||||
return ()
|
||||
set(_msvc_modules_json_file "${CMAKE_CXX_STDLIB_MODULES_JSON}")
|
||||
else ()
|
||||
find_file(_msvc_modules_json_file
|
||||
NAME modules.json
|
||||
HINTS
|
||||
"$ENV{VCToolsInstallDir}/modules"
|
||||
PATHS
|
||||
"$ENV{INCLUDE}"
|
||||
${CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES}
|
||||
"${CMAKE_CXX_COMPILER}/../../.."
|
||||
"${CMAKE_CXX_COMPILER}/../.." # msvc-wine layout
|
||||
PATH_SUFFIXES
|
||||
../modules
|
||||
NO_CACHE)
|
||||
# Without this file, we do not have modules installed.
|
||||
if (NOT EXISTS "${_msvc_modules_json_file}")
|
||||
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "Could not find `modules.json` resource" PARENT_SCOPE)
|
||||
return ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
file(READ "${_msvc_modules_json_file}" _msvc_modules_json)
|
||||
|
||||
Reference in New Issue
Block a user