Skip to content

Commit dba5f74

Browse files
authored
Merge pull request #213 from TwinFan/Next
v2.50
2 parents 43a3d4c + 4ce70a6 commit dba5f74

File tree

87 files changed

+2118
-39378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2118
-39378
lines changed

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
.DS_Store
22
.localized
3-
.image
3+
.image*
44
.vs/
55
.vscode/
66

77
# Build directories
8-
build/
9-
build-lin/
10-
build-win/
11-
build-mac/
8+
build*/
129

1310
# Generated documentation
1411
docs/html/

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cmake.configureOnOpen": false
3+
}

CMakeLists.txt

Lines changed: 121 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,97 @@
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
42

53
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")
77

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+
################################################################################
1211

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()
2322

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)
2637

2738
# 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()
2950

30-
if (UNIX OR APPLE)
3151
# Force-enable exception support. This is most likely redundant, although for C
3252
# code the default is the opposite. Since we are mixing C++ and C libraries,
3353
# safer to set it on?
34-
add_compile_options(-fexceptions -fpermissive)
54+
add_compile_options(-fexceptions)
3555

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.
3857
add_compile_options(-fvisibility=hidden)
58+
endif()
3959

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)
4360

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()
4982
endif()
5083

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+
5195
################################################################################
5296
# Source groups
5397
################################################################################
@@ -87,9 +131,9 @@ set(Header_Files
87131
Lib/ImgWindow/SystemGL.h
88132
Lib/Font/IconsFontAwesome5.h
89133
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
93137
)
94138
source_group("Header Files" FILES ${Header_Files})
95139

@@ -164,45 +208,37 @@ PROPERTIES
164208

165209
# Specify library search locations.
166210
if (APPLE)
167-
list(APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/CURL")
168211
list(APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/XPMP2")
169212
list(APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/SDK/Libraries/Mac")
170213
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}")
172215
elseif (WIN32)
173216
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}")
175218
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/SDK/Libraries/Win")
176219
endif ()
177220

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}")
186224
target_link_libraries(LiveTraffic ${XPMP2_LIBRARY})
187225

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}")
189230
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} )
197235
target_link_libraries( LiveTraffic ${CURL_LIBRARIES} )
198236

199237
# Link OpenGL and OpenAL related libraries.
200238
set (OpenGL_GL_PREFERENCE GLVND)
201239
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} )
206242

207243
# Link X-Plane plugin system libraries. They are only provided for OS X and Windows.
208244
if (WIN32 OR APPLE)
@@ -211,58 +247,43 @@ if (WIN32 OR APPLE)
211247
endif ()
212248

213249

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)
229264
target_link_libraries(LiveTraffic
230-
${APPLICATION_SERVICES}
231265
${CORE_FOUNDATION_LIBRARY}
232-
${SECURITY_LIBRARY}
266+
${Cocoa_LIBRARY}
267+
${Security_LIBRARY}
233268
${GSS_LIBRARY}
234-
${Kerberos5_LIBRARY}
235269
${OpenGL_LIBRARY}
236-
${Cocoa_LIBRARY}
237270
)
238-
endif ()
239271

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:
252273
target_link_libraries(LiveTraffic "-exported_symbols_list ${CMAKE_SOURCE_DIR}/Src/LiveTraffic.sym_mac")
253274
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:
257284
target_link_libraries(LiveTraffic -Wl,--version-script -Wl,${CMAKE_SOURCE_DIR}/Src/LiveTraffic.sym)
258285
endif ()
259286

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-
266287
# Target directory and file name
267288
if (WIN32)
268289
set_target_properties(LiveTraffic PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/win_x64")

0 commit comments

Comments
 (0)