1
- # LiveTraffic - Set up to be used in the provided docker environment to build lin and mac
2
- # mac does currently compile only, but fails linking.
3
- # Set up to be used in a Visual Studio environment to build win (File > Open > Folder, then VS recognized the CMAKE configuration)
1
+ # LiveTraffic - Set up to be used in the provided docker environment to build lin, mac, and win
4
2
5
3
cmake_minimum_required (VERSION 3.16 )
6
- project (LiveTraffic VERSION 2.20 DESCRIPTION "LiveTraffic X-Plane plugin" LANGUAGES C CXX )
4
+ project (LiveTraffic
5
+ VERSION 2.41
6
+ DESCRIPTION "LiveTraffic X-Plane plugin" )
7
7
8
- # By default, use optimized release configuration.
9
- if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "" )
10
- set (CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE )
11
- endif ()
8
+ ################################################################################
9
+ # Target Systems
10
+ ################################################################################
12
11
13
- # Set include directories used by our code and dependencies.
14
- include_directories ( " ${CMAKE_SOURCE_DIR} /Include" )
15
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/parson" )
16
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/XPMP2/XPMP2.framework/Versions/1.0/Headers" )
17
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/LTAPI " )
18
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/SDK/CHeaders/XPLM" )
19
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/ImGui" )
20
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/ImGui/misc/cpp" )
21
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/ImgWindow" )
22
- include_directories ( " ${CMAKE_SOURCE_DIR} /Lib/Font" )
12
+ # Windows: Target Windows 7.0 and later
13
+ if ( WIN32 )
14
+ add_compile_definitions ( _WIN32_WINNT=0x0601 )
15
+ if ( NOT DEFINED ENV{platform} )
16
+ set ( ENV{platform} "win " )
17
+ endif ( )
18
+ elseif ( APPLE )
19
+ add_compile_options ( -mmacosx-version-min=10.11 )
20
+ add_link_options ( -mmacosx-version-min=10.11 )
21
+ endif ( )
23
22
24
- # Enable all necessary X-Plane SDK APIs
25
- add_definitions (-DXPLM200=1 -DXPLM210=1 -DXPLM300=1 -DXPLM301=1 -DXPLM303=1 )
23
+ ################################################################################
24
+ # C++ Standard required
25
+ ################################################################################
26
+
27
+ set (CMAKE_CXX_STANDARD 17 )
28
+ set_property (GLOBAL PROPERTY CXX_STANDARD_REQUIRED 17 )
29
+ set_property (GLOBAL PROPERTY CXX_STANDARD 17 )
30
+
31
+ ################################################################################
32
+ # Compile Options
33
+ ################################################################################
34
+
35
+ # Enable all X-Plane SDK APIs up to the newest version.
36
+ add_compile_definitions (XPLM200=1 XPLM210=1 XPLM300=1 XPLM301=1 XPLM303=1 )
26
37
27
38
# Define platform macros.
28
- add_definitions (-DAPL=$<BOOL:${APPLE}> -DIBM=$<BOOL:${WIN32}> -DLIN=$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>> )
39
+ add_compile_definitions (APL=$<BOOL:${APPLE}> IBM=$<BOOL:${WIN32}> LIN=$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>> )
40
+
41
+ # Enable stricter warnings and then disable some we are not interested in.
42
+ if (MSVC )
43
+ # Deprecation warning: once is enough
44
+ add_compile_options (/wo4996 )
45
+ else ()
46
+ add_compile_options (-Wall -Wshadow -Wfloat-equal -Wextra )
47
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0 AND NOT APPLE )
48
+ add_compile_options (-Wno-stringop-truncation )
49
+ endif ()
29
50
30
- if (UNIX OR APPLE )
31
51
# Force-enable exception support. This is most likely redundant, although for C
32
52
# code the default is the opposite. Since we are mixing C++ and C libraries,
33
53
# safer to set it on?
34
- add_compile_options (-fexceptions -fpermissive )
54
+ add_compile_options (-fexceptions )
35
55
36
- # On UNIX systems this makes symbols non-exported by default. On Windows this
37
- # option is simply ignored, since symbol visibility works differently there.
56
+ # Makes symbols non-exported by default.
38
57
add_compile_options (-fvisibility=hidden )
58
+ endif ()
39
59
40
- # Enable stricter warnings and then disable some we are not interested in.
41
- add_compile_options (-Wall -Wshadow -Wfloat-equal -Wextra )
42
- add_compile_options (-Wno-unused )
43
60
44
- # Always use position-independent code and highest optimization level (FPS!).
45
- add_compile_options (-O3 -fPIC )
46
- elseif (WIN32 )
47
- # Deprecation warning: once is enough
48
- add_compile_options (/wo4996 )
61
+ # Debug vs Release build
62
+ if (CMAKE_BUILD_TYPE MATCHES "Debug" )
63
+ add_compile_definitions (DEBUG=1 )
64
+ if (MSVC )
65
+ add_compile_options (/Zi )
66
+ else ()
67
+ add_compile_options (-O0 -g )
68
+ endif ()
69
+ else ()
70
+ add_compile_definitions (NDEBUG=1 )
71
+ if (MSVC )
72
+ # Use highest optimization level in Release builds
73
+ add_compile_options (/GL )
74
+ elseif (APPLE )
75
+ add_compile_options (-O3 -fPIC )
76
+ elseif (UNIX OR MINGW )
77
+ # Use position-independent code and highest optimization level (FPS!).
78
+ add_compile_options (-O3 -fPIC )
79
+ # Strip symbols during linking
80
+ add_link_options (-s )
81
+ endif ()
49
82
endif ()
50
83
84
+ # Set include directories used by our code and dependencies.
85
+ include_directories ("${CMAKE_SOURCE_DIR} /Include" )
86
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/parson" )
87
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/XPMP2/XPMP2.framework/Versions/Current/Headers" )
88
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/LTAPI" )
89
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/SDK/CHeaders/XPLM" )
90
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/ImGui" )
91
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/ImGui/misc/cpp" )
92
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/ImgWindow" )
93
+ include_directories ("${CMAKE_SOURCE_DIR} /Lib/Font" )
94
+
51
95
################################################################################
52
96
# Source groups
53
97
################################################################################
@@ -87,9 +131,9 @@ set(Header_Files
87
131
Lib/ImgWindow/SystemGL.h
88
132
Lib/Font/IconsFontAwesome5.h
89
133
Lib/Font/fa-solid-900.inc
90
- Lib/XPMP2/XPMP2.framework/Versions/1.0 /Headers/XPCAircraft.h
91
- Lib/XPMP2/XPMP2.framework/Versions/1.0 /Headers/XPMPMultiplayer.h
92
- Lib/XPMP2/XPMP2.framework/Versions/1.0 /Headers/XPMPPlaneRenderer.h
134
+ Lib/XPMP2/XPMP2.framework/Versions/Current /Headers/XPCAircraft.h
135
+ Lib/XPMP2/XPMP2.framework/Versions/Current /Headers/XPMPMultiplayer.h
136
+ Lib/XPMP2/XPMP2.framework/Versions/Current /Headers/XPMPPlaneRenderer.h
93
137
)
94
138
source_group ("Header Files" FILES ${Header_Files} )
95
139
@@ -164,45 +208,37 @@ PROPERTIES
164
208
165
209
# Specify library search locations.
166
210
if (APPLE )
167
- list (APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/CURL" )
168
211
list (APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/XPMP2" )
169
212
list (APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/SDK/Libraries/Mac" )
170
213
elseif (UNIX )
171
- list (APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/XPMP2" )
214
+ list (APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/XPMP2/ $ENV{platform} " )
172
215
elseif (WIN32 )
173
216
list (APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/CURL" )
174
- list (APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/XPMP2" )
217
+ list (APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/XPMP2/ $ENV{platform} " )
175
218
list (APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR} /Lib/SDK/Libraries/Win" )
176
219
endif ()
177
220
178
- # Find the XPMP2 library
179
- if (APPLE )
180
- find_library (XPMP2_LIBRARY NAMES XPMP2 )
181
- elseif (UNIX )
182
- find_library (XPMP2_LIBRARY NAMES libXPMP2.a )
183
- elseif (WIN32 )
184
- find_library (XPMP2_LIBRARY NAMES XPMP2.lib )
185
- endif ()
221
+ # Link the XPMP2 library
222
+ find_library (XPMP2_LIBRARY XPMP2 REQUIRED )
223
+ message (" XPMP2_LIBRARY = ${XPMP2_LIBRARY} " )
186
224
target_link_libraries (LiveTraffic ${XPMP2_LIBRARY} )
187
225
188
- # CURL Library
226
+ # Link libcurl
227
+ find_package (CURL REQUIRED )
228
+ message (" CURL_INCLUDE_DIRS = ${CURL_INCLUDE_DIRS} " )
229
+ message (" CURL_LIBRARIES = ${CURL_LIBRARIES} " )
189
230
if (WIN32 )
190
- find_library (CURL_LIBRARIES NAMES libcurl.lib )
191
- include_directories ("${CMAKE_SOURCE_DIR} /Lib/CURL/libcurl.framework/Versions/Release-7.65.3/Headers" )
192
- add_definitions (-DCURL_STATICLIB )
193
- else ()
194
- find_package (CURL REQUIRED ) # sudo apt-get install curl
195
- include_directories ( ${CURL_INCLUDE_DIRS} )
196
- endif ()
231
+ # We have built a static up-to-date version of CURL just for ourselves, compile/link it statically
232
+ add_compile_definitions (CURL_STATICLIB )
233
+ endif ()
234
+ include_directories ( ${CURL_INCLUDE_DIRS} )
197
235
target_link_libraries ( LiveTraffic ${CURL_LIBRARIES} )
198
236
199
237
# Link OpenGL and OpenAL related libraries.
200
238
set (OpenGL_GL_PREFERENCE GLVND )
201
239
find_package (OpenGL REQUIRED ) # apt install freeglut3-dev
202
- if ( OpenGL_FOUND )
203
- include_directories ( ${OpenGL_INCLUDE_DIRS} )
204
- target_link_libraries ( LiveTraffic ${OpenGL_LIBRARIES} )
205
- endif ( OpenGL_FOUND )
240
+ include_directories ( ${OpenGL_INCLUDE_DIRS} )
241
+ target_link_libraries ( LiveTraffic ${OpenGL_LIBRARIES} )
206
242
207
243
# Link X-Plane plugin system libraries. They are only provided for OS X and Windows.
208
244
if (WIN32 OR APPLE )
@@ -211,58 +247,43 @@ if (WIN32 OR APPLE)
211
247
endif ()
212
248
213
249
214
- # Link library for dynamic loading of shared objects on UNIX systems.
215
- if (UNIX )
216
- find_library (DL_LIBRARY dl )
217
- target_link_libraries (LiveTraffic ${DL_LIBRARY} )
218
- endif ()
219
-
220
- # Link OS X core system libraries.
221
- if (APPLE )
222
- find_library (APPLICATION_SERVICES ApplicationServices )
223
- find_library (CORE_FOUNDATION_LIBRARY CoreFoundation )
224
- find_library (SECURITY_LIBRARY Security )
225
- find_library (GSS_LIBRARY GSS )
226
- find_library (Kerberos5_LIBRARY libgssapi_krb5.tbd )
227
- find_library (Cocoa_LIBRARY Cocoa )
228
-
250
+ if (WIN32 )
251
+ # Link platform-specific libraries especially for networking
252
+ target_link_libraries (LiveTraffic ws2_32.lib iphlpapi wldap32.lib advapi32.lib crypt32.lib )
253
+ if (MINGW )
254
+ # When cross-compiling we link the standard libraries statically
255
+ target_link_options (LiveTraffic PRIVATE -static-libgcc -static-libstdc++ )
256
+ endif ()
257
+ elseif (APPLE )
258
+ # Link OS X core system libraries.
259
+ find_library (CORE_FOUNDATION_LIBRARY CoreFoundation REQUIRED )
260
+ find_library (Cocoa_LIBRARY Cocoa REQUIRED )
261
+ find_library (Security_LIBRARY Security REQUIRED )
262
+ find_library (GSS_LIBRARY GSS REQUIRED )
263
+ find_library (OpenGL_LIBRARY OpenGL REQUIRED )
229
264
target_link_libraries (LiveTraffic
230
- ${APPLICATION_SERVICES}
231
265
${CORE_FOUNDATION_LIBRARY}
232
- ${SECURITY_LIBRARY}
266
+ ${Cocoa_LIBRARY}
267
+ ${Security_LIBRARY}
233
268
${GSS_LIBRARY}
234
- ${Kerberos5_LIBRARY}
235
269
${OpenGL_LIBRARY}
236
- ${Cocoa_LIBRARY}
237
270
)
238
- endif ()
239
271
240
- if (WIN32 )
241
- # Link platform-specific libraries especially for networking
242
- target_link_libraries (LiveTraffic ws2_32.lib iphlpapi wldap32.lib advapi32.lib crypt32.lib )
243
- elseif (APPLE )
244
- # X-Plane supports OS X 10.10+, so this should ensure FlyWithLua can run on
245
- # all supported versions.
246
- target_compile_options (LiveTraffic PUBLIC -mmacosx-version-min=10.11 )
247
- target_link_libraries (LiveTraffic -mmacosx-version-min=10.11 )
248
-
249
- # Restrict set of symbols exported from the plugin. This reduces changes of
250
- # conflict with other plugins, in particular ones with Lua interpreter
251
- # embedded.
272
+ # Restrict set of symbols exported from the plugin to the ones required by XPLM:
252
273
target_link_libraries (LiveTraffic "-exported_symbols_list ${CMAKE_SOURCE_DIR} /Src/LiveTraffic.sym_mac" )
253
274
elseif (UNIX )
254
- # Restrict set of symbols exported from the plugin. This reduces changes of
255
- # conflict with other plugins, in particular ones with Lua interpreter
256
- # embedded.
275
+ # Link library for dynamic loading of shared objects on UNIX systems.
276
+ find_library (DL_LIBRARY dl REQUIRED )
277
+ # Threads
278
+ set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
279
+ set (THREADS_PREFER_PTHREAD_FLAG TRUE )
280
+ find_package (Threads REQUIRED )
281
+ target_link_libraries (LiveTraffic ${DL_LIBRARY} Threads::Threads )
282
+ # Specify additional runtime search paths for dynamically-linked libraries.
283
+ # Restrict set of symbols exported from the plugin to the ones required by XPLM:
257
284
target_link_libraries (LiveTraffic -Wl,--version-script -Wl,${CMAKE_SOURCE_DIR}/Src/LiveTraffic.sym )
258
285
endif ()
259
286
260
- # We need C++ 17
261
- set (CMAKE_CXX_STANDARD 17 )
262
- target_compile_features (LiveTraffic PUBLIC cxx_std_17 )
263
- set_property (TARGET LiveTraffic PROPERTY CXX_STANDARD_REQUIRED 17 )
264
- set_property (TARGET LiveTraffic PROPERTY CXX_STANDARD 17 )
265
-
266
287
# Target directory and file name
267
288
if (WIN32 )
268
289
set_target_properties (LiveTraffic PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /win_x64" )
0 commit comments