1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

Merge pull request #1261 from srcejon/mac_package

Compile HIDAPI on Mac
This commit is contained in:
Edouard Griffiths 2022-05-29 21:58:06 +02:00 committed by GitHub
commit 7acf943a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 23 deletions

View File

@ -398,6 +398,7 @@ else()
find_package(Sgp4)
find_package(AptDec)
find_package(LibDAB)
find_package(HIDAPI)
endif()
if (LIBSIGMF_FOUND AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@ -448,8 +449,6 @@ if(ENABLE_USRP)
find_package(UHD)
endif()
find_package(HIDAPI)
if(ENABLE_FUNCUBE AND UNIX AND LIBUSB_FOUND AND HIDAPI_FOUND)
add_subdirectory(fcdlib)
add_subdirectory(fcdhid)

View File

@ -208,6 +208,14 @@ else()
set(USE_PRECOMPILED_LIBS TRUE)
endif()
# We don't CACHE the _DEPENDS variables, as the external project is only added when NOT _FOUND
# and not in subsequent configures when _FOUND
# Use PARENT_SCOPE so they can still be used in other CMakeFiles.
macro(set_global NAME VALUE)
set(${NAME} ${VALUE})
set(${NAME} ${VALUE} PARENT_SCOPE)
endmacro()
if (NOT LIBUSB_FOUND AND NOT USE_PRECOMPILED_LIBS)
# Cloning git repo doesn't include configure, so we download the bz2 which does
ExternalProject_Add(libusb
@ -218,7 +226,7 @@ if (NOT LIBUSB_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(libusb install_dir)
set(LIBUSB_DEPENDS libusb CACHE INTERNAL "")
set_global(LIBUSB_DEPENDS libusb)
set(LIBUSB_FOUND ON CACHE INTERNAL "")
set(LIBUSB_EXTERNAL ON CACHE INTERNAL "")
set(LIBUSB_INCLUDE_DIR "${install_dir}/include/libusb-1.0" CACHE INTERNAL "")
@ -232,6 +240,25 @@ if (NOT LIBUSB_FOUND AND NOT USE_PRECOMPILED_LIBS)
endif ()
endif (NOT LIBUSB_FOUND AND NOT USE_PRECOMPILED_LIBS)
if (NOT HIDAPI_FOUND AND NOT USE_PRECOMPILED_LIBS)
ExternalProject_Add(hidapi
GIT_REPOSITORY https://github.com/libusb/hidapi.git
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/hidapi"
CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
TEST_COMMAND ""
)
ExternalProject_Get_Property(hidapi install_dir)
set_global(HIDAPI_DEPENDS hidapi)
set(HIDAPI_FOUND ON CACHE INTERNAL "")
set(HIDAPI_EXTERNAL ON CACHE INTERNAL "")
set(HIDAPI_ROOT_DIR "${install_dir}" CACHE INTERNAL "")
set(HIDAPI_INCLUDE_DIRS "${install_dir}/include/hidapi" CACHE INTERNAL "")
if (APPLE)
set(HIDAPI_LIBRARIES "${install_dir}/lib/libhidapi${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
set(MACOS_EXTERNAL_LIBS_FIXUP "${MACOS_EXTERNAL_LIBS_FIXUP};${install_dir}/lib")
endif ()
endif (NOT HIDAPI_FOUND AND NOT USE_PRECOMPILED_LIBS)
if (NOT OPUS_FOUND AND NOT USE_PRECOMPILED_LIBS)
ExternalProject_Add(opus
GIT_REPOSITORY https://github.com/xiph/opus
@ -241,7 +268,7 @@ if (NOT OPUS_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(opus install_dir)
set(OPUS_DEPENDS opus CACHE INTERNAL "")
set_global(OPUS_DEPENDS opus)
set(OPUS_FOUND ON CACHE INTERNAL "")
set(OPUS_EXTERNAL ON CACHE INTERNAL "")
set(OPUS_INCLUDE_DIRS "${install_dir}/include" CACHE INTERNAL "")
@ -264,7 +291,7 @@ if (NOT ZLIB_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(zlib install_dir)
set(ZLIB_DEPENDS zlib CACHE INTERNAL "")
set_global(ZLIB_DEPENDS zlib)
set(ZLIB_FOUND ON CACHE INTERNAL "")
set(ZLIB_EXTERNAL ON CACHE INTERNAL "")
set(ZLIB_INCLUDE_DIRS "${install_dir}/include" CACHE INTERNAL "")
@ -286,7 +313,7 @@ if (NOT FAAD_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(faad source_dir binary_dir install_dir)
set(FAAD_DEPENDS faad CACHE INTERNAL "")
set_global(FAAD_DEPENDS faad)
set(FAAD_FOUND ON CACHE INTERNAL "")
set(FAAD_EXTERNAL ON CACHE INTERNAL "")
set(FAAD_INCLUDE_DIR "${install_dir}/include" CACHE INTERNAL "")
@ -310,7 +337,7 @@ if (NOT FFTW3F_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(fftw3f source_dir binary_dir)
set(FFTW3F_DEPENDS fftw3f CACHE INTERNAL "")
set_global(FFTW3F_DEPENDS fftw3f)
set(FFTW3F_FOUND ON CACHE INTERNAL "")
set(FFTW3F_EXTERNAL ON CACHE INTERNAL "")
set(FFTW3F_INCLUDE_DIRS "${source_dir}/api" "${binary_dir}" CACHE INTERNAL "")
@ -393,7 +420,7 @@ if (NOT FFMEG_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(x264 install_dir)
set(X264_DEPENDS x264 CACHE INTERNAL "")
set_global(X264_DEPENDS x264)
set(X264_PKG_CONFIG_DIR "${install_dir}/lib/pkgconfig")
set(X264_FOUND ON CACHE INTERNAL "")
set(X264_EXTERNAL ON CACHE INTERNAL "")
@ -411,7 +438,7 @@ if (NOT FFMEG_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(x265 install_dir)
set(X265_DEPENDS x265 CACHE INTERNAL "")
set_global(X265_DEPENDS x265)
set(X265_PKG_CONFIG_DIR "${install_dir}/lib/pkgconfig")
set(X265_FOUND ON CACHE INTERNAL "")
set(X265_EXTERNAL ON CACHE INTERNAL "")
@ -428,7 +455,7 @@ if (NOT FFMEG_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(fdk_aac install_dir)
set(FDK_AAC_DEPENDS fdk_aac CACHE INTERNAL "")
set_global(FDK_AAC_DEPENDS fdk_aac)
set(FDK_AAC_PKG_CONFIG_DIR "${install_dir}/lib/pkgconfig")
set(FDK_AAC_FOUND ON CACHE INTERNAL "")
set(FDK_AAC_EXTERNAL ON CACHE INTERNAL "")
@ -447,7 +474,7 @@ if (NOT FFMEG_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(mpg123 install_dir)
set(MPG123_DEPENDS mpg123 CACHE INTERNAL "")
set_global(MPG123_DEPENDS mpg123)
set(MPG123_PKG_CONFIG_DIR "${install_dir}/lib/pkgconfig")
set(MPG123_FOUND ON CACHE INTERNAL "")
set(MPG123_EXTERNAL ON CACHE INTERNAL "")
@ -467,7 +494,7 @@ if (NOT FFMEG_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(lame install_dir)
set(LAME_DEPENDS lame CACHE INTERNAL "")
set_global(LAME_DEPENDS lame)
# ffmpeg doesn't try to use pkg-config for lame, as it doesn't include a .pc file
#set(LAME_PKG_CONFIG_DIR "${install_dir}/lib/pkgconfig")
set(LAME_EXTRA_CFLAGS "-I${install_dir}/include")
@ -491,7 +518,7 @@ if (NOT FFMEG_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(ffmpeg install_dir)
set(FFMPEG_DEPENDS ffmpeg CACHE INTERNAL "")
set_global(FFMPEG_DEPENDS ffmpeg)
set(FFMPEG_INSTALL_DIR "${install_dir}")
set(FFMPEG_FOUND ON CACHE INTERNAL "")
set(FFMPEG_EXTERNAL ON CACHE INTERNAL "")
@ -523,7 +550,7 @@ if (NOT OpenCV_FOUND AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(opencv source_dir binary_dir)
set(OpenCV_DEPENDS opencv CACHE INTERNAL "")
set_global(OpenCV_DEPENDS opencv)
set(OpenCV_FOUND ON CACHE INTERNAL "")
set(OpenCV_EXTERNAL ON CACHE INTERNAL "")
set(OpenCV_INCLUDE_DIRS
@ -578,7 +605,7 @@ if ((NOT CODEC2_FOUND OR CODEC2_EXTERNAL) AND NOT USE_PRECOMPILED_LIBS)
TEST_COMMAND ""
)
ExternalProject_Get_Property(codec2 source_dir binary_dir)
set(CODEC2_DEPENDS codec2 CACHE INTERNAL "")
set_global(CODEC2_DEPENDS codec2)
set(CODEC2_FOUND ON CACHE INTERNAL "")
set(CODEC2_EXTERNAL ON CACHE INTERNAL "")
set(CODEC2_INCLUDE_DIR "${source_dir}/src" "${binary_dir}" CACHE INTERNAL "")
@ -619,7 +646,7 @@ if (NOT CM256CC_FOUND OR CM256CC_EXTERNAL)
TEST_COMMAND ""
)
ExternalProject_Get_Property(cm256cc source_dir binary_dir)
set(CM256CC_DEPENDS cm256cc CACHE INTERNAL "")
set_global(CM256CC_DEPENDS cm256cc)
set(CM256CC_FOUND ON CACHE INTERNAL "")
set(CM256CC_EXTERNAL ON CACHE INTERNAL "")
# we need cm256cc/library.h
@ -652,7 +679,7 @@ if ((NOT LIBDSDCC_FOUND OR LIBDSDCC_EXTERNAL) AND (NOT LIBMBE_FOUND OR LIBMBE_EX
)
ExternalProject_Get_Property(mbelib source_dir binary_dir)
set(USE_MBELIB ON)
set(DSDCC_DEPENDS mbelib)
set_global(DSDCC_DEPENDS mbelib)
set(LIBMBE_FOUND ON CACHE INTERNAL "")
set(LIBMBE_EXTERNAL ON CACHE INTERNAL "")
set(LIBMBE_INCLUDE_DIR "${source_dir}" CACHE INTERNAL "")
@ -683,7 +710,7 @@ if (NOT LIBSERIALDV_FOUND OR LIBSERIALDV_EXTERNAL)
TEST_COMMAND ""
)
ExternalProject_Get_Property(serialdv source_dir binary_dir)
set(DSDCC_DEPENDS ${DSDCC_DEPENDS} serialdv)
set_global(DSDCC_DEPENDS ${DSDCC_DEPENDS} serialdv)
set(LIBSERIALDV_FOUND ON CACHE INTERNAL "")
set(LIBSERIALDV_EXTERNAL ON CACHE INTERNAL "")
set(LIBSERIALDV_INCLUDE_DIR "${source_dir}" CACHE INTERNAL "")
@ -815,7 +842,7 @@ if (WIN32)
TEST_COMMAND ""
)
ExternalProject_Get_Property(pthreads4w source_dir binary_dir)
set(PTHREADS4W_DEPENDS pthreads4w)
set_global(PTHREADS4W_DEPENDS pthreads4w)
set(PTHREADS4W_FOUND ON CACHE INTERNAL "")
set(PTHREADS4W_EXTERNAL ON CACHE INTERNAL "")
set(PTHREADS4W_INCLUDE_DIR "${source_dir}" CACHE INTERNAL "")
@ -872,7 +899,7 @@ if (ZLIB_FOUND AND FAAD_FOUND)
)
endif(WIN32)
ExternalProject_Get_Property(dab source_dir binary_dir)
set(DAB_DEPENDS dab CACHE INTERNAL "")
set_global(DAB_DEPENDS dab)
set(DAB_FOUND ON CACHE INTERNAL "")
set(DAB_EXTERNAL ON CACHE INTERNAL "")
set(DAB_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/dab/src/dab" CACHE INTERNAL "")
@ -1312,7 +1339,7 @@ if (WIN32 OR APPLE)
)
endif ()
ExternalProject_Get_Property(libxml2 source_dir binary_dir)
set(LIBXML2_DEPENDS libxml2)
set_global(LIBXML2_DEPENDS libxml2)
set(LIBXML2_FOUND ON CACHE INTERNAL "")
set(LIBXML2_EXTERNAL ON CACHE INTERNAL "")
set(LIBXML2_INCLUDE_DIR "${source_dir}/include" CACHE INTERNAL "")

View File

@ -28,7 +28,7 @@
#include <stdio.h>
#include <stdint.h>
#include "fcdhidcmd.h"
#include "hidapi/hidapi.h"
#include "hidapi.h"
#include <inttypes.h>

View File

@ -61,7 +61,7 @@ target_link_libraries(${TARGET_NAME}
"${OpenCV_LIBS}"
)
if(OpenCV_EXTERNAL)
if(DEFINED OpenCV_DEPENDS)
add_dependencies(${TARGET_NAME} opencv)
endif()