cmake: fix documentation of Clang flags for MSVC
Fixed a documentation typo (requested by Wan-Teh Chang in
I54140a1645f539944657c2b18dd801b57e422216).
Additionally, I documented why the change in standard and
architecture flags is necessary for Microsoft's flavour of Clang.
The former (C++11 to 14) is needed to allow the STL to build, since
it's designed for MSVC's default of C++14. The latter is needed to
work around Clang not applying MSVC's semantics for enabling
instruction sets (i.e. its default only enables SSE2, not up to
SSE4.1).
Change-Id: I18bf140d81cbfd19819f00ffc585f90dda6732c6
(cherry picked from commit 24a3240fc573b8dd3a97d3acca3aa9eb8055091e)
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake
index c878665..4a4a6ee 100644
--- a/build/cmake/aom_configure.cmake
+++ b/build/cmake/aom_configure.cmake
@@ -300,7 +300,12 @@
endif()
else()
require_c_flag("-std=c99" YES)
- if(WIN32 AND NOT MINGW)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
+ AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
+ AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+ # MSVC's STL requires C++14 as it's the compiler's default and minimum
+ # supported C++ version. However, clang (as opposed to clang-cl) in Visual
+ # Studio defaults to C++11.
require_cxx_flag_nomsvc("-std=c++14" YES)
else()
require_cxx_flag_nomsvc("-std=c++11" YES)
diff --git a/build/cmake/aom_optimization.cmake b/build/cmake/aom_optimization.cmake
index e48c52b..8d28711 100644
--- a/build/cmake/aom_optimization.cmake
+++ b/build/cmake/aom_optimization.cmake
@@ -46,7 +46,10 @@
add_library(${target_name} OBJECT ${${sources}})
set_property(TARGET ${target_name} PROPERTY FOLDER ${AOM_TARGET_CPU})
- # Clang/CL requires the -mXXX flag. The MSVC version is not granular enough.
+ # MSVC does not need flags for intrinsics flavors other than AVX/AVX2.
+ # However, for clang-cl, the default is SSE2, and the MSVC frontend does not
+ # provide any flags to enable SSE3 up to SSE4.1. So we need to restrict the
+ # usage of MSVC-style flags to only the real MSVC.
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
get_msvc_intrinsic_flag("${flag}" "flag")
endif()