add sndio support

This commit is contained in:
SASANO Takayoshi 2021-02-13 12:22:05 +09:00
parent 816c5659f8
commit 6a9d6f96e7
3 changed files with 61 additions and 1 deletions

View File

@ -143,6 +143,10 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
configure_file("${CMAKE_SOURCE_DIR}/cmake/cpack/${CMAKE_PROJECT_NAME}.desktop.in"
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.desktop" @ONLY)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
set(OPENBSD TRUE)
set(HAVE_SNDIO TRUE)
elseif(APPLE)
if("${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
message(STATUS "Build for macOS target: local version")
@ -276,6 +280,12 @@ if(LINUX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
endif()
elseif (HAVE_SNDIO)
find_package(sndio REQUIRED)
if(SNDIO_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SNDIO")
endif()
elseif (NOT WIN32 AND NOT CYGWIN)
find_package(Portaudio REQUIRED)
if(PORTAUDIO_FOUND)
@ -289,6 +299,8 @@ else()
set(UDEV_LIBRARIES "")
set(PORTAUDIO_INCLUDE_DIRS "")
set(PORTAUDIO_LIBRARIES "")
set(SNDIO_INCLUDE_DIRS "")
set(SNDIO_LIBRARIES "")
endif()
# manage and fetch new data

View File

@ -0,0 +1,42 @@
# - Try to find sndio
#
# SNDIO_FOUND - system has sndio
# SNDIO_LIBRARIES - location of the library for sndio
# SNDIO_INCLUDE_DIRS - location of the include files for sndio
set(SNDIO_ROOT_DIR
"${SNDIO_ROOT_DIR}"
CACHE
PATH
"Directory to search for sndio")
# no need to check pkg-config
find_path(SNDIO_INCLUDE_DIRS
NAMES
sndio.h
PATHS
/usr/local/include
/usr/include
/opt/local/include
HINTS
${SNDIO_ROOT_DIR}
)
find_library(SNDIO_LIBRARIES
NAMES
sndio
PATHS
/usr/local/lib
/usr/lib
/usr/lib64
/opt/local/lib
HINTS
${SNDIIO_ROOT_DIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SNDIO DEFAULT_MSG SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)
mark_as_advanced(SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)

View File

@ -7,6 +7,7 @@ include_directories(
${ALSA_INCLUDE_DIRS}
${UDEV_INCLUDE_DIRS}
${PORTAUDIO_INCLUDE_DIRS}
${SNDIO_INCLUDE_DIRS}
${CUSTOM_GEOTRANZ_DIR}
)
@ -107,7 +108,11 @@ if(LINUX)
list(REMOVE_ITEM direwolf_SOURCES
dwgpsd.c
)
else() # macOS freebsd openbsd
elseif(HAVE_SNDIO)
list(APPEND direwolf_SOURCES
audio.c
)
else() # macOS freebsd
list(APPEND direwolf_SOURCES
audio_portaudio.c
)
@ -127,6 +132,7 @@ target_link_libraries(direwolf
${ALSA_LIBRARIES}
${UDEV_LIBRARIES}
${PORTAUDIO_LIBRARIES}
${SNDIO_LIBRARIES}
)
if(WIN32 OR CYGWIN)