mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-09 22:08:56 +08:00
build(cmake): treat clang-cl like MSVC in px4_add_common_flags
clang-cl emits CMAKE_CXX_COMPILER_ID="Clang" with CMAKE_CXX_SIMULATE_ID="MSVC" because it is the LLVM driver running on top of MSVC's headers and CRT. The previous flag selector keyed strictly on CMAKE_CXX_COMPILER_ID == "MSVC", so clang-cl fell into the GCC/Clang flag branch and tried to forward switches the cl-style driver rejects (e.g. -fdata-sections, GCC-style warning toggles). Recognise the (Clang + SIMULATE_ID=MSVC) combination as the MSVC driver path so the same MSVC-flavoured flag set is applied. Native clang/AppleClang is unaffected because SIMULATE_ID is empty there. Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
@@ -195,7 +195,13 @@ endfunction()
|
||||
|
||||
function(px4_add_common_flags)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# clang-cl emits CMAKE_CXX_COMPILER_ID="Clang" with
|
||||
# CMAKE_CXX_SIMULATE_ID="MSVC" because it is the LLVM driver running
|
||||
# on top of the MSVC headers/CRT. Treat it like native MSVC for flag
|
||||
# selection so we don't try to forward GCC-style switches like
|
||||
# -fdata-sections that the cl-style driver rejects.
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR
|
||||
(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")))
|
||||
add_compile_options(
|
||||
/MP
|
||||
/Zi
|
||||
|
||||
Reference in New Issue
Block a user