aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt28
-rw-r--r--src/CMakeLists.txt12
-rw-r--r--src/rtl_tcp.c1
3 files changed, 31 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2def354..e2946ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,14 +66,25 @@ endif()
########################################################################
# Find build dependencies
########################################################################
-if(WIN32 AND NOT MINGW)
- set(THREADS_USE_PTHREADS_WIN32 true)
-endif()
find_package(Threads)
find_package(PkgConfig)
-pkg_check_modules(LIBUSB libusb-1.0 IMPORTED_TARGET)
-if(NOT LIBUSB_FOUND)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(LIBUSB libusb-1.0 IMPORTED_TARGET)
+else()
+ set(LIBUSB_LIBRARIES "" CACHE STRING "manual libusb path")
+ set(LIBUSB_INCLUDE_DIRS "" CACHE STRING "manual libusb includepath")
+endif()
+
+if(MSVC)
+ set(THREADS_PTHREADS_LIBRARY "" CACHE STRING "manual pthread-win32 path")
+ set(THREADS_PTHREADS_INCLUDE_DIR "" CACHE STRING "manual pthread-win32 includepath")
+else()
+ set(THREADS_PTHREADS_LIBRARY "" CACHE INTERNAL "manual pthread-win32 path")
+ set(THREADS_PTHREADS_INCLUDE_DIR "" CACHE INTERNAL "manual pthread-win32 includepath")
+endif()
+
+if(PKG_CONFIG_FOUND AND NOT LIBUSB_FOUND)
message(FATAL_ERROR "LibUSB 1.0 required to compile rtl-sdr")
endif()
if(NOT THREADS_FOUND)
@@ -139,7 +150,7 @@ add_subdirectory(src)
########################################################################
# Create Pkg Config File
########################################################################
-FOREACH(inc ${LIBUSB_INCLUDE_DIR})
+FOREACH(inc ${LIBUSB_INCLUDEDIR})
LIST(APPEND RTLSDR_PC_CFLAGS "-I${inc}")
ENDFOREACH(inc)
@@ -157,6 +168,11 @@ IF(CMAKE_CROSSCOMPILING)
UNSET(RTLSDR_PC_LIBS)
ENDIF(CMAKE_CROSSCOMPILING)
+set(prefix "${CMAKE_INSTALL_PREFIX}")
+set(exec_prefix \${prefix})
+set(includedir \${prefix}/include)
+set(libdir \${exec_prefix}/lib)
+
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/librtlsdr.pc.in
${CMAKE_CURRENT_BINARY_DIR}/librtlsdr.pc
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index de93044..7b47309 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,10 +20,12 @@
########################################################################
add_library(rtlsdr SHARED librtlsdr.c
tuner_e4k.c tuner_fc0012.c tuner_fc0013.c tuner_fc2580.c tuner_r82xx.c)
-target_link_libraries(rtlsdr PkgConfig::LIBUSB)
+target_link_libraries(rtlsdr ${LIBUSB_LIBRARIES} ${THREADS_PTHREADS_LIBRARY})
target_include_directories(rtlsdr PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
+ ${LIBUSB_INCLUDE_DIRS}
+ ${THREADS_PTHREADS_INCLUDE_DIR}
)
set_target_properties(rtlsdr PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
set_target_properties(rtlsdr PROPERTIES OUTPUT_NAME rtlsdr)
@@ -36,10 +38,12 @@ 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)
-target_link_libraries(rtlsdr_static PkgConfig::LIBUSB)
+target_link_libraries(rtlsdr ${LIBUSB_LIBRARIES} ${THREADS_PTHREADS_LIBRARY})
target_include_directories(rtlsdr_static PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
+ ${LIBUSB_INCLUDE_DIRS}
+ ${THREADS_PTHREADS_INCLUDE_DIR}
)
set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
if(NOT WIN32)
@@ -58,8 +62,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)
########################################################################
diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c
index 562198f..995bc1b 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