mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-23 21:30:37 +00:00
[libsoundio] Add libsoundio port (#8273)
* [libsoundio] Add libsoundio port * [libsoundio] Add description and homepage * [libsoundio] WindowsStore not supported * [libsoundio] Fix libsoundio-config.cmake * [libsoundio] Fix CMakeLists for Linux
This commit is contained in:
parent
804d8ea43c
commit
889fa61c29
4
ports/libsoundio/CONTROL
Normal file
4
ports/libsoundio/CONTROL
Normal file
@ -0,0 +1,4 @@
|
||||
Source: libsoundio
|
||||
Version: 2.0.0
|
||||
Description: libsoundio is C library providing cross-platform audio input and output.
|
||||
Homepage: http://libsound.io/
|
184
ports/libsoundio/fix_cmakelists.patch
Normal file
184
ports/libsoundio/fix_cmakelists.patch
Normal file
@ -0,0 +1,184 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 6541f1b..058bf3b 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -1,6 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.5)
|
||||
-project(libsoundio C)
|
||||
-set(CMAKE_MODULE_PATH ${libsoundio_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.0.0)
|
||||
set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "library install dir (lib)")
|
||||
@@ -11,6 +9,11 @@ else()
|
||||
cmake_policy(SET CMP0046 NEW)
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
+cmake_policy(SET CMP0022 NEW)
|
||||
+
|
||||
+project(libsoundio C)
|
||||
+set(CMAKE_MODULE_PATH ${libsoundio_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
+set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
|
||||
@@ -27,8 +30,7 @@ if(NOT SOUNDIO_STATIC_LIBNAME)
|
||||
set(SOUNDIO_STATIC_LIBNAME soundio)
|
||||
endif()
|
||||
|
||||
-option(BUILD_STATIC_LIBS "Build static libraries" ON)
|
||||
-option(BUILD_DYNAMIC_LIBS "Build dynamic libraries" ON)
|
||||
+option(BUILD_SHARED_LIBS "Build dynamic libraries" ON)
|
||||
option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON)
|
||||
option(BUILD_TESTS "Build tests" ON)
|
||||
option(ENABLE_JACK "Enable JACK backend" ON)
|
||||
@@ -203,7 +205,7 @@ if(MSVC)
|
||||
set(EXAMPLE_CFLAGS "/W4")
|
||||
set(TEST_CFLAGS "${LIB_CFLAGS}")
|
||||
set(TEST_LDFLAGS " ")
|
||||
- set(LIBM " ")
|
||||
+ set(LIBM "")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -pedantic")
|
||||
set(LIB_CFLAGS "-std=c11 -fvisibility=hidden -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes -D_REENTRANT -D_POSIX_C_SOURCE=200809L -Wno-missing-braces")
|
||||
@@ -223,32 +225,33 @@ configure_file(
|
||||
${DOXYGEN_CONF_FILE}
|
||||
)
|
||||
|
||||
-if(BUILD_DYNAMIC_LIBS)
|
||||
- add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES})
|
||||
- set_target_properties(libsoundio_shared PROPERTIES
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
+ add_library(libsoundio SHARED ${LIBSOUNDIO_SOURCES})
|
||||
+ set_target_properties(libsoundio PROPERTIES PUBLIC_HEADER "${LIBSOUNDIO_HEADERS}")
|
||||
+ set_target_properties(libsoundio PROPERTIES
|
||||
OUTPUT_NAME soundio
|
||||
SOVERSION ${LIBSOUNDIO_VERSION_MAJOR}
|
||||
VERSION ${LIBSOUNDIO_VERSION}
|
||||
COMPILE_FLAGS ${LIB_CFLAGS}
|
||||
LINKER_LANGUAGE C
|
||||
)
|
||||
- target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS})
|
||||
- install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
-endif()
|
||||
-
|
||||
-if(BUILD_STATIC_LIBS)
|
||||
- add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES})
|
||||
- set_target_properties(libsoundio_static PROPERTIES
|
||||
- OUTPUT_NAME ${SOUNDIO_STATIC_LIBNAME}
|
||||
+ target_link_libraries(libsoundio LINK_PUBLIC ${LIBSOUNDIO_LIBS})
|
||||
+ install(TARGETS libsoundio EXPORT libsoundio-export LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
+else()
|
||||
+ add_library(libsoundio STATIC ${LIBSOUNDIO_SOURCES})
|
||||
+ set_target_properties(libsoundio PROPERTIES PUBLIC_HEADER "${LIBSOUNDIO_HEADERS}")
|
||||
+ set_target_properties(libsoundio PROPERTIES
|
||||
+ OUTPUT_NAME soundio
|
||||
COMPILE_FLAGS ${LIB_CFLAGS}
|
||||
LINKER_LANGUAGE C
|
||||
)
|
||||
- install(TARGETS libsoundio_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
+ target_link_libraries(libsoundio LINK_PUBLIC ${LIBSOUNDIO_LIBS})
|
||||
+ target_compile_definitions(libsoundio PUBLIC SOUNDIO_STATIC_LIBRARY)
|
||||
+ install(TARGETS libsoundio EXPORT libsoundio-export LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
-install(FILES
|
||||
- ${LIBSOUNDIO_HEADERS}
|
||||
- DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/soundio")
|
||||
+add_library(libsoundio::libsoundio ALIAS libsoundio)
|
||||
+install(EXPORT libsoundio-export FILE libsoundio-config.cmake DESTINATION share/libsoundio/ NAMESPACE ${PROJECT_NAME}:: EXPORT_LINK_INTERFACE_LIBRARIES)
|
||||
|
||||
# Example Programs
|
||||
|
||||
@@ -257,44 +260,28 @@ if(BUILD_EXAMPLE_PROGRAMS)
|
||||
set_target_properties(sio_sine PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(sio_sine libsoundio_shared ${LIBM})
|
||||
- else()
|
||||
- target_link_libraries(sio_sine libsoundio_static ${LIBSOUNDIO_LIBS} ${LIBM})
|
||||
- endif()
|
||||
+ target_link_libraries(sio_sine libsoundio::libsoundio ${LIBM})
|
||||
install(TARGETS sio_sine DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
add_executable(sio_list_devices example/sio_list_devices.c)
|
||||
set_target_properties(sio_list_devices PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(sio_list_devices libsoundio_shared)
|
||||
- else()
|
||||
- target_link_libraries(sio_list_devices libsoundio_static ${LIBSOUNDIO_LIBS})
|
||||
- endif()
|
||||
+ target_link_libraries(sio_list_devices libsoundio::libsoundio)
|
||||
install(TARGETS sio_list_devices DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
add_executable(sio_microphone example/sio_microphone.c)
|
||||
set_target_properties(sio_microphone PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(sio_microphone libsoundio_shared)
|
||||
- else()
|
||||
- target_link_libraries(sio_microphone libsoundio_static ${LIBSOUNDIO_LIBS})
|
||||
- endif()
|
||||
+ target_link_libraries(sio_microphone libsoundio::libsoundio)
|
||||
install(TARGETS sio_microphone DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
add_executable(sio_record example/sio_record.c)
|
||||
set_target_properties(sio_record PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(sio_record libsoundio_shared)
|
||||
- else()
|
||||
- target_link_libraries(sio_record libsoundio_static ${LIBSOUNDIO_LIBS})
|
||||
- endif()
|
||||
+ target_link_libraries(sio_record libsoundio::libsoundio)
|
||||
install(TARGETS sio_record DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
@@ -308,7 +295,7 @@ if(BUILD_TESTS)
|
||||
)
|
||||
|
||||
add_executable(latency "${libsoundio_SOURCE_DIR}/test/latency.c" ${LIBSOUNDIO_SOURCES})
|
||||
- target_link_libraries(latency LINK_PUBLIC ${LIBSOUNDIO_LIBS} ${LIBM})
|
||||
+ target_link_libraries(latency LINK_PUBLIC libsoundio::libsoundio ${LIBM})
|
||||
set_target_properties(latency PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${LIB_CFLAGS}
|
||||
@@ -318,31 +305,19 @@ if(BUILD_TESTS)
|
||||
set_target_properties(underflow PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(underflow libsoundio_shared ${LIBM})
|
||||
- else()
|
||||
- target_link_libraries(underflow libsoundio_static ${LIBSOUNDIO_LIBS} ${LIBM})
|
||||
- endif()
|
||||
+ target_link_libraries(underflow libsoundio::libsoundio ${LIBM})
|
||||
|
||||
add_executable(backend_disconnect_recover test/backend_disconnect_recover.c)
|
||||
set_target_properties(backend_disconnect_recover PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(backend_disconnect_recover libsoundio_shared)
|
||||
- else()
|
||||
- target_link_libraries(backend_disconnect_recover libsoundio_static ${LIBSOUNDIO_LIBS})
|
||||
- endif()
|
||||
+ target_link_libraries(backend_disconnect_recover libsoundio::libsoundio)
|
||||
|
||||
add_executable(overflow test/overflow.c)
|
||||
set_target_properties(overflow PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
COMPILE_FLAGS ${EXAMPLE_CFLAGS})
|
||||
- if(BUILD_DYNAMIC_LIBS)
|
||||
- target_link_libraries(overflow libsoundio_shared)
|
||||
- else()
|
||||
- target_link_libraries(overflow libsoundio_static ${LIBSOUNDIO_LIBS})
|
||||
- endif()
|
||||
+ target_link_libraries(overflow libsoundio::libsoundio)
|
||||
|
||||
|
||||
|
36
ports/libsoundio/fix_example.patch
Normal file
36
ports/libsoundio/fix_example.patch
Normal file
@ -0,0 +1,36 @@
|
||||
diff --git a/sio_microphone.c b/sio_microphone.c
|
||||
index 0fa8cca..5c89656 100644
|
||||
--- a/sio_microphone.c
|
||||
+++ b/sio_microphone.c
|
||||
@@ -45,10 +45,13 @@ static int prioritized_sample_rates[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
-
|
||||
+#ifdef _MSC_VER
|
||||
+__declspec (noreturn)
|
||||
+#else
|
||||
__attribute__ ((cold))
|
||||
__attribute__ ((noreturn))
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
+#endif
|
||||
static void panic(const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
diff --git a/sio_record.c b/sio_record.c
|
||||
index 61d584d..c33b05e 100644
|
||||
--- a/sio_record.c
|
||||
+++ b/sio_record.c
|
||||
@@ -12,7 +12,12 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
+#ifdef _WIN32
|
||||
+#include <windows.h>
|
||||
+#define sleep(n) Sleep(n * 1000)
|
||||
+#else
|
||||
#include <unistd.h>
|
||||
+#endif
|
||||
|
||||
struct RecordContext {
|
||||
struct SoundIoRingBuffer *ring_buffer;
|
82
ports/libsoundio/fix_test.patch
Normal file
82
ports/libsoundio/fix_test.patch
Normal file
@ -0,0 +1,82 @@
|
||||
diff --git a/backend_disconnect_recover.c b/backend_disconnect_recover.c
|
||||
index 046a150..7c89df7 100644
|
||||
--- a/backend_disconnect_recover.c
|
||||
+++ b/backend_disconnect_recover.c
|
||||
@@ -12,11 +12,20 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
+#ifdef _WIN32
|
||||
+#include <windows.h>
|
||||
+#define sleep(n) Sleep(n * 1000)
|
||||
+#else
|
||||
#include <unistd.h>
|
||||
+#endif
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+__declspec (noreturn)
|
||||
+#else
|
||||
__attribute__ ((cold))
|
||||
__attribute__ ((noreturn))
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
+#endif
|
||||
static void panic(const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
diff --git a/overflow.c b/overflow.c
|
||||
index 43b6d22..67947fe 100644
|
||||
--- a/overflow.c
|
||||
+++ b/overflow.c
|
||||
@@ -12,7 +12,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
+#ifdef _WIN32
|
||||
+#include <windows.h>
|
||||
+#define sleep(n) Sleep(n * 1000)
|
||||
+#else
|
||||
#include <unistd.h>
|
||||
+#endif
|
||||
|
||||
static enum SoundIoFormat prioritized_formats[] = {
|
||||
SoundIoFormatFloat32NE,
|
||||
@@ -36,9 +41,13 @@ static enum SoundIoFormat prioritized_formats[] = {
|
||||
SoundIoFormatInvalid,
|
||||
};
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+__declspec (noreturn)
|
||||
+#else
|
||||
__attribute__ ((cold))
|
||||
__attribute__ ((noreturn))
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
+#endif
|
||||
static void panic(const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
diff --git a/underflow.c b/underflow.c
|
||||
index 083e92d..32907de 100644
|
||||
--- a/underflow.c
|
||||
+++ b/underflow.c
|
||||
@@ -12,12 +12,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
+#ifdef _WIN32
|
||||
+#include <windows.h>
|
||||
+#define sleep(n) Sleep(n * 1000)
|
||||
+#else
|
||||
#include <unistd.h>
|
||||
+#endif
|
||||
#include <stdint.h>
|
||||
|
||||
+#ifdef _MSC_VER
|
||||
+__declspec (noreturn)
|
||||
+#else
|
||||
__attribute__ ((cold))
|
||||
__attribute__ ((noreturn))
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
+#endif
|
||||
static void panic(const char *format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
41
ports/libsoundio/portfile.cmake
Normal file
41
ports/libsoundio/portfile.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
include(vcpkg_common_functions)
|
||||
|
||||
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||
message(FATAL_ERROR "WindowsStore not supported")
|
||||
endif()
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO andrewrk/libsoundio
|
||||
REF 2.0.0
|
||||
SHA512 347a9be1789a41e778ea8d0efa1d00e03e725a4ab65e3aaf6c71e49138643f08a50a81bd60087d86a3b4d63beaeec617e47ba6b81f829ece8a3ac17418eb5309
|
||||
HEAD_REF master
|
||||
PATCHES
|
||||
fix_cmakelists.patch
|
||||
fix_example.patch
|
||||
fix_test.patch
|
||||
)
|
||||
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED_LIBS)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
|
||||
-DBUILD_EXAMPLE_PROGRAMS=OFF
|
||||
-DBUILD_TESTS=OFF
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
vcpkg_fixup_cmake_targets()
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
|
||||
endif()
|
||||
|
||||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libsoundio RENAME copyright)
|
||||
|
||||
vcpkg_test_cmake(PACKAGE_NAME libsoundio)
|
Loading…
x
Reference in New Issue
Block a user