[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
```
This commit is contained in:
jim wang
2024-05-09 20:04:12 +00:00
committed by GitHub
parent bdea1d796b
commit fa61404c72
5 changed files with 47 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
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)")

View File

@@ -4,6 +4,8 @@ vcpkg_from_github(
REF ${VERSION}
SHA512 085feb2673185460717ba45fc87254961e477823759e11281092c1ba13301303de1cd36aa9efeba0710cbf2c70f2e2f7f9e41173cf372ded528c41612b19acd5
HEAD_REF master
PATCHES
fix-pulse.patch
)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" RTAUDIO_STATIC_MSVCRT)
@@ -14,13 +16,18 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
alsa RTAUDIO_API_ALSA
pulse RTAUDIO_API_PULSE
)
set(PKG_OPT "")
if("pulse" IN_LIST FEATURES)
vcpkg_find_acquire_program(PKGCONFIG)
set(PKG_OPT "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}")
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DRTAUDIO_STATIC_MSVCRT=${RTAUDIO_STATIC_MSVCRT}
-DRTAUDIO_API_JACK=OFF
${FEATURE_OPTIONS}
${PKG_OPT}
)
vcpkg_cmake_install()

View File

@@ -1,6 +1,7 @@
{
"name": "rtaudio",
"version": "6.0.1",
"port-version": 1,
"description": "A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO and WASAPI) operating systems.",
"homepage": "https://github.com/thestk/rtaudio",
"license": null,
@@ -29,7 +30,10 @@
},
"pulse": {
"description": "Build with PulseAudio backend",
"supports": "linux"
"supports": "linux",
"dependencies": [
"pulseaudio"
]
}
}
}

View File

@@ -7794,7 +7794,7 @@
},
"rtaudio": {
"baseline": "6.0.1",
"port-version": 0
"port-version": 1
},
"rtlsdr": {
"baseline": "2020-04-16",

View File

@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "07842f7b2096168243d97720d33ec5436b0d6365",
"version": "6.0.1",
"port-version": 1
},
{
"git-tree": "b97a9859776e7d23b21a9660e9b31e69fdb84185",
"version": "6.0.1",