build: add cmake options for optional dependencies

closes #1
This commit is contained in:
Andrew Kelley 2015-08-31 15:51:49 -07:00
parent 0f508fcf19
commit 0b7c9965f9

View file

@ -24,6 +24,12 @@ set(LIBSOUNDIO_VERSION_PATCH 0)
set(LIBSOUNDIO_VERSION "${LIBSOUNDIO_VERSION_MAJOR}.${LIBSOUNDIO_VERSION_MINOR}.${LIBSOUNDIO_VERSION_PATCH}")
message("Configuring libsoundio version ${LIBSOUNDIO_VERSION}")
option(ENABLE_JACK "Enable JACK backend" ON)
option(ENABLE_PULSEAUDIO "Enable PulseAudio backend" ON)
option(ENABLE_ALSA "Enable ALSA backend" ON)
option(ENABLE_COREAUDIO "Enable CoreAudio backend" ON)
option(ENABLE_WASAPI "Enable WASAPI backend" ON)
find_package(Threads)
if(Threads_FOUND)
set(STATUS_THREADS "OK")
@ -31,41 +37,60 @@ else(Threads_FOUND)
set(STATUS_THREADS "not found")
endif(Threads_FOUND)
find_package(JACK)
if(JACK_FOUND)
if(ENABLE_JACK)
find_package(JACK)
if(JACK_FOUND)
set(STATUS_JACK "OK")
set(SOUNDIO_HAVE_JACK true)
include_directories(${JACK_INCLUDE_DIR})
else()
else()
set(STATUS_JACK "not found")
set(SOUNDIO_HAVE_JACK false)
set(JACK_LIBRARY "")
endif()
else()
set(STATUS_JACK "disabled")
set(SOUNDIO_HAVE_JACK false)
set(JACK_LIBRARY "")
endif()
find_package(PulseAudio)
if(PULSEAUDIO_FOUND)
if(ENABLE_PULSEAUDIO)
find_package(PulseAudio)
if(PULSEAUDIO_FOUND)
set(STATUS_PULSEAUDIO "OK")
set(SOUNDIO_HAVE_PULSEAUDIO true)
include_directories(${PULSEAUDIO_INCLUDE_DIR})
else()
else()
set(STATUS_PULSEAUDIO "not found")
set(SOUNDIO_HAVE_PULSEAUDIO false)
set(PULSEAUDIO_LIBRARY "")
endif()
else()
set(STATUS_PULSEAUDIO "disabled")
set(SOUNDIO_HAVE_PULSEAUDIO false)
set(PULSEAUDIO_LIBRARY "")
endif()
find_package(ALSA)
if(ALSA_FOUND)
if(ENABLE_ALSA)
find_package(ALSA)
if(ALSA_FOUND)
set(STATUS_ALSA "OK")
set(SOUNDIO_HAVE_ALSA true)
include_directories(${ALSA_INCLUDE_DIRS})
else()
else()
set(STATUS_ALSA "not found")
set(SOUNDIO_HAVE_ALSA false)
set(ALSA_LIBRARIES "")
endif()
else()
set(STATUS_ALSA "disabled")
set(SOUNDIO_HAVE_ALSA false)
set(ALSA_LIBRARIES "")
endif()
find_package(CoreAudio)
if(COREAUDIO_FOUND)
if(ENABLE_COREAUDIO)
find_package(CoreAudio)
if(COREAUDIO_FOUND)
set(STATUS_COREAUDIO "OK")
set(SOUNDIO_HAVE_COREAUDIO true)
include_directories(${COREAUDIO_INCLUDE_DIR})
@ -77,21 +102,33 @@ if(COREAUDIO_FOUND)
find_path(AUDIOUNIT_INCLUDE_DIR NAMES AudioUnit.h)
find_library(AUDIOUNIT_LIBRARY NAMES AudioUnit)
include_directories(${AUDIOUNIT_INCLUDE_DIR})
else()
else()
set(STATUS_COREAUDIO "not found")
set(SOUNDIO_HAVE_COREAUDIO false)
set(COREAUDIO_LIBRARY "")
set(COREFOUNDATION_LIBRARY "")
set(AUDIOUNIT_LIBRARY "")
endif()
else()
set(STATUS_COREAUDIO "disabled")
set(SOUNDIO_HAVE_COREAUDIO false)
set(COREAUDIO_LIBRARY "")
set(COREFOUNDATION_LIBRARY "")
set(AUDIOUNIT_LIBRARY "")
endif()
find_package(WASAPI)
if(WASAPI_FOUND)
if(ENABLE_WASAPI)
find_package(WASAPI)
if(WASAPI_FOUND)
set(STATUS_WASAPI "OK")
set(SOUNDIO_HAVE_WASAPI true)
else()
else()
set(STATUS_WASAPI "not found")
set(SOUNDIO_HAVE_WASAPI false)
endif()
else()
set(STATUS_WASAPI "disabled")
set(SOUNDIO_HAVE_WASAPI false)
endif()