-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
148 lines (123 loc) · 5.08 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
cmake_minimum_required(VERSION 3.10)
# Define Test Variants
set(CMAKE_C_FLAGS_TESTDEBUG "-Wall -Werror -g -DDXWIFI_TESTS")
set(CMAKE_C_FLAGS_TESTREL "-Wall -Werror -O3 -DNDEBUG -DDXWIFI_TESTS")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Cross-Compilation support, only supports armhf at the moment
if(PLATFORM STREQUAL "armhf")
if(NOT LINUX_ARM_ENV_ROOT)
set(LINUX_ARM_ENV_ROOT /mnt/data/armhf)
endif()
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
set(CMAKE_TOOLCHAIN_FILE platform/arm-linux-gnueabihf-gcc.cmake)
endif()
# Project directive will detect toolchain if we did not specify a platform
project(dxwifi)
# Determine Build configuration
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING
"Build options are: Debug, Release, RelWithDebInfo, MinSizeRel, TestDebug, TestRel"
FORCE)
endif()
# Versioning
set(DXWIFI_VERSION_MAJOR "0")
set(DXWIFI_VERSION_MINOR "1")
set(DXWIFI_VERSION_PATCH "0")
set(DXWIFI_VERSION_REVISION "0")
string(CONCAT CPACK_PACKAGE_VERSION
"${DXWIFI_VERSION_MAJOR}."
"${DXWIFI_VERSION_MINOR}."
"${DXWIFI_VERSION_PATCH}-"
"${DXWIFI_VERSION_REVISION}"
)
string(CONCAT DXWIFI_VERSION
"${CPACK_PACKAGE_VERSION}-"
"${CMAKE_BUILD_TYPE}"
)
add_compile_definitions(DXWIFI_VERSION="${DXWIFI_VERSION}")
# User Options
option(OPENFEC_DEBUG_MODE "Build OpenFEC in Debug mode" OFF)
option(LIBDXWIFI_DISABLE_ASSERTS "Disable Assert Functions" OFF)
option(LIBDXWIFI_DISABLE_LOGGING "Disable Logging" OFF)
option(INSTALL_SYSLOG_CONFIG "Include configuration files for rsyslog and logrotate" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(LIBDXWIFI_DISABLE_ASSERTS)
add_compile_definitions(LIBDXWIFI_DISABLE_ASSERTS)
endif()
if(LIBDXWIFI_DISABLE_LOGGING)
add_compile_definitions(LIBDXWIFI_DISABLE_LOGGING)
endif()
# Include and output directories
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/openfec/src/lib_common
${PROJECT_SOURCE_DIR}/openfec/src/lib_stable
)
set(DXWIFI_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
set(DXWIFI_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE})
set(DXWIFI_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE})
# Deal with dependencies
find_library(LIB_PCAP pcap)
if(NOT LIB_PCAP)
message(FATAL_ERROR "pcap not found. Please install libpcap-dev")
endif()
find_library(LIB_GPIOD gpiod)
if(NOT LIB_GPIOD)
message(FATAL_ERROR "gpiod not found. Please install libgpiod-dev")
endif()
# Global CPack configuration
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "oresat-dxwifi")
set(CPACK_PACKAGE_CONTACT "PSAS <[email protected]>")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Oresat Live DxWiFi")
set(CPACK_DEBIAN_PACKAGE_SECTION "net")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libpcap-dev (>= 1.8.1-6), iw")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/oresat/oresat-dxwifi-software")
# Determine architecture
if(PLATFORM STREQUAL "armhf")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
else() # Else use host architecture
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
if ("${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" STREQUAL "")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
endif()
endif()
# RX component CPack config
set(CPACK_DEBIAN_RX_PACKAGE_CONTROL_EXTRA
"${CMAKE_SOURCE_DIR}/config/debian/rx/postinst"
"${CMAKE_SOURCE_DIR}/config/debian/rx/postrm"
"${CMAKE_SOURCE_DIR}/config/debian/rx/prerm"
)
set(CPACK_DEBIAN_RX_FILE_NAME "${CPACK_PACKAGE_NAME}-rx_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
# TX component CPack config
set(CPACK_DEBIAN_TX_PACKAGE_CONTROL_EXTRA
"${CMAKE_SOURCE_DIR}/config/debian/tx/postinst"
"${CMAKE_SOURCE_DIR}/config/debian/tx/postrm"
"${CMAKE_SOURCE_DIR}/config/debian/tx/prerm"
)
set(CPACK_DEBIAN_TX_FILE_NAME "${CPACK_PACKAGE_NAME}-tx_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
# Encode component CPack config
set(CPACK_DEBIAN_ENCODE_PACKAGE_CONTROL_EXTRA
"${CMAKE_SOURCE_DIR}/config/debian/encode/postinst"
"${CMAKE_SOURCE_DIR}/config/debian/encode/postrm"
"${CMAKE_SOURCE_DIR}/config/debian/encode/prerm"
)
set(CPACK_DEBIAN_ENCODE_FILE_NAME "${CPACK_PACKAGE_NAME}-encode_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
# Encode component CPack config
set(CPACK_DEBIAN_DECODE_PACKAGE_CONTROL_EXTRA
"${CMAKE_SOURCE_DIR}/config/debian/decode/postinst"
"${CMAKE_SOURCE_DIR}/config/debian/decode/postrm"
"${CMAKE_SOURCE_DIR}/config/debian/decode/prerm"
)
set(CPACK_DEBIAN_DECODE_FILE_NAME "${CPACK_PACKAGE_NAME}-decode_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
include(CPack)
# Sub targets
add_subdirectory(rscode)
add_subdirectory(openfec)
add_subdirectory(libdxwifi)
add_subdirectory(dxwifi/tx)
add_subdirectory(dxwifi/rx)
add_subdirectory(dxwifi/encode)
add_subdirectory(dxwifi/decode)