ASM: Restore CMAKE_{C,CXX}_COMPILER as ASM-first candidates

Prior to commit abfe98ce6c (ASM: Consider C/CXX compilers only if
enabled, 2025-04-08) one could pass `-DCMAKE_C_COMPILER=...` to
configure a project that enables `ASM` before/without `C` or `CXX`.
This was previously allowed accidentally as a side effect of the way we
implemented support for using the selected `C` or `CXX` compiler for
`ASM`.  Restore it for compatibility, but also preserve the effect of
commit 6baf65ec46 (ASM: Do not consider MSVC C/CXX compiler for generic
ASM, 2025-04-08) by excluding `cl`.
This commit is contained in:
Brad King
2025-04-12 09:55:01 -04:00
parent 95437332ec
commit d26efc3600

View File

@@ -23,8 +23,12 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
if(NOT CMAKE_ASM_COMPILER_INIT)
if(CMAKE_C_COMPILER_LOADED AND NOT CMAKE_C_COMPILER_ID MATCHES "^(MSVC)$")
set(CMAKE_ASM_COMPILER_LIST ${CMAKE_C_COMPILER})
elseif(NOT CMAKE_C_COMPILER_LOADED AND CMAKE_C_COMPILER AND NOT CMAKE_C_COMPILER MATCHES "(^|/)[Cc][Ll](\\.|$)")
set(CMAKE_ASM_COMPILER_LIST ${CMAKE_C_COMPILER})
elseif(CMAKE_CXX_COMPILER_LOADED AND NOT CMAKE_CXX_COMPILER_ID MATCHES "^(MSVC)$")
set(CMAKE_ASM_COMPILER_LIST ${CMAKE_CXX_COMPILER})
elseif(NOT CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER AND NOT CMAKE_CXX_COMPILER MATCHES "(^|/)[Cc][Ll](\\.|$)")
set(CMAKE_ASM_COMPILER_LIST ${CMAKE_CXX_COMPILER})
else()
# List all default C and CXX compilers
set(CMAKE_ASM_COMPILER_LIST