fix clang cmake build on windows

This commit is contained in:
zdenop 2021-04-12 21:41:09 +02:00
parent 91b2b4f4a0
commit 53b8cd04ab

View File

@ -132,7 +132,11 @@ endif()
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -march=native -mtune=native")
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -march=native")
if(NOT CLANG AND MSVC)
# clang-cl does not know this argument
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -mtune=native")
endif()
set(MARCH_NATIVE_OPT ON)
endif()
@ -208,6 +212,16 @@ if(MSVC)
set(HAVE_SSE4_1 ON)
add_definitions("-DHAVE_SSE4_1")
endif()
# clang with MSVC compatibility
if(CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-microsoft-unqualified-friend")
if(HAVE_FMA)
set(FMA_COMPILE_FLAGS "-mfma ${FMA_COMPILE_FLAGS}")
endif(HAVE_FMA)
if(HAVE_SSE4_1)
set(SSE4_1_COMPILE_FLAGS "-msse4.1 ${SSE4_1_COMPILE_FLAGS}")
endif(HAVE_SSE4_1)
endif(CLANG)
endif(MSVC)
endif(AARCH64)
@ -230,6 +244,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG -pedantic -Og")
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) # strdup
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
if (NOT CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")