From a245479372363b6693c180f65781ac9d434a2380 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Aug 2019 09:43:00 -0400 Subject: clang: Work around toolchain file use of internal CMake variables Since commit d44c0db0b2 (clang: setup correct configuration in gnu mode, 2019-02-20, v3.15.0-rc1~41^2~5) our Clang compiler information modules need the `CMAKE__COMPILER_FRONTEND_VARIANT` variable that we compute during compiler detection. However, some existing toolchain files set our internal `CMAKE__COMPILER_ID_RUN` variables and block that detection, but do not set the new frontend variant variable. Help them out by setting `CMAKE__COMPILER_FRONTEND_VARIANT` anyway. Fixes: #19515, #19539 --- Modules/CMakeDetermineCCompiler.cmake | 16 ++++++++++++++++ Modules/CMakeDetermineCXXCompiler.cmake | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 8be781a..037c33b 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -124,6 +124,22 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) elseif(CMAKE_C_PLATFORM_ID MATCHES "Cygwin") set(CMAKE_COMPILER_IS_CYGWIN 1) endif() +else() + if(NOT DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT) + # Some toolchain files set our internal CMAKE_C_COMPILER_ID_RUN + # variable but are not aware of CMAKE_C_COMPILER_FRONTEND_VARIANT. + # They pre-date our support for the GNU-like variant targeting the + # MSVC ABI so we do not consider that here. + if(CMAKE_C_COMPILER_ID STREQUAL "Clang") + if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_C_COMPILER_FRONTEND_VARIANT "MSVC") + else() + set(CMAKE_C_COMPILER_FRONTEND_VARIANT "GNU") + endif() + else() + set(CMAKE_C_COMPILER_FRONTEND_VARIANT "") + endif() + endif() endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 00ef5b9..7274eec 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -119,6 +119,22 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) elseif(CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin") set(CMAKE_COMPILER_IS_CYGWIN 1) endif() +else() + if(NOT DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT) + # Some toolchain files set our internal CMAKE_CXX_COMPILER_ID_RUN + # variable but are not aware of CMAKE_CXX_COMPILER_FRONTEND_VARIANT. + # They pre-date our support for the GNU-like variant targeting the + # MSVC ABI so we do not consider that here. + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "MSVC") + else() + set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "GNU") + endif() + else() + set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "") + endif() + endif() endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) -- cgit v0.12