Skip to content

add sndio support #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
42 changes: 42 additions & 0 deletions cmake/modules/Findsndio.cmake
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include_directories(
${ALSA_INCLUDE_DIRS}
${UDEV_INCLUDE_DIRS}
${PORTAUDIO_INCLUDE_DIRS}
${SNDIO_INCLUDE_DIRS}
${CUSTOM_GEOTRANZ_DIR}
)

Expand Down Expand Up @@ -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
)
Expand All @@ -127,6 +132,7 @@ target_link_libraries(direwolf
${ALSA_LIBRARIES}
${UDEV_LIBRARIES}
${PORTAUDIO_LIBRARIES}
${SNDIO_LIBRARIES}
)

if(WIN32 OR CYGWIN)
Expand Down
Loading