1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

add basic external libraries

- codec2
- cm256cc
- mbelib
- serialdv
- dsdcc
This commit is contained in:
Davide Gerhard 2019-05-23 16:01:06 +02:00
parent e79fa91d9c
commit 92129089a5
No known key found for this signature in database
GPG Key ID: 7CBEFA144857DC97
12 changed files with 144 additions and 50 deletions

View File

@ -9,9 +9,6 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# For some external project macros
include(ExternalProject)
# configure version
set(sdrangel_VERSION_MAJOR "4")
set(sdrangel_VERSION_MINOR "8")
@ -27,7 +24,6 @@ option(BUILD_GUI "Build GUI" ON)
option(BUNDLE "Enable distribution bundle" OFF)
option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF)
option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF)
option(ENABLE_EXTERNAL_LIBRARIES "Build external libraries" OFF)
option(ENABLE_AIRSPY "Enable AirSpy support" ON)
option(ENABLE_AIRSPYHF "Enable AirSpyHF support" ON)
option(ENABLE_BLADERF "Enable bladeRF support" ON)
@ -41,6 +37,12 @@ option(ENABLE_RTLSDR "Enable rtl-sdr support" ON)
option(ENABLE_SOAPYSDR "Enable SoapySDR support" ON)
option(ENABLE_XTRX "Enable XTRX support" ON)
option(ENABLE_PACK_MIRSDRAPI "Enable inclusion of the mirsdr-api library - for personal use only" OFF)
# on windows always build external libraries
if(WIN32)
option(ENABLE_EXTERNAL_LIBRARIES "Build external libraries" ON)
else()
option(ENABLE_EXTERNAL_LIBRARIES "Build external libraries" OFF)
endif()
# Set additional project information
set(COMPANY "f4exb")
@ -126,8 +128,7 @@ else()
endif()
set(INSTALL_PLUGINS_DIR "${INSTALL_LIB_DIR}/plugins")
set(INSTALL_PLUGINSSRV_DIR "${INSTALL_LIB_DIR}/pluginssrv")
set(EXTERNAL_BUILD_LIBRARIES "${CMAKE_BINARY_DIR}/external_build")
set(EXTERNAL_INSTALL_LIBRARIES "${CMAKE_BINARY_DIR}/external")
set(EXTERNAL_BUILD_LIBRARIES "${CMAKE_BINARY_DIR}/external")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX TRUE)
@ -143,7 +144,11 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
configure_file("${CMAKE_SOURCE_DIR}/cmake/cpack/${CMAKE_PROJECT_NAME}.desktop.in"
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.desktop" @ONLY)
elseif(APPLE)
message(STATUS "Build for macOS target: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
if("${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
message(STATUS "Build for macOS target: local version")
else()
message(STATUS "Build for macOS target: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
# prepend path to find_*()
set(CMAKE_FIND_ROOT_PATH "/opt/local")
@ -155,14 +160,14 @@ elseif(APPLE)
"${CMAKE_BINARY_DIR}/Info.plist" @ONLY)
elseif (WIN32)
set(EXTERNAL_LIBRARY_FOLDER "${CMAKE_SOURCE_DIR}/external/windows")
set(BOOST_ROOT "${EXTERNAL_LIBRARY_FOLDER}/boot")
set(FFTW3F_INCLUDE_DIRS "${EXTERNAL_LIBRARY_FOLDER}/fftw-3/include")
set(FFTW3F_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/fftw-3/libfftw3f-3.dll")
set(LIBUSB_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/libusb/include")
set(LIBUSB_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/libusb/libusb-1.0.x64.dll")
set(OpenCV_INCLUDE_DIRS "${EXTERNAL_LIBRARY_FOLDER}/opencv/include")
set(OpenCV_LIBS "${EXTERNAL_LIBRARY_FOLDER}/opencv/opencv_ffmpeg410_64.dll")
set(PKG_CONFIG_EXECUTABLE "${EXTERNAL_LIBRARY_FOLDER}/pkg-config-lite/bin/pkg-config.exe")
set(BOOST_ROOT "${EXTERNAL_LIBRARY_FOLDER}/boost" CACHE INTERNAL "")
set(FFTW3F_FOUND ON CACHE INTERNAL "")
set(FFTW3F_INCLUDE_DIRS "${EXTERNAL_LIBRARY_FOLDER}/fftw-3/include" CACHE INTERNAL "")
set(FFTW3F_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/fftw-3/libfftw3f-3.dll" CACHE INTERNAL "")
set(LIBUSB_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/libusb/include" CACHE INTERNAL "")
set(LIBUSB_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/libusb/libusb-1.0.x64.dll" CACHE INTERNAL "")
set(OpenCV_DIR "${EXTERNAL_LIBRARY_FOLDER}/opencv" CACHE INTERNAL "")
set(PKG_CONFIG_EXECUTABLE "${EXTERNAL_LIBRARY_FOLDER}/pkg-config-lite/bin/pkg-config.exe" CACHE INTERNAL "")
endif()
# TODO: check if(DEFINED) and fix macports -D
@ -251,15 +256,14 @@ endif()
# include external cmake if needed
if(ENABLE_EXTERNAL_LIBRARIES)
add_subdirectory(external)
else()
find_package(Codec2)
find_package(CM256cc)
find_package(LibMbe)
find_package(SerialDV)
find_package(LibDSDcc)
endif()
# after external libraries
find_package(LibDSDcc)
find_package(LibMbe)
find_package(SerialDV)
find_package(CM256cc)
find_package(Codec2)
# Devices
if(ENABLE_AIRSPY)
find_package(LibAIRSPY)

View File

@ -1,52 +1,104 @@
# TODO:
# we need a way to build at compile time and the find_package
# - use git submodules and add_subdirectory with "EXCLUDE_FROM_ALL" but probably useless
# - try https://stackoverflow.com/questions/17446981/cmake-externalproject-add-and-findpackage/23570741#23570741
# Many idea are exposed at
# https://stackoverflow.com/questions/15175318/cmake-how-to-build-external-projects-and-include-their-targets
# https://crascit.com/2015/07/25/cmake-gtest/
#
# in essence, we need a way to build external libraries before use it;
# we choose add_dependencies() to the target.
# other viable solution is to use execute_process() during config
# but make the configuration dirty
# add the install path to cmake
# TODO need reload after externalproject build
list(APPEND CMAKE_PREFIX_PATH "${EXTERNAL_INSTALL_LIBRARIES}")
# For some external project macros
include(ExternalProject)
# add the build path to cmake
#list(APPEND CMAKE_PREFIX_PATH "${EXTERNAL_BUILD_LIBRARIES}")
# macro that create symbolic links
macro(makeLink src dest target)
add_custom_command(TARGET ${target} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink ${src} ${dest} DEPENDS ${dest} COMMENT "mklink ${src} -> ${dest}")
endmacro()
# needs boost
ExternalProject_Add(codec2
GIT_REPOSITORY https://github.com/drowe67/codec2.git
GIT_TAG 7a0187da3ffb06fd90c081216b50bab94d02d046
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/codec2"
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(CODEC2_FOUND ON CACHE INTERNAL "")
set(CODEC2_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/codec2/src/codec2/src" CACHE INTERNAL "")
set(CODEC2_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/codec2/src/codec2-build/libcodec2${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
# some source include "codec2/comp.h" and some without codec2
makeLink("${EXTERNAL_BUILD_LIBRARIES}/codec2/src/codec2/src" "${EXTERNAL_BUILD_LIBRARIES}/codec2/src/codec2/src/codec2" codec2)
# needs boost
ExternalProject_Add(cm256cc
GIT_REPOSITORY https://github.com/f4exb/cm256cc.git
GIT_TAG v1.0.5
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/cm256cc"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LIBRARIES}
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(CM256CC_FOUND ON CACHE INTERNAL "")
set(CM256CC_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/cm256cc/src" CACHE INTERNAL "")
set(CM256CC_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/cm256cc/src/cm256cc-build/libcm256cc${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
ExternalProject_Add(mbelib
GIT_REPOSITORY https://github.com/szechyjs/mbelib.git
GIT_TAG "debian/1.3.0"
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/mbelib"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LIBRARIES}
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(DSDCC_DEPENDS mbelib)
set(LIBMBE_FOUND)
set(LIBMBE_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/mbelib/src/mbelib")
set(LIBMBE_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/mbelib/src/mbelib-build/libmbe${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(WIN32 OR LINUX)
ExternalProject_Add(serialdv
GIT_REPOSITORY https://github.com/f4exb/serialDV.git
GIT_TAG v1.0.6
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/serialDV"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LIBRARIES}
GIT_TAG 89c841ce5b24b8b75c329d6330ec216773f002d2
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/serialdv"
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(DSDCC_DEPENDS ${DSDCC_DEPENDS} serialdv)
set(LIBSERIALDV_FOUND ON CACHE INTERNAL "")
set(LIBSERIALDV_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/serialdv/src/serialdv" CACHE INTERNAL "")
set(LIBSERIALDV_LIBRARY "${EXTERNAL_BUILD_LIBRARIES}/serialdv/src/serialdv-build/libserialdv${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
# because sdrbase/dsp/dvserialworker.h use dsp/dvcontroller.h
# so we need a link
makeLink("${EXTERNAL_BUILD_LIBRARIES}/serialdv/src/serialdv" "${EXTERNAL_BUILD_LIBRARIES}/serialdv/src/serialdv/dsp" serialdv)
endif()
# could use mbelib
ExternalProject_Add(dsdcc
GIT_REPOSITORY https://github.com/f4exb/dsdcc.git
GIT_TAG v1.8.4
DEPENDS mbelib
GIT_TAG cee82816bc8982ecb218abbd2baeb5bb5186711b
DEPENDS ${DSDCC_DEPENDS}
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/dsdcc"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LIBRARIES}
)
# needs pkgconfig, libusb
ExternalProject_Add(perseus
GIT_REPOSITORY https://github.com/f4exb/libperseus-sdr.git
GIT_TAG afefa23e3140ac79d845acb68cf0beeb86d09028
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/perseus"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LIBRARIES}
CMAKE_ARGS "-DUSE_MBELIB=ON -DLIBMBE_INCLUDE_DIR=${LIBMBE_INCLUDE_DIR} -DLIBMBE_LIBRARY=${LIBMBE_LIBRARIES} -DLIBSERIALDV_INCLUDE_DIR=${LIBSERIALDV_INCLUDE_DIR} -DLIBSERIALDV_LIBRARY=${LIBSERIALDV_LIBRARY}"
INSTALL_COMMAND ""
TEST_COMMAND ""
)
set(LIBDSDCC_FOUND ON CACHE INTERNAL "")
set(LIBDSDCC_INCLUDE_DIR "${EXTERNAL_BUILD_LIBRARIES}/dsdcc/src" CACHE INTERNAL "")
set(LIBDSDCC_LIBRARIES "${EXTERNAL_BUILD_LIBRARIES}/dsdcc/src/dsdcc-build/libdsdcc${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
# already on the respository
# TODO decide what to do
if(OFF)
# needs pkgconfig, libusb, autoconf, automake and autolib
ExternalProject_Add(perseus
GIT_REPOSITORY https://github.com/f4exb/libperseus-sdr.git
GIT_TAG afefa23e3140ac79d845acb68cf0beeb86d09028
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/perseus"
INSTALL_COMMAND ""
TEST_COMMAND ""
)
# apt install libcodec2-dev
# needs speexdsp
ExternalProject_Add(codec2

2
external/windows vendored

@ -1 +1 @@
Subproject commit 66a1b6495e6ba2906e38e2e1b4609da1d437f0c4
Subproject commit e09fc96d9998207336dfcb42122c046bafd0bdee

View File

@ -72,6 +72,10 @@ add_library(freedv SHARED
${freedv_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(freedv codec2)
endif()
target_link_libraries(freedv
${CODEC2_LIBRARIES}
)

View File

@ -52,6 +52,10 @@ add_library(${TARGET_NAME} SHARED
${dsddemod_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME dsdcc)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -45,6 +45,10 @@ add_library(${TARGET_NAME} SHARED
${freedv_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME} codec2)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -25,6 +25,7 @@ set(remotesink_HEADERS
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${Boost_INCLUDE_DIRS}
${CM256CC_INCLUDE_DIR}
)
@ -55,6 +56,10 @@ add_library(${TARGET_NAME} SHARED
${remotesink_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME} cm256cc)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -45,6 +45,10 @@ add_library(${TARGET_NAME} SHARED
${modfreedv_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME} codec2)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -25,6 +25,7 @@ set(remotesource_HEADERS
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${Boost_INCLUDE_DIRS}
${CM256CC_INCLUDE_DIR}
)
@ -55,6 +56,10 @@ add_library(${TARGET_NAME} SHARED
${remotesource_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME} cm256cc)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -30,6 +30,7 @@ set(remoteoutput_HEADERS
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${Boost_INCLUDE_DIRS}
${CM256CC_INCLUDE_DIR}
)
@ -60,6 +61,10 @@ add_library(${TARGET_NAME} SHARED
${remoteoutput_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME} cm256cc)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -27,6 +27,7 @@ set(remoteinput_HEADERS
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${Boost_INCLUDE_DIRS}
${CM256CC_INCLUDE_DIR}
)
@ -57,6 +58,10 @@ add_library(${TARGET_NAME} SHARED
${remoteinput_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES)
add_dependencies(${TARGET_NAME} cm256cc)
endif()
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}

View File

@ -1,8 +1,8 @@
project (sdrbase)
if(WIN32)
set(OPUS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/external/windows/opus/include")
set(OPUS_LIBRARIES "${CMAKE_SOURCE_DIR}/external/windows/libopus-0.x64.dll")
set(OPUS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/external/windows/libopus/include")
set(OPUS_LIBRARIES "${CMAKE_SOURCE_DIR}/external/windows/libopus/lib/x64/libopus.lib")
endif()
find_package(Opus REQUIRED)
@ -46,8 +46,6 @@ if (LIBSERIALDV_FOUND)
add_definitions(-DDSD_USE_SERIALDV)
include_directories(${LIBSERIALDV_INCLUDE_DIR})
set(sdrbase_SERIALDV_LIB ${LIBSERIALDV_LIBRARY})
else(LIBSERIALDV_FOUND)
message(STATUS "No SerialDV support")
endif(LIBSERIALDV_FOUND)
set(sdrbase_SOURCES
@ -285,6 +283,10 @@ add_library(sdrbase SHARED
${sdrbase_SOURCES}
)
if(ENABLE_EXTERNAL_LIBRARIES AND LIBSERIALDV_FOUND)
add_dependencies(sdrbase serialdv)
endif()
target_link_libraries(sdrbase
${OPUS_LIBRARIES}
${sdrbase_FFTW3F_LIB}