diff --git a/opus/CMakeLists.txt b/opus/CMakeLists.txt index 8535ad5..4878f80 100644 --- a/opus/CMakeLists.txt +++ b/opus/CMakeLists.txt @@ -14,6 +14,30 @@ include(GNUInstallDirs) include(CMakeDependentOption) include(FeatureSummary) +# Detect clang-cl +set(MSVC_CLANG_CL false BOOL) +if (MSVC) + if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") + set(MSVC_CLANG_CL true BOOL) + endif() +endif() + +if(MSVC) + if(OPUS_STATIC_RUNTIME) + if(CMAKE_BUILD_TYPE MATCHES DEBUG) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + endif() + else() + if(CMAKE_BUILD_TYPE MATCHES DEBUG) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") + endif() + endif() +endif() + set(OPUS_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.") option(OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR} OFF) if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OPUS_BUILD_FRAMEWORK) @@ -271,14 +295,6 @@ if(OPUS_CUSTOM_MODES) list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h) endif() -if(MSVC) - if(OPUS_STATIC_RUNTIME) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - else() - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - endif() -endif() - add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER}) add_library(Opus::opus ALIAS opus) @@ -484,20 +500,20 @@ if(NOT OPUS_DISABLE_INTRINSICS) add_sources_group(opus lpcnet ${dnn_sources_sse4_1}) endif() target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) - if(NOT MSVC) + if(NOT MSVC OR MSVC_CLANG_CL) set_source_files_properties(${celt_sources_sse4_1} ${silk_sources_sse4_1} ${dnn_sources_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) endif() if(OPUS_FIXED_POINT) add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) - if(NOT MSVC) + if(NOT MSVC OR MSVC_CLANG_CL) set_source_files_properties(${silk_sources_fixed_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) endif() endif() endif() if(OPUS_X86_PRESUME_SSE4_1) target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) - if(NOT MSVC) + if(NOT MSVC OR MSVC_CLANG_CL) target_compile_options(opus PRIVATE -msse4.1) endif() endif()