andrewrk / libsoundio

C library for cross-platform real-time audio input and output
http://libsound.io/
MIT License
1.92k stars 229 forks source link

Add install libsoundio-config.cmake #220

Open UnaNancyOwen opened 4 years ago

UnaNancyOwen commented 4 years ago

This pull-request will change to install libsoundio-config.cmake. It makes possible to users to find libraries using find_package(libsoundio) in CMakeLists.txt.

cmake_minimum_required(VERSION 3.6)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(sample)
add_executable(sample main.cpp)

find_package(libsoundio REQUIRED)

if(libsoundio_FOUND)
    target_link_libraries(sample libsoundio::libsoundio)
endif()

I have confirmed that this change works correctly on Windows. unit_tests are all OK (success).

PS C:\libsoundio\build\Release> .\unit_tests.exe
testing os_get_time...OK
testing create output stream...OK
testing mirrored memory...OK
testing soundio_device_nearest_sample_rate...OK
testing ring buffer basic...OK
testing ring buffer threaded...OK

However, it has not been tested on Linux and Mac yet. It is necessary to test on Linux and Mac, because CMakeLists.txt has changed significantly. Please try test on Linux and Mac.

(This pull-request change CMake option to BUILD_SHARED_LIBS from BUILD_DYNAMIC_LIBS. BUILD_STATIC_LIBS option has been discontinued along with that. If you build static link library, Please set BUILD_SHARED_LIBS option to OFF.)

UnaNancyOwen commented 4 years ago

I was finished fixes this pull-request. It is work correctly on Windows and Linux (Ubunts 18.04 LTS). Perhaps, It will also work on Mac.

t_sugiura0204@ubuntu:~/libsoundio/build$ ./unit_tests
testing os_get_time...OK
testing create output stream...OK
testing mirrored memory...OK
testing soundio_device_nearest_sample_rate...OK
testing ring buffer basic...OK
testing ring buffer threaded...OK
UnaNancyOwen commented 4 years ago

@andrewrk Please review this pull-request! Thanks,

janhenke commented 2 years ago

@andrewrk I was searching for exactly this feature today. Would you mind taking a look at this PR and consider merging it? It would be tremendously useful for consumers of the library.