-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
260 lines (228 loc) · 9.35 KB
/
Copy pathCMakeLists.txt
File metadata and controls
260 lines (228 loc) · 9.35 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
cmake_minimum_required(VERSION 3.13)
project(UniversalFlightConnector VERSION 0.0.1)
set(CMAKE_CXX_STANDARD 20)
find_package(PkgConfig REQUIRED)
pkg_check_modules(yamlcpp REQUIRED yaml-cpp)
pkg_check_modules(lua REQUIRED lua)
pkg_check_modules(nlohmann_json REQUIRED nlohmann_json)
find_library(SQLITE3_LIBRARY NAMES sqlite3 )
if(UNIX AND NOT APPLE)
pkg_check_modules(hidapi REQUIRED hidapi-libusb)
set(OS_LIBS )
elseif(UNIX AND APPLE)
pkg_check_modules(hidapi REQUIRED hidapi)
find_library(IOKIT_LIBRARY IOKit)
find_library(FOUNDATION_LIBRARY Foundation)
set(OS_LIBS ${IOKIT_LIBRARY} ${FOUNDATION_LIBRARY})
else()
message(FATAL_ERROR "Unsupported platform")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Third Party Modules
add_subdirectory(3rdparty/luacpp/Source EXCLUDE_FROM_ALL)
set(USE_EMBEDDED_CURL ON)
set(USE_SYSTEM_CURL OFF)
set(CURL_DISABLE_WEBSOCKETS OFF CACHE BOOL "" FORCE)
add_subdirectory(3rdparty/curly.hpp EXCLUDE_FROM_ALL)
set(DATADIR ${CMAKE_INSTALL_PREFIX}/share/ufc)
SET(FLAGS_COMMON "-Wall -Werror -Wno-vla-cxx-extension -Wno-unused-function -Wno-unknown-warning-option")
SET(CMAKE_CXX_FLAGS_DEBUG "${FLAGS_COMMON} -O0 -g -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
SET(CMAKE_CXX_FLAGS_RELEASE "${FLAGS_COMMON} -O3")
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/3rdparty/luacpp/Source
${CMAKE_SOURCE_DIR}/3rdparty/curly.hpp/headers
${CURL_SOURCE_DIR}/include
)
add_definitions(${yamlcpp_CFLAGS} ${hidapi_CFLAGS} ${lua_CFLAGS} ${nlohmann_json_CFLAGS} ${curl_CFLAGS})
add_library(ufc-utils SHARED
include/ufc/utils/bitbuffer.h
include/ufc/utils/data.h
include/ufc/utils/geoutils.h
include/ufc/utils/logger.h
include/ufc/utils/udp.h
include/ufc/utils/utils.h
src/libufc-utils/base64.cpp
src/libufc-utils/base64.h
src/libufc-utils/bitbuffer.cpp
src/libufc-utils/data.cpp
src/libufc-utils/database.cpp
src/libufc-utils/geoutils.cpp
src/libufc-utils/logger.cpp
src/libufc-utils/udp.cpp
src/libufc-utils/utils.cpp
)
target_compile_definitions(ufc-utils PUBLIC -DDATADIR=${DATADIR})
target_link_libraries(ufc-utils
luacpp_static
${SQLITE3_LIBRARY}
)
add_library(ufc-data SHARED
include/ufc/data/airports.h
include/ufc/data/airways.h
include/ufc/data/flightplan.h
include/ufc/data/fpformat.h
include/ufc/data/greatcircle.h
include/ufc/data/lnmnavdata.h
include/ufc/data/msfsiniformat.h
include/ufc/data/navaids.h
include/ufc/data/navdata.h
include/ufc/data/routetextformat.h
include/ufc/data/simbriefjson.h
include/ufc/data/xplanefmsformat.h
include/ufc/data/xplanenavdata.h
src/libufc-data/flightplans/fpformat.cpp
src/libufc-data/flightplans/msfsiniformat.cpp
src/libufc-data/flightplans/routetext.cpp
src/libufc-data/flightplans/simbriefjson.cpp
src/libufc-data/greatcircle.cpp
src/libufc-data/navdata/airport.cpp
src/libufc-data/navdata/littlenavmap/lnmairports.cpp
src/libufc-data/navdata/littlenavmap/lnmairways.cpp
src/libufc-data/navdata/littlenavmap/lnmnavaids.cpp
src/libufc-data/navdata/littlenavmap/lnmnavdata.cpp
src/libufc-data/navdata/littlenavmap/lnmprocedures.cpp
src/libufc-data/navdata/procedures.cpp
src/libufc-data/navdata/xplane/airports.cpp
src/libufc-data/navdata/xplane/navaids.cpp
src/libufc-data/navdata/xplane/xplanenavdata.cpp
)
target_compile_definitions(ufc-data PUBLIC -DDATADIR=${DATADIR})
target_link_libraries(ufc-data
ufc-utils
${SQLITE3_LIBRARY}
curly.hpp::curly.hpp
)
add_executable(ufc-generate-data src/ufc-generate-data/main.cpp)
target_link_libraries(ufc-generate-data
ufc-utils
${yamlcpp_LDFLAGS}
)
add_custom_command(
PRE_BUILD
OUTPUT include/ufc/aircraftdata.h include/ufc/aircraftcommands.h
COMMAND
ufc-generate-data ${CMAKE_SOURCE_DIR}/data/x-plane/defaults.yaml
${CMAKE_SOURCE_DIR}/include/ufc/aircraftdata.h
${CMAKE_SOURCE_DIR}/include/ufc/aircraftcommands.h
DEPENDS ufc-generate-data data/x-plane/defaults.yaml
)
add_library(ufc SHARED
include/ufc/aircraftdata.h
include/ufc/aircraftcommands.h
include/ufc/aircraftmapping.h
include/ufc/aircraftstate.h
include/ufc/datasource.h
include/ufc/devices/device.h
include/ufc/devices/usbhiddevice.h
include/ufc/flightconnector.h
src/libufc-connector/aircraftstate.cpp
src/libufc-connector/datasources/aircraftmapping.cpp
src/libufc-connector/datasources/clock.cpp
src/libufc-connector/datasources/clock.h
src/libufc-connector/datasources/datasource.cpp
src/libufc-connector/datasources/simulator.cpp
src/libufc-connector/datasources/simulator.h
src/libufc-connector/datasources/xplane/xplane.cpp
src/libufc-connector/datasources/xplane/xplane.h
src/libufc-connector/datasources/xplane/xplaneclient.cpp
src/libufc-connector/datasources/xplane/xplaneclient.h
src/libufc-connector/datasources/xplane/xplaneudpclient.cpp
src/libufc-connector/datasources/xplane/xplaneudpclient.h
src/libufc-connector/datasources/xplane/xplanewsclient.cpp
src/libufc-connector/datasources/xplane/xplanewsclient.h
src/libufc-connector/devices/consoleoutput.cpp
src/libufc-connector/devices/consoleoutput.h
src/libufc-connector/devices/device.cpp
src/libufc-connector/devices/serial/device.cpp
src/libufc-connector/devices/serial/lib/list_ports_linux.cpp
src/libufc-connector/devices/serial/lib/list_ports_osx.cpp
src/libufc-connector/devices/serial/lib/list_ports_win.cpp
src/libufc-connector/devices/serial/lib/serial.cpp
src/libufc-connector/devices/serial/lib/serial_unix.cpp
src/libufc-connector/devices/serial/lib/serial_win.cpp
src/libufc-connector/devices/serial/serial.h
src/libufc-connector/devices/serial/serialmanager.cpp
src/libufc-connector/devices/serial/serialport.cpp
src/libufc-connector/devices/serial/serialport.h
src/libufc-connector/devices/usbhidconfig/device.cpp
src/libufc-connector/devices/usbhidconfig/lcd.h
src/libufc-connector/devices/usbhidconfig/manager.cpp
src/libufc-connector/devices/usbhidconfig/usbhidconfig.h
src/libufc-connector/devices/usbhiddevice.cpp
src/libufc-connector/flightconnector.cpp
src/libufc-connector/lua.cpp
src/libufc-connector/lua.h
)
if(UNIX AND APPLE)
target_link_options(ufc PUBLIC -all_load)
endif()
target_compile_definitions(ufc PUBLIC -DDATADIR=${DATADIR})
target_link_libraries(ufc
ufc-utils
luacpp_static
${yamlcpp_LDFLAGS}
${hidapi_LDFLAGS}
${lua_LDFLAGS}
${OS_LIBS}
${SQLITE3_LIBRARY}
curly.hpp::curly.hpp
)
if (UNIX AND APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(ufc-utils PROPERTIES
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
)
set_target_properties(ufc-data PROPERTIES
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
)
set_target_properties(ufc PROPERTIES
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
)
endif()
install(TARGETS ufc ufc ufc-utils ufc-data DESTINATION lib)
add_executable(ufctool src/ufctool/main.cpp)
target_link_libraries(ufctool
ufc
)
if (UNIX AND APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(ufctool PROPERTIES
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
)
endif()
if(UNIX AND APPLE)
set(XPLM_LDFLAGS ${CMAKE_SOURCE_DIR}/3rdparty/XPlaneSDK/Libraries/Mac/XPLM.framework)
set(XPLM_CFLAGS -DAPL=1)
elseif (UNIX AND NOT APPLE)
set(XPLM_CFLAGS -DLIN=1)
endif()
set(XPLANE_INC ${CMAKE_SOURCE_DIR}/3rdparty/XPlaneSDK/CHeaders/XPLM)
message("XPLM_LDFLAGS: ${XPLM_LDFLAGS}")
message("XPLANE_INC: ${XPLANE_INC}")
add_library(ufc-plugin SHARED
src/ufc-plugin/ufcplugin.cpp
src/ufc-plugin/ufcplugin.h
src/ufc-plugin/xpplugindatasource.cpp
src/ufc-plugin/xpplugindatasource.h
)
target_compile_definitions(ufc-plugin PUBLIC ${XPLM_CFLAGS})
target_include_directories(ufc-plugin PUBLIC ${XPLANE_INC})
target_link_libraries(ufc-plugin
ufc
${XPLM_LDFLAGS}
)
if (UNIX AND APPLE AND CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(ufc-plugin PROPERTIES
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
)
endif()
add_subdirectory(tests EXCLUDE_FROM_ALL)
set(DATADIR ${CMAKE_INSTALL_PREFIX}/share/ufc)
install(DIRECTORY include/ufc DESTINATION include FILES_MATCHING PATTERN "*.h" )
install(DIRECTORY data/x-plane DESTINATION ${DATADIR})
install(DIRECTORY data/usbhid DESTINATION ${DATADIR})
set(PKGCONFIG_CFLAGS_LIST -I${CMAKE_INSTALL_PREFIX}/include ${yamlcpp_CFLAGS} ${hidapi_CFLAGS})
string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS_LIST}")
set(PKGCONFIG_LDFLAGS_LIST -L${CMAKE_INSTALL_PREFIX}/lib -lufc-utils -lufc ${yamlcpp_LDFLAGS} ${hidapi_LDFLAGS})
string(REPLACE ";" " " PKGCONFIG_LDFLAGS "${PKGCONFIG_LDFLAGS_LIST}")
configure_file(libufc.pc.in libufc.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/libufc.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig")