vcpkg/ports/rtaudio/fix-pulse.patch
jim wang fa61404c72
[rtaudio] Fix feature pulse compilation error (#38625)
Fix one of https://github.com/microsoft/vcpkg/issues/32398 issue.

Fixed the issue of prompting that pulse and pulse-simple cannot be found
when compiling feature pulse on Linux.
- [X] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [ ] ~~SHA512s are updated for each updated download.~~
- [ ] ~~The "supports" clause reflects platforms that may be fixed by
this new version.~~
- [ ] ~~Any fixed [CI
baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt)
entries are removed from that file.~~
- [ ] ~~Any patches that are no longer applied are deleted from the
port's directory.~~
- [X] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [X] Only one version is added to each modified port's versions file.

Compile test pass with following triplets:
```
x64-windows
x64-linux
```
Usage test pass with following triplets:

```
x64-linux
```
2024-05-09 13:04:12 -07:00

29 lines
1.2 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e021dc..6dbac46 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,9 +149,9 @@ endif()
# Pulse
if (RTAUDIO_API_PULSE)
set(NEED_PTHREAD ON)
- find_library(PULSE_LIB pulse)
- find_library(PULSESIMPLE_LIB pulse-simple)
- list(APPEND LINKLIBS ${PULSE_LIB} ${PULSESIMPLE_LIB})
+ find_package(PkgConfig)
+ pkg_check_modules(pulse-simple REQUIRED IMPORTED_TARGET libpulse-simple)
+ list(APPEND LINKLIBS PkgConfig::pulse-simple)
list(APPEND PKGCONFIG_REQUIRES "libpulse-simple")
list(APPEND API_DEFS "-D__LINUX_PULSE__")
list(APPEND API_LIST "pulse")
@@ -323,6 +323,10 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/RtAudioConfig.cmake.in "@PACKAGE_INIT@\n"
if(NEED_PTHREAD)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/RtAudioConfig.cmake.in "find_package(Threads REQUIRED)\n")
endif()
+if (RTAUDIO_API_PULSE)
+ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/RtAudioConfig.cmake.in "find_package(PkgConfig)\n")
+ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/RtAudioConfig.cmake.in "pkg_check_modules(pulse-simple REQUIRED IMPORTED_TARGET libpulse-simple)\n")
+endif()
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/RtAudioConfig.cmake.in "include(\${CMAKE_CURRENT_LIST_DIR}/RtAudioTargets.cmake)")