Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6a9d6f9

Browse files
committedFeb 13, 2021
add sndio support
1 parent 816c565 commit 6a9d6f9

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed
 

‎CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
143143
configure_file("${CMAKE_SOURCE_DIR}/cmake/cpack/${CMAKE_PROJECT_NAME}.desktop.in"
144144
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.desktop" @ONLY)
145145

146+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
147+
set(OPENBSD TRUE)
148+
set(HAVE_SNDIO TRUE)
149+
146150
elseif(APPLE)
147151
if("${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
148152
message(STATUS "Build for macOS target: local version")
@@ -276,6 +280,12 @@ if(LINUX)
276280
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
277281
endif()
278282

283+
elseif (HAVE_SNDIO)
284+
find_package(sndio REQUIRED)
285+
if(SNDIO_FOUND)
286+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SNDIO")
287+
endif()
288+
279289
elseif (NOT WIN32 AND NOT CYGWIN)
280290
find_package(Portaudio REQUIRED)
281291
if(PORTAUDIO_FOUND)
@@ -289,6 +299,8 @@ else()
289299
set(UDEV_LIBRARIES "")
290300
set(PORTAUDIO_INCLUDE_DIRS "")
291301
set(PORTAUDIO_LIBRARIES "")
302+
set(SNDIO_INCLUDE_DIRS "")
303+
set(SNDIO_LIBRARIES "")
292304
endif()
293305

294306
# manage and fetch new data

‎cmake/modules/Findsndio.cmake

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# - Try to find sndio
2+
#
3+
# SNDIO_FOUND - system has sndio
4+
# SNDIO_LIBRARIES - location of the library for sndio
5+
# SNDIO_INCLUDE_DIRS - location of the include files for sndio
6+
7+
set(SNDIO_ROOT_DIR
8+
"${SNDIO_ROOT_DIR}"
9+
CACHE
10+
PATH
11+
"Directory to search for sndio")
12+
13+
# no need to check pkg-config
14+
15+
find_path(SNDIO_INCLUDE_DIRS
16+
NAMES
17+
sndio.h
18+
PATHS
19+
/usr/local/include
20+
/usr/include
21+
/opt/local/include
22+
HINTS
23+
${SNDIO_ROOT_DIR}
24+
)
25+
26+
find_library(SNDIO_LIBRARIES
27+
NAMES
28+
sndio
29+
PATHS
30+
/usr/local/lib
31+
/usr/lib
32+
/usr/lib64
33+
/opt/local/lib
34+
HINTS
35+
${SNDIIO_ROOT_DIR}
36+
)
37+
38+
39+
include(FindPackageHandleStandardArgs)
40+
find_package_handle_standard_args(SNDIO DEFAULT_MSG SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)
41+
42+
mark_as_advanced(SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)

‎src/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include_directories(
77
${ALSA_INCLUDE_DIRS}
88
${UDEV_INCLUDE_DIRS}
99
${PORTAUDIO_INCLUDE_DIRS}
10+
${SNDIO_INCLUDE_DIRS}
1011
${CUSTOM_GEOTRANZ_DIR}
1112
)
1213

@@ -107,7 +108,11 @@ if(LINUX)
107108
list(REMOVE_ITEM direwolf_SOURCES
108109
dwgpsd.c
109110
)
110-
else() # macOS freebsd openbsd
111+
elseif(HAVE_SNDIO)
112+
list(APPEND direwolf_SOURCES
113+
audio.c
114+
)
115+
else() # macOS freebsd
111116
list(APPEND direwolf_SOURCES
112117
audio_portaudio.c
113118
)
@@ -127,6 +132,7 @@ target_link_libraries(direwolf
127132
${ALSA_LIBRARIES}
128133
${UDEV_LIBRARIES}
129134
${PORTAUDIO_LIBRARIES}
135+
${SNDIO_LIBRARIES}
130136
)
131137

132138
if(WIN32 OR CYGWIN)

0 commit comments

Comments
 (0)
Please sign in to comment.