Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindPortAudio: Link ALSA in static builds on Linux #12291

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmake/modules/FindPortAudio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The following cache variables may also be set:

#]=======================================================================]

include(IsStaticLibrary)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I've added this include to be explicit, we previously assumed that it was transitively included through one of the other FindX modules.


find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_PortAudio QUIET portaudio-2.0)
Expand Down Expand Up @@ -89,6 +91,14 @@ if(PortAudio_FOUND)
)
is_static_library(PortAudio_IS_STATIC PortAudio::PortAudio)
if(PortAudio_IS_STATIC)
if(PortAudio_ALSA_H)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably check if we need this, a few lines above the file states that this was a workaround to provide compile-time defines for checking whether ALSA exists, so we might not want to rely on PortAudio_ALSA_H.

Is it safe to simply link ALSA whenever we find it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do not "link" it. We just tell the linker "Here is something that you may want to link". So you solution should be safe in any case.

find_package(ALSA)
if(ALSA_FOUND)
set_property(TARGET PortAudio::PortAudio APPEND PROPERTY INTERFACE_LINK_LIBRARIES
ALSA::ALSA
)
endif()
endif()
find_package(JACK)
if(JACK_FOUND)
set_property(TARGET PortAudio::PortAudio APPEND PROPERTY INTERFACE_LINK_LIBRARIES
Expand Down
Loading