1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 01:18:38 -05:00

Fix and refactor FindSoapySDR.cmake

This commit is contained in:
Mykola Dvornik 2024-06-01 19:25:42 +02:00
parent 03bb11b869
commit 4252592045
6 changed files with 30 additions and 29 deletions

View File

@ -9,44 +9,45 @@ if(NOT SOAPYSDR_FOUND)
set(${VERSION} "${CMAKE_MATCH_1}" PARENT_SCOPE)
endfunction(_SOAPY_SDR_GET_ABI_VERSION)
pkg_search_module (LIBSOAPYSDR_PKG soapysdr>=0.4.0 SoapySDR>=0.4.0)
pkg_search_module (SOAPYSDR SoapySDR>=0.4.0)
if(NOT LIBSOAPYSDR_PKG_FOUND OR (DEFINED SOAPYSDR_DIR))
if(NOT SOAPYSDR_FOUND OR (DEFINED SOAPYSDR_DIR))
find_path (SOAPYSDR_INCLUDE_DIR
find_path (SOAPYSDR_INCLUDE_DIRS
NAMES SoapySDR/Version.h
HINTS ${SOAPYSDR_DIR}/include
${LIBSOAPYSDR_PKG_INCLUDE_DIRS}
PATHS /usr/include
/usr/local/include
)
)
find_library (SOAPYSDR_LIBRARY
find_library (SOAPYSDR_LINK_LIBRARIES
NAMES SoapySDR
HINTS ${SOAPYSDR_DIR}/lib
${SOAPYSDR_DIR}/lib64
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
${LIBSOAPYSDR_PKG_LIBRARY_DIRS}
PATHS /usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
)
)
if (SOAPYSDR_INCLUDE_DIR AND SOAPYSDR_LIBRARY)
if (SOAPYSDR_INCLUDE_DIRS AND SOAPYSDR_LINK_LIBRARIES)
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")
string(REGEX REPLACE "/lib/.*${CMAKE_SHARED_LIBRARY_SUFFIX}" "" SOAPYSDR_LIBDIR ${SOAPYSDR_LINK_LIBRARIES})
# get the soapy version
_SOAPY_SDR_GET_ABI_VERSION(SOAPYSDR_VERSION ${SOAPYSDR_INCLUDE_DIRS})
endif()
mark_as_advanced(SOAPYSDR_INCLUDE_DIR SOAPYSDR_LIBRARY SOAPYSDR_ROOT SOAPYSDR_ABI_VERSION)
endif(NOT SOAPYSDR_FOUND OR (DEFINED SOAPYSDR_DIR))
endif(NOT LIBSOAPYSDR_PKG_FOUND OR (DEFINED SOAPYSDR_DIR))
if (SOAPYSDR_FOUND)
message (STATUS "Found SoapySDR: version ${SOAPYSDR_VERSION}, ${SOAPYSDR_LIBDIR}, ${SOAPYSDR_INCLUDE_DIRS}, ${SOAPYSDR_LINK_LIBRARIES}")
else()
message (STATUS "SoapySDR not found")
endif()
mark_as_advanced(SOAPYSDR_INCLUDE_DIRS SOAPYSDR_LINK_LIBRARIES SOAPYSDR_LIBDIR SOAPYSDR_VERSION)
endif(NOT SOAPYSDR_FOUND)

View File

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

View File

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

View File

@ -1224,7 +1224,7 @@ if (WIN32 OR APPLE)
if (ENABLE_SOAPYSDR)
if (WIN32)
set(SOAPYSDR_LIBRARY "${SDRANGEL_BINARY_LIB_DIR}/SoapySDR.lib" CACHE INTERNAL "")
set(SOAPYSDR_LINK_LIBRARIES "${SDRANGEL_BINARY_LIB_DIR}/SoapySDR.lib" CACHE INTERNAL "")
endif ()
ExternalProject_Add(soapysdr
GIT_REPOSITORY https://github.com/pothosware/SoapySDR.git
@ -1235,7 +1235,7 @@ if (WIN32 OR APPLE)
-DENABLE_PYTHON=OFF
-DENABLE_PYTHON3=OFF
-DENABLE_TESTS=OFF
BUILD_BYPRODUCTS "${SOAPYSDR_LIBRARY}"
BUILD_BYPRODUCTS "${SOAPYSDR_LINK_LIBRARIES}"
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> -- SoapySDR
INSTALL_COMMAND ""
TEST_COMMAND ""
@ -1243,12 +1243,12 @@ if (WIN32 OR APPLE)
ExternalProject_Get_Property(soapysdr source_dir binary_dir)
set_global_cache(SOAPYSDR_FOUND ON)
set(SOAPYSDR_EXTERNAL ON CACHE INTERNAL "")
set(SOAPYSDR_INCLUDE_DIR "${source_dir}/include" CACHE INTERNAL "")
set(SOAPYSDR_INCLUDE_DIRS "${source_dir}/include" CACHE INTERNAL "")
if (WIN32)
install(FILES "${SDRANGEL_BINARY_BIN_DIR}/SoapySDR${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION "${INSTALL_LIB_DIR}")
install(DIRECTORY "${SDRANGEL_BINARY_LIB_DIR}/SoapySDR" DESTINATION "${INSTALL_LIB_DIR}/lib")
elseif (APPLE)
set(SOAPYSDR_LIBRARY "${binary_dir}/lib/libSoapySDR${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
set(SOAPYSDR_LINK_LIBRARIES "${binary_dir}/lib/libSoapySDR${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE INTERNAL "")
install(DIRECTORY "${binary_dir}/lib/" DESTINATION "${INSTALL_LIB_DIR}"
FILES_MATCHING PATTERN "libSoapySDR*${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(MACOS_EXTERNAL_LIBS_FIXUP "${MACOS_EXTERNAL_LIBS_FIXUP};${binary_dir}/lib/")

View File

@ -19,7 +19,7 @@ set(soapysdroutput_HEADERS
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${SOAPYSDR_INCLUDE_DIR}
${SOAPYSDR_INCLUDE_DIRS}
)
if(NOT SERVER_MODE)
@ -55,7 +55,7 @@ target_link_libraries(${TARGET_NAME}
sdrbase
${TARGET_LIB_GUI}
swagger
${SOAPYSDR_LIBRARY}
${SOAPYSDR_LINK_LIBRARIES}
soapysdrdevice
)

View File

@ -19,7 +19,7 @@ set(soapysdrinput_HEADERS
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${SOAPYSDR_INCLUDE_DIR}
${SOAPYSDR_INCLUDE_DIRS}
)
if(NOT SERVER_MODE)
@ -55,7 +55,7 @@ target_link_libraries(${TARGET_NAME}
sdrbase
${TARGET_LIB_GUI}
swagger
${SOAPYSDR_LIBRARY}
${SOAPYSDR_LINK_LIBRARIES}
soapysdrdevice
)