Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtlsdr] Add new port #10901

Merged
merged 3 commits into from May 7, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ports/rtlsdr/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Source: rtlsdr
Version: 2020-04-16
Homepage: https://osmocom.org/projects/rtl-sdr
Description: rtl-sdr is a library that turns your Realtek RTL2832 based DVB dongle into a SDR receiver
Build-Depends: libusb, pthreads (windows)
Supports: windows&(x86|x64)
This conversation was marked as resolved.
Show resolved Hide resolved
88 changes: 88 additions & 0 deletions ports/rtlsdr/Compile-with-msvc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2def354..674ff2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,12 @@ endif()
########################################################################
# Find build dependencies
########################################################################
+if(MSVC)
+find_package(pthreads)
+find_package(libusb)
+include_directories(${PThreads4W_INCLUDE_DIR})
+include_directories(${LIBUSB_INCLUDE_DIRS})
+else()
if(WIN32 AND NOT MINGW)
set(THREADS_USE_PTHREADS_WIN32 true)
endif()
@@ -79,6 +85,7 @@ endif()
if(NOT THREADS_FOUND)
message(FATAL_ERROR "pthreads(-win32) required to compile rtl-sdr")
endif()
+endif()

########################################################################
# Create uninstall target
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 33faee7..fda4612 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,7 +20,11 @@
########################################################################
add_library(rtlsdr SHARED librtlsdr.c
tuner_e4k.c tuner_fc0012.c tuner_fc0013.c tuner_fc2580.c tuner_r82xx.c)
+if(MSVC)
+target_link_libraries(rtlsdr ${LIBUSB_LIBRARIES})
+else()
target_link_libraries(rtlsdr PkgConfig::LIBUSB)
+endif()
target_include_directories(rtlsdr PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
@@ -36,7 +40,11 @@ generate_export_header(rtlsdr)
########################################################################
add_library(rtlsdr_static STATIC librtlsdr.c
tuner_e4k.c tuner_fc0012.c tuner_fc0013.c tuner_fc2580.c tuner_r82xx.c)
+if(MSVC)
+target_link_libraries(rtlsdr_static ${LIBUSB_LIBRARIES})
+else()
target_link_libraries(rtlsdr_static PkgConfig::LIBUSB)
+endif()
target_include_directories(rtlsdr_static PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
@@ -58,8 +66,8 @@ IF(MSVC)
${CMAKE_CURRENT_SOURCE_DIR}/rtlsdr.rc.in
${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc
@ONLY)
- target_sources(rtlsdr ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
- target_sources(rtlsdr_static ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
+ target_sources(rtlsdr PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
+ target_sources(rtlsdr_static PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
ENDIF(MSVC)

########################################################################
@@ -77,6 +85,11 @@ add_library(libgetopt_static STATIC
target_link_libraries(convenience_static
rtlsdr
)
+if(MSVC)
+target_link_libraries(convenience_static
+ ${PThreads4W_LIBRARY}
+)
+endif()
endif()

########################################################################
diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c
index 562198f..b4bfa51 100644
--- a/src/rtl_tcp.c
+++ b/src/rtl_tcp.c
@@ -35,6 +35,7 @@
#include <fcntl.h>
#else
#include <winsock2.h>
+#include <ws2tcpip.h>
#include "getopt/getopt.h"
#endif

17 changes: 17 additions & 0 deletions ports/rtlsdr/Findlibusb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
find_path(
LIBUSB_INCLUDE_DIRS
NAMES libusb.h
PATH_SUFFIXES libusb-1.0
)

find_library(
LIBUSB_LIBRARIES
NAMES libusb-1.0
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
LIBUSB
REQUIRED_VARS LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS
)
46 changes: 46 additions & 0 deletions ports/rtlsdr/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
vcpkg_fail_port_install(
ON_TARGET "uwp" "linux" "osx" "android" "freebsd"
ON_ARCH "arm" "arm64"
)

vcpkg_from_git(
OUT_SOURCE_PATH SOURCE_PATH
URL git://git.osmocom.org/rtl-sdr
REF d794155ba65796a76cd0a436f9709f4601509320
PATCHES Compile-with-msvc.patch
)

file(
COPY ${CMAKE_CURRENT_LIST_DIR}/Findlibusb.cmake
DESTINATION ${SOURCE_PATH}/cmake/Modules
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/rtlsdr)
vcpkg_copy_pdbs()

file(
INSTALL ${SOURCE_PATH}/COPYING
DESTINATION ${CURRENT_PACKAGES_DIR}/share/rtlsdr
RENAME copyright
)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
else()
file(GLOB DEBUG_TOOLS "${CURRENT_PACKAGES_DIR}/debug/bin/*.exe")
file(GLOB RELEASE_TOOLS "${CURRENT_PACKAGES_DIR}/bin/*.exe")
file(
INSTALL ${RELEASE_TOOLS}
DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT}
)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
file(REMOVE ${DEBUG_TOOLS} ${RELEASE_TOOLS})
endif()
5 changes: 5 additions & 0 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,11 @@ rpclib:x64-uwp=fail
rpclib:x64-windows=ignore
rpclib:x86-windows=ignore
rpclib:x64-windows-static=ignore
rtlsdr:x64-uwp=fail
rtlsdr:arm64-windows=fail
rtlsdr:arm-uwp=fail
rtlsdr:x64-linux=fail
rtlsdr:x64-osx=fail
rttr:arm-uwp=fail
rttr:x64-uwp=fail
rxspencer:x64-uwp=fail
Expand Down