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

cmake: fix *_DIR usage on FindLib and re-import SoapySDR module

This commit is contained in:
Davide Gerhard 2019-05-22 11:36:16 +02:00
parent e29500fc6d
commit a4c8a9978a
No known key found for this signature in database
GPG Key ID: 7CBEFA144857DC97
8 changed files with 72 additions and 27 deletions

View File

@ -287,14 +287,7 @@ if(ENABLE_RTLSDR)
find_package(LibRTLSDR) find_package(LibRTLSDR)
endif() endif()
if(ENABLE_SOAPYSDR) if(ENABLE_SOAPYSDR)
find_package(SoapySDR 0.4.0 NO_MODULE) find_package(SoapySDR)
if(NOT "${SoapySDR_LIBRARIES}" STREQUAL "" AND NOT "${SoapySDR_INCLUDE_DIRS}" STREQUAL "")
set(SOAPYSDR_FOUND ON)
message(STATUS "Found SoapySDR: ${SoapySDR_INCLUDE_DIRS}, ${SoapySDR_LIBRARIES}")
endif()
# Only on APPLE; bad!
string(REPLACE "-flat_namespace" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REPLACE "-flat_namespace" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif() endif()
if(ENABLE_XTRX) if(ENABLE_XTRX)
find_package(LibXTRX) find_package(LibXTRX)

View File

@ -2,7 +2,7 @@ if(NOT LIBBLADERF_FOUND)
pkg_check_modules (LIBBLADERF_PKG libbladerf>=2.0) pkg_check_modules (LIBBLADERF_PKG libbladerf>=2.0)
if(LIBBLADERF_PKG_FOUND) if(LIBBLADERF_PKG_FOUND OR (DEFINED BLADERF_DIR))
find_path(LIBBLADERF_INCLUDE_DIRS find_path(LIBBLADERF_INCLUDE_DIRS
NAMES libbladeRF.h NAMES libbladeRF.h
PATHS ${BLADERF_DIR}/include PATHS ${BLADERF_DIR}/include
@ -29,6 +29,6 @@ if(NOT LIBBLADERF_FOUND)
mark_as_advanced(LIBBLADERF_INCLUDE_DIRS LIBBLADERF_LIBRARIES) mark_as_advanced(LIBBLADERF_INCLUDE_DIRS LIBBLADERF_LIBRARIES)
endif(LIBBLADERF_PKG_FOUND) endif(LIBBLADERF_PKG_FOUND OR (DEFINED BLADERF_DIR))
endif(NOT LIBBLADERF_FOUND) endif(NOT LIBBLADERF_FOUND)

View File

@ -2,7 +2,7 @@ if(NOT LIBIIO_FOUND)
pkg_check_modules (LIBIIO_PKG libiio>=0.7) pkg_check_modules (LIBIIO_PKG libiio>=0.7)
if(LIBIIO_PKG_FOUND) if(LIBIIO_PKG_FOUND OR (DEFINED IIO_DIR))
find_path(LIBIIO_INCLUDE_DIR find_path(LIBIIO_INCLUDE_DIR
NAMES iio.h NAMES iio.h
PATHS ${IIO_DIR}/include PATHS ${IIO_DIR}/include
@ -20,15 +20,15 @@ if(NOT LIBIIO_FOUND)
) )
if(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES) if(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES)
set(LIBIIO_FOUND TRUE CACHE INTERNAL "libiio found") set(LIBIIO_FOUND TRUE CACHE INTERNAL "libiio found")
message(STATUS "Found libiio: ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}") message(STATUS "Found libiio: ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}")
else(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES) else(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES)
set(LIBIIO_FOUND FALSE CACHE INTERNAL "libiio found") set(LIBIIO_FOUND FALSE CACHE INTERNAL "libiio found")
message(STATUS "libiio not found.") message(STATUS "libiio not found.")
endif(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES) endif(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES)
mark_as_advanced(LIBIIO_INCLUDE_DIR LIBIIO_LIBRARIES) mark_as_advanced(LIBIIO_INCLUDE_DIR LIBIIO_LIBRARIES)
endif(LIBIIO_PKG_FOUND) endif(LIBIIO_PKG_FOUND OR (DEFINED IIO_DIR))
endif(NOT LIBIIO_FOUND) endif(NOT LIBIIO_FOUND)

View File

@ -0,0 +1,52 @@
if(NOT SOAPYSDR_FOUND)
function(_SOAPY_SDR_GET_ABI_VERSION VERSION SOAPY_SDR_INCLUDE_DIR)
file(READ "${SOAPY_SDR_INCLUDE_DIR}/SoapySDR/Version.h" version_h)
string(REGEX MATCH "\\#define SOAPY_SDR_ABI_VERSION \"([0-9]+\\.[0-9]+(-[A-Za-z0-9]+)?)\"" SOAPY_SDR_ABI_VERSION_MATCHES "${version_h}")
if(NOT SOAPY_SDR_ABI_VERSION_MATCHES)
message(FATAL_ERROR "Failed to extract version number from Version.h")
endif(NOT SOAPY_SDR_ABI_VERSION_MATCHES)
set(${VERSION} "${CMAKE_MATCH_1}" PARENT_SCOPE)
endfunction(_SOAPY_SDR_GET_ABI_VERSION)
pkg_check_modules (LIBSOAPYSDR_PKG soapysdr>=0.4.0)
if(LIBSOAPYSDR_PKG_FOUND OR (DEFINED SOAPYSDR_DIR))
find_path (SOAPYSDR_INCLUDE_DIR
NAMES SoapySDR/Version.h
PATHS ${SOAPYSDR_DIR}/include
${LIBSOAPYSDR_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
)
find_library (SOAPYSDR_LIBRARY
NAMES SoapySDR
HINTS ${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
PATHS ${SOAPYSDR_DIR}/lib
${SOAPYSDR_DIR}/lib64
${LIBSOAPYSDR_PKG_LIBRARY_DIRS}
/usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
)
if (SOAPYSDR_INCLUDE_DIR AND SOAPYSDR_LIBRARY)
set(SOAPYSDR_FOUND TRUE)
# get the root of SoapySDR; used on cpack
string(REGEX REPLACE "/lib/.*${CMAKE_SHARED_LIBRARY_SUFFIX}" "" SOAPYSDR_ROOT ${SOAPYSDR_LIBRARY})
# get the soapy version; to using FindPkgConfig because we can use SOAPYSDR_DIR
_SOAPY_SDR_GET_ABI_VERSION(SOAPYSDR_ABI_VERSION ${SOAPYSDR_INCLUDE_DIR})
message (STATUS "Found SoapySDR: ${SOAPYSDR_INCLUDE_DIR}, ${SOAPYSDR_LIBRARY}")
else()
message (STATUS "SoapySDR not found")
endif()
mark_as_advanced(SOAPYSDR_INCLUDE_DIR SOAPYSDR_LIBRARY SOAPYSDR_ROOT SOAPYSDR_ABI_VERSION)
endif(LIBSOAPYSDR_PKG_FOUND OR (DEFINED SOAPYSDR_DIR))
endif(NOT SOAPYSDR_FOUND)

View File

@ -69,11 +69,11 @@ Plugins = ../PlugIns
# probably libmirsdrapi-rsp.dylib can't be re-distribuited # probably libmirsdrapi-rsp.dylib can't be re-distribuited
# we remove the file at the end of fixup_bundle # we remove the file at the end of fixup_bundle
if(ENABLE_SOAPYSDR AND SOAPYSDR_FOUND) if(ENABLE_SOAPYSDR AND SOAPYSDR_FOUND)
set(SOAPY_SDR_MOD_PATH "${SOAPY_SDR_ROOT}/lib/SoapySDR/modules${SOAPY_SDR_ABI_VERSION}") set(SOAPY_SDR_MOD_PATH "${SOAPYSDR_ROOT}/lib/SoapySDR/modules${SOAPYSDR_ABI_VERSION}")
file(GLOB SOAPY_MODS ${SOAPY_SDR_MOD_PATH}/*.so) file(GLOB SOAPY_MODS ${SOAPY_SDR_MOD_PATH}/*.so)
foreach(SOAPY_MOD_FILE ${SOAPY_MODS}) foreach(SOAPY_MOD_FILE ${SOAPY_MODS})
install( FILES "${SOAPY_MOD_FILE}" install( FILES "${SOAPY_MOD_FILE}"
DESTINATION "../Frameworks/SoapySDR/modules${SOAPY_SDR_ABI_VERSION}" DESTINATION "../Frameworks/SoapySDR/modules${SOAPYSDR_ABI_VERSION}"
COMPONENT Runtime COMPONENT Runtime
) )
endforeach() endforeach()

View File

@ -15,7 +15,7 @@ set(soapysdrdevice_HEADERS
) )
include_directories( include_directories(
${SoapySDR_INCLUDE_DIRS} ${SOAPYSDR_INCLUDE_DIR}
) )
add_library(soapysdrdevice SHARED add_library(soapysdrdevice SHARED
@ -26,7 +26,7 @@ set_target_properties(soapysdrdevice
PROPERTIES DEFINE_SYMBOL "devices_EXPORTS") PROPERTIES DEFINE_SYMBOL "devices_EXPORTS")
target_link_libraries(soapysdrdevice target_link_libraries(soapysdrdevice
${SoapySDR_LIBRARIES} ${SOAPYSDR_LIBRARY}
sdrbase sdrbase
) )

View File

@ -17,7 +17,7 @@ set(soapysdroutput_HEADERS
include_directories( include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices ${CMAKE_SOURCE_DIR}/devices
${SoapySDR_INCLUDE_DIRS} ${SOAPYSDR_INCLUDE_DIR}
) )
if(NOT SERVER_MODE) if(NOT SERVER_MODE)
@ -53,7 +53,7 @@ target_link_libraries(${TARGET_NAME}
sdrbase sdrbase
${TARGET_LIB_GUI} ${TARGET_LIB_GUI}
swagger swagger
${SoapySDR_LIBRARIES} ${SOAPYSDR_LIBRARY}
soapysdrdevice soapysdrdevice
) )

View File

@ -17,7 +17,7 @@ set(soapysdrinput_HEADERS
include_directories( include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices ${CMAKE_SOURCE_DIR}/devices
${SoapySDR_INCLUDE_DIRS} ${SOAPYSDR_INCLUDE_DIR}
) )
if(NOT SERVER_MODE) if(NOT SERVER_MODE)
@ -53,7 +53,7 @@ target_link_libraries(${TARGET_NAME}
sdrbase sdrbase
${TARGET_LIB_GUI} ${TARGET_LIB_GUI}
swagger swagger
${SOAPYSDR_LIBRARIES} ${SOAPYSDR_LIBRARY}
soapysdrdevice soapysdrdevice
) )