kopia lustrzana https://github.com/keenerd/rtl-sdr
build: Fix compilation on VS2013, Cygwin and MinGW.
- Link librtlsdr dynamically also on Windows.pull/12/head
rodzic
6aa5f17589
commit
5ba889896f
|
@ -22,6 +22,7 @@
|
||||||
# Project setup
|
# Project setup
|
||||||
########################################################################
|
########################################################################
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
|
||||||
project(rtlsdr C)
|
project(rtlsdr C)
|
||||||
|
|
||||||
#select the release build type by default to get optimization flags
|
#select the release build type by default to get optimization flags
|
||||||
|
|
|
@ -28,11 +28,9 @@ add_library(rtlsdr_shared SHARED
|
||||||
tuner_fc2580.c
|
tuner_fc2580.c
|
||||||
tuner_r82xx.c
|
tuner_r82xx.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(rtlsdr_shared
|
target_link_libraries(rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(rtlsdr_shared PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
|
set_target_properties(rtlsdr_shared PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
|
||||||
set_target_properties(rtlsdr_shared PROPERTIES OUTPUT_NAME rtlsdr)
|
set_target_properties(rtlsdr_shared PROPERTIES OUTPUT_NAME rtlsdr)
|
||||||
set_target_properties(rtlsdr_shared PROPERTIES SOVERSION ${MAJOR_VERSION})
|
set_target_properties(rtlsdr_shared PROPERTIES SOVERSION ${MAJOR_VERSION})
|
||||||
|
@ -46,25 +44,17 @@ add_library(rtlsdr_static STATIC
|
||||||
tuner_fc2580.c
|
tuner_fc2580.c
|
||||||
tuner_r82xx.c
|
tuner_r82xx.c
|
||||||
)
|
)
|
||||||
|
target_link_libraries(rtlsdr_static
|
||||||
|
${LIBUSB_LIBRARIES}
|
||||||
|
)
|
||||||
|
set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
|
|
||||||
add_library(convenience_static STATIC
|
add_library(convenience_static STATIC
|
||||||
convenience/convenience.c
|
convenience/convenience.c
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
add_library(libgetopt_static STATIC
|
|
||||||
getopt/getopt.c
|
|
||||||
)
|
|
||||||
target_link_libraries(convenience_static
|
target_link_libraries(convenience_static
|
||||||
rtlsdr_shared
|
rtlsdr_shared
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(rtlsdr_static
|
|
||||||
${LIBUSB_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
# Force same library filename for static and shared variants of the library
|
# Force same library filename for static and shared variants of the library
|
||||||
|
@ -83,31 +73,31 @@ add_executable(rtl_adsb rtl_adsb.c)
|
||||||
add_executable(rtl_power rtl_power.c)
|
add_executable(rtl_power rtl_power.c)
|
||||||
set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power)
|
set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power)
|
||||||
|
|
||||||
target_link_libraries(rtl_sdr rtlsdr_shared convenience_static
|
target_link_libraries(rtl_sdr convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
target_link_libraries(rtl_tcp rtlsdr_shared convenience_static
|
target_link_libraries(rtl_tcp convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
target_link_libraries(rtl_test rtlsdr_shared convenience_static
|
target_link_libraries(rtl_test convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
target_link_libraries(rtl_fm rtlsdr_shared convenience_static
|
target_link_libraries(rtl_fm convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
target_link_libraries(rtl_eeprom rtlsdr_shared convenience_static
|
target_link_libraries(rtl_eeprom convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
target_link_libraries(rtl_adsb rtlsdr_shared convenience_static
|
target_link_libraries(rtl_adsb convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
target_link_libraries(rtl_power rtlsdr_shared convenience_static
|
target_link_libraries(rtl_power convenience_static rtlsdr_shared
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
|
@ -124,6 +114,9 @@ endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
add_library(libgetopt_static STATIC
|
||||||
|
getopt/getopt.c
|
||||||
|
)
|
||||||
target_link_libraries(rtl_sdr libgetopt_static)
|
target_link_libraries(rtl_sdr libgetopt_static)
|
||||||
target_link_libraries(rtl_tcp ws2_32 libgetopt_static)
|
target_link_libraries(rtl_tcp ws2_32 libgetopt_static)
|
||||||
target_link_libraries(rtl_test libgetopt_static)
|
target_link_libraries(rtl_test libgetopt_static)
|
||||||
|
@ -131,13 +124,6 @@ target_link_libraries(rtl_fm libgetopt_static)
|
||||||
target_link_libraries(rtl_eeprom libgetopt_static)
|
target_link_libraries(rtl_eeprom libgetopt_static)
|
||||||
target_link_libraries(rtl_adsb libgetopt_static)
|
target_link_libraries(rtl_adsb libgetopt_static)
|
||||||
target_link_libraries(rtl_power libgetopt_static)
|
target_link_libraries(rtl_power libgetopt_static)
|
||||||
set_property(TARGET rtl_sdr APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
set_property(TARGET rtl_tcp APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
set_property(TARGET rtl_test APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
set_property(TARGET rtl_fm APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
set_property(TARGET rtl_eeprom APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
set_property(TARGET rtl_adsb APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
set_property(TARGET rtl_power APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|
||||||
endif()
|
endif()
|
||||||
########################################################################
|
########################################################################
|
||||||
# Install built library files & utilities
|
# Install built library files & utilities
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
#include "rtl-sdr.h"
|
#include "rtl-sdr.h"
|
||||||
#include "convenience/convenience.h"
|
#include "convenience/convenience.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||||
#define sleep Sleep
|
|
||||||
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
|
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include "getopt/getopt.h"
|
#include "getopt/getopt.h"
|
||||||
#define usleep(x) Sleep(x/1000)
|
#define usleep(x) Sleep(x/1000)
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||||
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
|
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
|
||||||
#endif
|
#endif
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
|
@ -322,7 +322,7 @@ int cic_9_tables[][10] = {
|
||||||
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
|
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||||
double log2(double n)
|
double log2(double n)
|
||||||
{
|
{
|
||||||
return log(n) / log(2.0);
|
return log(n) / log(2.0);
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include "getopt/getopt.h"
|
#include "getopt/getopt.h"
|
||||||
#define usleep(x) Sleep(x/1000)
|
#define usleep(x) Sleep(x/1000)
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||||
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
|
#define round(x) (x > 0.0 ? floor(x + 0.5): ceil(x - 0.5))
|
||||||
#endif
|
#endif
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
|
@ -260,7 +260,7 @@ int cic_9_tables[][10] = {
|
||||||
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
|
{9, -199, -362, 5303, -25505, 77489, -25505, 5303, -362, -199},
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||||
double log2(double n)
|
double log2(double n)
|
||||||
{
|
{
|
||||||
return log(n) / log(2.0);
|
return log(n) / log(2.0);
|
||||||
|
|
|
@ -110,11 +110,7 @@ int gettimeofday(struct timeval *tv, void* ignored)
|
||||||
tmp <<= 32;
|
tmp <<= 32;
|
||||||
tmp |= ft.dwLowDateTime;
|
tmp |= ft.dwLowDateTime;
|
||||||
tmp /= 10;
|
tmp /= 10;
|
||||||
#ifdef _MSC_VER
|
|
||||||
tmp -= 11644473600000000Ui64;
|
|
||||||
#else
|
|
||||||
tmp -= 11644473600000000ULL;
|
tmp -= 11644473600000000ULL;
|
||||||
#endif
|
|
||||||
tv->tv_sec = (long)(tmp / 1000000UL);
|
tv->tv_sec = (long)(tmp / 1000000UL);
|
||||||
tv->tv_usec = (long)(tmp % 1000000UL);
|
tv->tv_usec = (long)(tmp % 1000000UL);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue