CMake: use correct flags for clang-cl

According to clang-cl documentation [1], when we need to pass
parameters to the clang driver, we need to add the "/clang:"
or "-Xclang" prefix to the parameter.

[1] https://clang.llvm.org/docs/UsersManual.html#the-clang-option

Change-Id: I2b96942a12fbdf70773c732c021e8ad5173e9311
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Yuhang Zhao 2023-05-23 15:53:37 +08:00 committed by Yuhang Zhao
parent 5522e33128
commit 4ba7081b66

View File

@ -35,35 +35,40 @@ if (MSVC)
endif()
if(GCC OR CLANG OR QCC)
set(QT_CFLAGS_SSE2 "-msse2")
set(QT_CFLAGS_SSE3 "-msse3")
set(QT_CFLAGS_SSSE3 "-mssse3")
set(QT_CFLAGS_SSE4_1 "-msse4.1")
set(QT_CFLAGS_SSE4_2 "-msse4.2")
set(QT_CFLAGS_F16C "-mf16c")
set(QT_CFLAGS_RDRND "-mrdrnd")
set(QT_CFLAGS_RDSEED "-mrdseed")
set(QT_CFLAGS_AVX "-mavx")
set(QT_CFLAGS_AVX2 "-mavx2")
set(QT_CFLAGS_ARCH_HASWELL "-march=haswell")
set(QT_CFLAGS_AVX512F "-mavx512f")
set(QT_CFLAGS_AVX512ER "-mavx512er")
set(QT_CFLAGS_AVX512CD "-mavx512cd")
set(QT_CFLAGS_AVX512PF "-mavx512pf")
set(QT_CFLAGS_AVX512DQ "-mavx512dq")
set(QT_CFLAGS_AVX512BW "-mavx512bw")
set(QT_CFLAGS_AVX512VL "-mavx512vl")
set(QT_CFLAGS_AVX512IFMA "-mavx512ifma")
set(QT_CFLAGS_AVX512VBMI "-mavx512vbmi")
set(QT_CFLAGS_AVX512VBMI2 "-mavx512vbmi2")
set(QT_CFLAGS_AESNI "-maes")
set(QT_CFLAGS_SHANI "-msha")
set(QT_CFLAGS_VAES "-mvaes")
if(NOT UIKIT AND NOT QT_64BIT)
set(QT_CFLAGS_NEON "-mfpu=neon")
set(__prefix)
if(MSVC AND CLANG)
set(__prefix "/clang:")
endif()
set(QT_CFLAGS_MIPS_DSP "-mdsp")
set(QT_CFLAGS_MIPS_DSPR2 "-mdspr2")
set(QT_CFLAGS_SSE2 "${__prefix}-msse2")
set(QT_CFLAGS_SSE3 "${__prefix}-msse3")
set(QT_CFLAGS_SSSE3 "${__prefix}-mssse3")
set(QT_CFLAGS_SSE4_1 "${__prefix}-msse4.1")
set(QT_CFLAGS_SSE4_2 "${__prefix}-msse4.2")
set(QT_CFLAGS_F16C "${__prefix}-mf16c")
set(QT_CFLAGS_RDRND "${__prefix}-mrdrnd")
set(QT_CFLAGS_RDSEED "${__prefix}-mrdseed")
set(QT_CFLAGS_AVX "${__prefix}-mavx")
set(QT_CFLAGS_AVX2 "${__prefix}-mavx2")
set(QT_CFLAGS_ARCH_HASWELL "${__prefix}-march=haswell")
set(QT_CFLAGS_AVX512F "${__prefix}-mavx512f")
set(QT_CFLAGS_AVX512ER "${__prefix}-mavx512er")
set(QT_CFLAGS_AVX512CD "${__prefix}-mavx512cd")
set(QT_CFLAGS_AVX512PF "${__prefix}-mavx512pf")
set(QT_CFLAGS_AVX512DQ "${__prefix}-mavx512dq")
set(QT_CFLAGS_AVX512BW "${__prefix}-mavx512bw")
set(QT_CFLAGS_AVX512VL "${__prefix}-mavx512vl")
set(QT_CFLAGS_AVX512IFMA "${__prefix}-mavx512ifma")
set(QT_CFLAGS_AVX512VBMI "${__prefix}-mavx512vbmi")
set(QT_CFLAGS_AVX512VBMI2 "${__prefix}-mavx512vbmi2")
set(QT_CFLAGS_AESNI "${__prefix}-maes")
set(QT_CFLAGS_SHANI "${__prefix}-msha")
set(QT_CFLAGS_VAES "${__prefix}-mvaes")
if(NOT UIKIT AND NOT QT_64BIT)
set(QT_CFLAGS_NEON "${__prefix}-mfpu=neon")
endif()
set(QT_CFLAGS_MIPS_DSP "${__prefix}-mdsp")
set(QT_CFLAGS_MIPS_DSPR2 "${__prefix}-mdspr2")
unset(__prefix)
endif()
# Fall through is important, so that more specific flags that might be missing are set by the