-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
128 lines (97 loc) · 3.88 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
cmake_minimum_required(VERSION 3.7)
include(CMakeDependentOption)
project(TSL-SDR VERSION 1.0.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -gdwarf-4 -rdynamic")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
# Installation path information
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
# Add our default set of gcc warnings
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wno-trigraphs")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format-security")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-delete-null-pointer-checks -Wuninitialized -Wmissing-include-dirs -Wshadow")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wframe-larger-than=2047")
set(TSL_SDR_BASE_DIR "${PROJECT_SOURCE_DIR}")
add_definitions(-D_ATS_IN_TREE -D_GNU_SOURCE)
add_definitions(-DSYS_CACHE_LINE_LENGTH=64)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
# Enable POCSAG debugging
option(DEBUG_POCSAG "Enable POCSAG State Machine Debugging" OFF)
# Enable DIAG statements
cmake_dependent_option(DEBUG_TSL "Enable verbose TSL debugging" ON
"DEBUG_POCSAG" OFF)
# Grab the revision from git
execute_process(COMMAND git describe --abbrev=16 --dirty --always --tags
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
if ("${GIT_REV}" STREQUAL "")
set(GIT_REV "NotInGit")
else()
string(STRIP "${GIT_REV}" GIT_REV)
endif()
add_definitions(-D_VC_VERSION="${GIT_REV}")
# Enable POCSAG debugging if requested
if (DEBUG_POCSAG)
add_definitions(-D_PAGER_POCSAG_DEBUG)
endif (DEBUG_POCSAG)
if (DEBUG_TSL)
add_definitions(-D_TSL_DEBUG)
endif (DEBUG_TSL)
# Grab the CPU model we're building on (no cross-compiling support)
execute_process(COMMAND uname -m
OUTPUT_VARIABLE CPU_ARCH
ERROR_QUIET)
string(STRIP "${CPU_ARCH}" CPU_ARCH)
message(STATUS "CPU Archiecture is ${CPU_ARCH}")
if("${CPU_ARCH}" STREQUAL "armv7l")
message(STATUS "Enabling NEON, setting CPU Architecture to armv7-a")
add_definitions(-D_USE_ARM_NEON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard")
elseif("${CPU_ARCH}" STREQUAL "aarch64")
message(STATUS "Enabling NEON, setting CPU architecture to armv8-a")
add_definitions(-D_USE_ARM_NEON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a -mtune=native")
else()
message(STATUS "Using conservative defaults for CPU architecture")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mtune=native")
endif()
# We use pkg-config to find our required libraries
find_package(PkgConfig REQUIRED)
# Find the TSL
pkg_check_modules(TSL REQUIRED tsl)
# Find RTL-SDR
pkg_check_modules(RTLSDR librtlsdr)
# Find DespAirspy
pkg_check_modules(DESPAIRSPY libdespairspy)
# Find UHD
pkg_check_modules(UHD uhd)
# Find ConcurrencyKit
pkg_check_modules(CK REQUIRED ck)
# Find Jansson
pkg_check_modules(JANSSON REQUIRED jansson)
# Build the Project
add_subdirectory(filter)
add_subdirectory(multifm)
add_subdirectory(pager)
add_subdirectory(ais)
add_subdirectory(resampler)
add_subdirectory(decoder)
# Only include RF interface modules we built as dpkg deps
set(RF_INTERFACE_DEPS )
if(RTLSDR_FOUND)
set(RF_INTERFACE_DEPS "${RF_INTERFACE_DEPS}, librtlsdr0")
endif()
if(UHD_FOUND)
set(RF_INTERFACE_DEPS "${RF_INTERFACE_DEPS}, libuhd003")
endif()
# Generate dpkg automatically
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_NAME "tsl-sdr")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_CONTACT "Phil Vachon <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "The Standard Library of SDR Functions")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libjansson4, libck0${RF_INTERFACE_DEPS}")
include(CPack)