diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake index b2c91b5e..95fafcb9 100644 --- a/cmake/cpu.cmake +++ b/cmake/cpu.cmake @@ -87,6 +87,23 @@ foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE}) if(SIMD_COMPILE_FLAG) unset(HAS_COMPILE_FLAG CACHE) check_c_compiler_flag(${SIMD_COMPILE_FLAG} HAS_COMPILE_FLAG) + if(HAS_COMPILE_FLAG) + # Do one more check for Clang to circumvent CMake issue 13194. + if(COMMAND check_compiler_flag_common_patterns) + # Only in CMake 3.0 and above. + check_compiler_flag_common_patterns(COMMON_PATTERNS) + else() + set(COMMON_PATTERNS) + endif() + set(CMAKE_REQUIRED_DEFINITIONS ${SIMD_COMPILE_FLAG}) + check_c_source_compiles("int main(void) {return 0;}" FLAG2 + FAIL_REGEX "warning: argument unused during compilation:" + ${COMMON_PATTERNS} + ) + if(NOT FLAG2) + unset(HAS_COMPILE_FLAG CACHE) + endif() + endif() if(HAS_COMPILE_FLAG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SIMD_COMPILE_FLAG}") endif()