Skip to content

Commit

Permalink
Fix build errors on MSYS2 (Windows) (LabSound#198)
Browse files Browse the repository at this point in the history
* Fix MSVC compiler flags being passed to the MSYS toolchain

Since MSYS uses GCC (or optionally clang), MSVC flags won't work here.

* Explicitly link Windows Media Foundation libraries for MINGW

It seems that building with VS "just works", but MSYS can't infer them.
  • Loading branch information
phildremi authored Sep 11, 2023
1 parent a494aad commit 666f78a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 6 additions & 4 deletions cmake/LabSound.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ function (configureProj proj)
)
set_property(TARGET ${proj} PROPERTY CXX_STANDARD 17)
if(WIN32)
# Arch AVX is problematic for many users, so disable it until
# some reasonable strategy (a separate AVX target?) is determined
#target_compile_options(${proj} PRIVATE /arch:AVX /Zi)
target_compile_options(${proj} PRIVATE /Zi)
if(MSVC)
# Arch AVX is problematic for many users, so disable it until
# some reasonable strategy (a separate AVX target?) is determined
#target_compile_options(${proj} PRIVATE /arch:AVX /Zi)
target_compile_options(${proj} PRIVATE /Zi)
endif(MSVC)
# TODO: These vars are for libnyquist and should be set in the find libynquist script.
target_compile_definitions(${proj} PRIVATE HAVE_STDINT_H=1 HAVE_SINF=1)
elseif(APPLE)
Expand Down
14 changes: 10 additions & 4 deletions cmake/examples.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ set(CMAKE_CXX_STANDARD 14)
set(proj LabSoundExample)

if(WIN32)
# Arch AVX is problematic for many users, so disable it until
# some reasonable strategy (a separate AVX target?) is determined
#target_compile_options(${proj} PRIVATE /arch:AVX /Zi)
target_compile_options(${proj} PRIVATE /Zi)
if(MSVC)
# Arch AVX is problematic for many users, so disable it until
# some reasonable strategy (a separate AVX target?) is determined
#target_compile_options(${proj} PRIVATE /arch:AVX /Zi)
target_compile_options(${proj} PRIVATE /Zi)
endif(MSVC)
target_compile_definitions(${proj} PRIVATE __WINDOWS_WASAPI__=1)
# TODO: These vars are for libniquist and should be set in the find libynquist script.
target_compile_definitions(${proj} PRIVATE HAVE_STDINT_H=1 HAVE_SINF=1)
Expand Down Expand Up @@ -80,6 +82,10 @@ if (NOT IOS)
target_link_libraries(LabSoundExample LabSound LabSoundRtAudio)
endif()

if(MINGW)
target_link_libraries(LabSoundExample mfuuid mfplat ksuser wmcodecdspuuid)
endif(MINGW)

set_target_properties(LabSoundExample PROPERTIES
RUNTIME_OUTPUT_DIRECTORY bin)

Expand Down

0 comments on commit 666f78a

Please sign in to comment.