-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
133 lines (116 loc) · 3.65 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project("rtl_asio")
include(FetchContent)
FetchContent_Declare(
asio
GIT_REPOSITORY https://github.com/chriskohlhoff/asio
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
GIT_TAG origin/master)
if(NOT asio_POPULATED)
FetchContent_Populate(asio)
set(ASIO_STANDALONE
ON
CACHE BOOL "" FORCE)
set(ASIO_HEADER_ONLY
ON
CACHE BOOL "" FORCE)
endif()
FetchContent_Declare(
rtl_sdr
GIT_REPOSITORY https://gitea.osmocom.org/sdr/rtl-sdr/
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
GIT_TAG origin/master)
if(NOT rtl_sdr_POPULATED)
FetchContent_Populate(rtl_sdr)
endif()
# select the release build type by default to get optimization flags
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ##############################################################################
# Compiler specific setup
# ##############################################################################
if(CMAKE_COMPILER_IS_GNUCC AND NOT WIN32)
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-Wno-unused-parameter)
add_definitions(-Wno-unused)
add_definitions(-Wsign-compare)
# http://gcc.gnu.org/wiki/Visibility
add_definitions(-fvisibility=hidden)
elseif(MSVC14 OR MSVC14)
# pthread-w32 issue, timespec is now part of time.h
add_definitions(-D_TIMESPEC_DEFINED)
endif()
find_package(Threads)
find_package(PkgConfig)
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)
message(FATAL_ERROR "pthreads(-win32) required to compile rtl-sdr")
endif()
option(DETACH_KERNEL_DRIVER "Detach kernel driver if loaded" OFF)
if(DETACH_KERNEL_DRIVER)
message(STATUS "Building with kernel driver detaching enabled")
add_definitions(-DDETACH_KERNEL_DRIVER=1)
else(DETACH_KERNEL_DRIVER)
message(
STATUS
"Building with kernel driver detaching disabled, use -DDETACH_KERNEL_DRIVER=ON to enable"
)
endif(DETACH_KERNEL_DRIVER)
option(ENABLE_ZEROCOPY "Enable usbfs zero-copy support" OFF)
if(ENABLE_ZEROCOPY)
message(STATUS "Building with usbfs zero-copy support enabled")
add_definitions(-DENABLE_ZEROCOPY=1)
else(ENABLE_ZEROCOPY)
message(
STATUS
"Building with usbfs zero-copy support disabled, use -DENABLE_ZEROCOPY=ON to enable"
)
endif(ENABLE_ZEROCOPY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
add_executable(
rtl_asio
rtl_asio.cpp
${rtl_sdr_SOURCE_DIR}/src/librtlsdr.c
${rtl_sdr_SOURCE_DIR}/src/tuner_e4k.c
${rtl_sdr_SOURCE_DIR}/src/tuner_fc0012.c
${rtl_sdr_SOURCE_DIR}/src/tuner_fc0013.c
${rtl_sdr_SOURCE_DIR}/src/tuner_fc2580.c
${rtl_sdr_SOURCE_DIR}/src/tuner_r82xx.c)
target_link_libraries(rtl_asio ${LIBUSB_LIBRARIES} ${THREADS_PTHREADS_LIBRARY})
include_directories(
${asio_SOURCE_DIR}/asio/include ${rtl_sdr_SOURCE_DIR}/include
${LIBUSB_INCLUDE_DIRS} ${THREADS_PTHREADS_INCLUDE_DIR})