-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
130 lines (111 loc) · 6.09 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
cmake_minimum_required(VERSION 2.8)
project(sdr-modem)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
endif ()
add_library(sdr_modemLib
${CMAKE_CURRENT_SOURCE_DIR}/src/api_utils.c
${CMAKE_CURRENT_SOURCE_DIR}/src/api.pb-c.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp_worker.c
${CMAKE_CURRENT_SOURCE_DIR}/src/linked_list.c
${CMAKE_CURRENT_SOURCE_DIR}/src/queue.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sdr_worker.c
${CMAKE_CURRENT_SOURCE_DIR}/src/server_config.c
${CMAKE_CURRENT_SOURCE_DIR}/src/tcp_server.c
${CMAKE_CURRENT_SOURCE_DIR}/src/tcp_utils.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/clock_recovery_mm.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/dc_blocker.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/doppler.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/fir_filter.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/frequency_modulator.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/fsk_demod.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/gaussian_taps.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/gfsk_mod.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/interp_fir_filter.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/lpf.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/lpf_taps.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/mmse_fir_interpolator.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/quadrature_demod.c
${CMAKE_CURRENT_SOURCE_DIR}/src/dsp/sig_source.c
${CMAKE_CURRENT_SOURCE_DIR}/src/math/fast_atan2f.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sdr/plutosdr.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sdr/file_source.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sdr/iio_lib.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sdr/sdr_server_client.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sgpsdp/sgp4sdp4.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sgpsdp/sgp_in.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sgpsdp/sgp_math.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sgpsdp/sgp_obs.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sgpsdp/sgp_time.c
${CMAKE_CURRENT_SOURCE_DIR}/src/sgpsdp/solar.c
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PC_VOLK REQUIRED volk)
include_directories(${PC_VOLK_INCLUDE_DIRS})
link_directories(${PC_VOLK_LIBRARY_DIRS})
target_link_libraries(sdr_modemLib ${PC_VOLK_LIBRARIES})
pkg_check_modules(PC_LIBCONFIG REQUIRED libconfig)
include_directories(${PC_LIBCONFIG_INCLUDE_DIRS})
link_directories(${PC_LIBCONFIG_LIBRARY_DIRS})
target_link_libraries(sdr_modemLib ${PC_LIBCONFIG_LIBRARIES})
pkg_check_modules(PC_LIBPROTOBUFC REQUIRED libprotobuf-c)
include_directories(${PC_LIBPROTOBUFC_INCLUDE_DIRS})
link_directories(${PC_LIBPROTOBUFC_LIBRARY_DIRS})
target_link_libraries(sdr_modemLib ${PC_LIBPROTOBUFC_LIBRARIES})
if (APPLE)
find_path(LIBIIO_INCLUDE_DIRS iio.h)
include_directories(${LIBIIO_INCLUDE_DIRS})
link_directories("/Library/Frameworks/iio.framework")
else ()
pkg_check_modules(PC_LIBIIO REQUIRED libiio)
include_directories(${PC_LIBIIO_INCLUDE_DIRS})
endif ()
find_package(Threads REQUIRED)
target_link_libraries(sdr_modemLib ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(sdr_modemLib m ${CMAKE_DL_LIBS})
add_executable(sdr_modem ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c)
target_link_libraries(sdr_modem sdr_modemLib)
install(TARGETS sdr_modem DESTINATION /usr/bin/)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/config.conf DESTINATION /etc/sdr-modem/)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/sdr-modem.service DESTINATION /lib/systemd/system/)
enable_testing()
file(GLOB TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test/test_*.c)
file(GLOB TEST_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test/resources/*)
file(COPY ${TEST_RESOURCES} DESTINATION "${CMAKE_BINARY_DIR}")
file(GLOB PERF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test/perf_*.c)
file(GLOB AUX_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/api.pb-c.c)
list(FILTER AUX_TEST_SOURCES EXCLUDE REGEX "test_.*\\.c")
list(FILTER AUX_TEST_SOURCES EXCLUDE REGEX "perf_.*\\.c")
list(FILTER AUX_TEST_SOURCES EXCLUDE REGEX "mock_.*\\.c")
add_library(sdr_modemTestLib ${AUX_TEST_SOURCES})
pkg_check_modules(PC_CHECK REQUIRED check)
include_directories(${PC_CHECK_INCLUDE_DIRS})
link_directories(${PC_CHECK_LIBRARY_DIRS})
foreach (curTest ${TEST_SOURCES})
get_filename_component(curTestName ${curTest} NAME_WE)
add_test(NAME ${curTestName} COMMAND ${curTestName} ${curTest})
add_executable(${curTestName} ${curTest})
target_link_libraries(${curTestName} sdr_modemLib sdr_modemTestLib ${PC_CHECK_LIBRARIES})
endforeach ()
foreach (curPerfTest ${PERF_SOURCES})
get_filename_component(curPerfTestName ${curPerfTest} NAME_WE)
add_executable(${curPerfTestName} ${curPerfTest})
target_link_libraries(${curPerfTestName} sdr_modemLib sdr_modemTestLib ${PC_CHECK_LIBRARIES})
endforeach ()
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_custom_target("coverage")
add_custom_command(TARGET "coverage" COMMAND gcov ${CMAKE_BINARY_DIR}/CMakeFiles/sdr_modemLib.dir/src/*.c.o ${CMAKE_BINARY_DIR}/CMakeFiles/sdr_modemLib.dir/src/dsp/*.c.o ${CMAKE_BINARY_DIR}/CMakeFiles/sdr_modemLib.dir/src/math/*.c.o ${CMAKE_BINARY_DIR}/CMakeFiles/sdr_modemLib.dir/src/sdr/*.c.o ${CMAKE_BINARY_DIR}/CMakeFiles/sdr_modemLib.dir/src/sgpsdp/*.c.o)
endif ()
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_NAME "sdr-modem")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libvolk2-bin, libprotobuf-c1, libconfig9, zlib1g")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Andrey Rodionov <dernasherbrezon@gmail.com>")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Modem based on software defined radios")
set(CPACK_DEBIAN_PACKAGE_SECTION "comm")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/dernasherbrezon/sdr-modem")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm")
set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)
set(CPACK_DEBIAN_FILE_NAME "sdr-modem_${CPACK_DEBIAN_PACKAGE_VERSION}_${CUSTOM_ARCHITECTURE}.deb")
include(CPack)