From 899c8d7b21591bdada171dcab41db0aa0cf6b4da Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 31 Jan 2024 14:08:32 -0500 Subject: CUDA/Clang: Fail early when mixing clang++ with cl on Windows In commit 88c740462c (CUDA/Clang: Add support for MSVC ABI on Windows using GNU-like frontend, 2024-01-17) we updated the message for the existing check to mention CUDA, but neglected to update the check itself. Issue: #25648 --- Modules/Platform/Windows-Clang.cmake | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index db48150..b9e6394 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -167,37 +167,32 @@ macro(__enable_llvm_rc_preprocessing clang_option_prefix extra_pp_flags) endif() endmacro() -macro(__verify_same_language_values variable) - foreach(lang "C" "CXX" "HIP") - if(DEFINED CMAKE_${lang}_${variable}) - list(APPEND __LANGUAGE_VALUES_${variable} "${CMAKE_${lang}_${variable}}") - endif() +function(__verify_same_language_values variable langs) + foreach(lang IN LISTS langs) + list(APPEND __LANGUAGE_VALUES_${variable} ${CMAKE_${lang}_${variable}}) endforeach() list(REMOVE_DUPLICATES __LANGUAGE_VALUES_${variable}) list(LENGTH __LANGUAGE_VALUES_${variable} __NUM_VALUES) - if(__NUM_VALUES GREATER 1) message(FATAL_ERROR ${ARGN}) endif() - unset(__NUM_VALUES) - unset(__LANGUAGE_VALUES_${variable}) -endmacro() +endfunction() if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_HIP_SIMULATE_ID}" STREQUAL "xMSVC") - __verify_same_language_values(COMPILER_ID + __verify_same_language_values(COMPILER_ID "C;CXX;HIP" "The current configuration mixes Clang and MSVC or " "some other CL compatible compiler tool. This is not supported. " - "Use either Clang or MSVC as the compiler for all of C, C++, CUDA and/or HIP.") + "Use either Clang or MSVC as the compiler for all of C, C++, and/or HIP.") - __verify_same_language_values(COMPILER_FRONTEND_VARIANT + __verify_same_language_values(COMPILER_FRONTEND_VARIANT "C;CXX;CUDA;HIP" "The current configuration uses the Clang compiler " "tool with mixed frontend variants, both the GNU and in MSVC CL " "like variants. This is not supported. Use either clang/clang++ " - "or clang-cl as all C, C++, CUDA and/or HIP compilers.") + "or clang-cl as all C, C++, CUDA, and/or HIP compilers.") if(NOT CMAKE_RC_COMPILER_INIT) # Check if rc is already in the path -- cgit v0.12