mirror of https://github.com/wb2osz/direwolf.git
Build changes for the use of CM108 for PTT on Mac
The CMake changes are slightly complicated by the Windows build using a local copy of some hidapi files, for some reason, instead of using the hidapi library itself. The Mac version uses hidapi in the same way as other libraries. In the CMake files, it is unclear to me whether "elseif (NOT WIN32 AND NOT CYGWIN)" means the same thing as "elseif (APPLE)", so they are treated separately in order to avoid breaking other build types.
This commit is contained in:
parent
b03a797ec4
commit
b8fdf013c5
|
@ -342,6 +342,17 @@ elseif (HAVE_SNDIO)
|
|||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_SNDIO")
|
||||
endif()
|
||||
|
||||
elseif (APPLE)
|
||||
find_package(Portaudio REQUIRED)
|
||||
if(PORTAUDIO_FOUND)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_PORTAUDIO")
|
||||
endif()
|
||||
|
||||
find_package(hidapi REQUIRED)
|
||||
if(HIDAPI_FOUND)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CM108")
|
||||
endif()
|
||||
|
||||
elseif (NOT WIN32 AND NOT CYGWIN)
|
||||
find_package(Portaudio REQUIRED)
|
||||
if(PORTAUDIO_FOUND)
|
||||
|
@ -367,7 +378,10 @@ add_subdirectory(data)
|
|||
# external libraries
|
||||
add_subdirectory(${CUSTOM_GEOTRANZ_DIR})
|
||||
add_subdirectory(${CUSTOM_REGEX_DIR})
|
||||
add_subdirectory(${CUSTOM_HIDAPI_DIR})
|
||||
if(NOT APPLE)
|
||||
# Mac builds use the hidapi library, not custom local files
|
||||
add_subdirectory(${CUSTOM_HIDAPI_DIR})
|
||||
endif()
|
||||
add_subdirectory(${CUSTOM_MISC_DIR})
|
||||
|
||||
# direwolf source code and utilities
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# - Try to find hidapi
|
||||
#
|
||||
# HIDAPI_FOUND - system has hidapi
|
||||
# HIDAPI_LIBRARIES - location of the library for hidapi
|
||||
# HIDAPI_INCLUDE_DIRS - location of the include files for hidapi
|
||||
|
||||
set(HIDAPI_ROOT_DIR
|
||||
"${HIDAPI_ROOT_DIR}"
|
||||
CACHE
|
||||
PATH
|
||||
"Directory to search for hidapi")
|
||||
|
||||
# no need to check pkg-config
|
||||
|
||||
find_path(HIDAPI_INCLUDE_DIRS
|
||||
NAMES
|
||||
hidapi.h
|
||||
PATHS
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
/opt/local/include
|
||||
HINTS
|
||||
${HIDAPI_ROOT_DIR}
|
||||
PATH_SUFFIXES
|
||||
hidapi
|
||||
)
|
||||
|
||||
find_library(HIDAPI_LIBRARIES
|
||||
NAMES
|
||||
hidapi
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/opt/local/lib
|
||||
HINTS
|
||||
${HIDAPI_ROOT_DIR}
|
||||
)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(HIDAPI DEFAULT_MSG HIDAPI_INCLUDE_DIRS HIDAPI_LIBRARIES)
|
||||
|
||||
mark_as_advanced(HIDAPI_INCLUDE_DIRS HIDAPI_LIBRARIES)
|
|
@ -10,15 +10,21 @@ include_directories(
|
|||
${PORTAUDIO_INCLUDE_DIRS}
|
||||
${SNDIO_INCLUDE_DIRS}
|
||||
${CUSTOM_GEOTRANZ_DIR}
|
||||
${CUSTOM_HIDAPI_DIR}
|
||||
)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
include_directories(
|
||||
${CUSTOM_HIDAPI_DIR}
|
||||
${CUSTOM_REGEX_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
include_directories(
|
||||
${HIDAPI_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# direwolf
|
||||
list(APPEND direwolf_SOURCES
|
||||
|
@ -131,6 +137,7 @@ if(LINUX)
|
|||
else() # macOS freebsd
|
||||
list(APPEND direwolf_SOURCES
|
||||
audio_portaudio.c
|
||||
cm108.c
|
||||
)
|
||||
if(USE_MACOS_DNSSD)
|
||||
list(APPEND direwolf_SOURCES
|
||||
|
@ -469,10 +476,11 @@ endif()
|
|||
|
||||
# List USB audio adapters than can use GPIO for PTT.
|
||||
# Originally for Linux only (using udev).
|
||||
# Version 1.7 adds it for Windows. Needs hidapi library.
|
||||
# Version 1.7 adds it for Windows. Uses local hidapi code.
|
||||
# Post-1.7 adds it for Mac. Uses hidapi library.
|
||||
|
||||
# cm108
|
||||
if(UDEV_FOUND OR WIN32 OR CYGWIN)
|
||||
if(UDEV_FOUND OR WIN32 OR CYGWIN OR HIDAPI_FOUND)
|
||||
list(APPEND cm108_SOURCES
|
||||
cm108.c
|
||||
textcolor.c
|
||||
|
@ -496,6 +504,12 @@ if(UDEV_FOUND OR WIN32 OR CYGWIN)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(cm108
|
||||
${HIDAPI_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32 OR CYGWIN)
|
||||
target_link_libraries(cm108
|
||||
${HIDAPI_LIBRARIES}
|
||||
|
@ -568,6 +582,6 @@ install(TARGETS ttcalc DESTINATION ${INSTALL_BIN_DIR})
|
|||
install(TARGETS kissutil DESTINATION ${INSTALL_BIN_DIR})
|
||||
install(TARGETS tnctest DESTINATION ${INSTALL_BIN_DIR})
|
||||
install(TARGETS appserver DESTINATION ${INSTALL_BIN_DIR})
|
||||
if(UDEV_FOUND OR WIN32 OR CYGWIN)
|
||||
if(UDEV_FOUND OR WIN32 OR CYGWIN OR HIDAPI_FOUND)
|
||||
install(TARGETS cm108 DESTINATION ${INSTALL_BIN_DIR})
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue