On WIN32, fix compile errors on Clang using MSVC headers

This commit is contained in:
Rt39 2024-07-10 01:11:46 +08:00
parent e14acb96c1
commit 8d575db721
2 changed files with 11 additions and 1 deletions

View File

@ -21,6 +21,16 @@ if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
if(WITH_AVX AND MSVC)
set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS /arch:AVX2)
endif()
if(WITH_AVX AND WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang")
cmake_policy(PUSH)
cmake_policy(SET CMP0075 NEW)
check_include_file("unistd.h" HAVE_UNISTD_H)
if(NOT HAVE_UNISTD_H)
# Clang on Windows using MSVC headers
set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS -mavx2)
endif()
cmake_policy(POP)
endif()
else()
check_cpu_arch_arm64(FLAC__CPU_ARM64)
if(FLAC__CPU_ARM64)

View File

@ -221,7 +221,7 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */
#ifndef getenv
#if !defined(getenv) && !(defined(__clang__) && defined(_MSC_VER))
extern char *getenv (const char * name);
#endif