forked from TwinFan/LiveTraffic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
240 lines (201 loc) · 8.5 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
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
# LiveTraffic build script.
#
cmake_minimum_required(VERSION 3.9)
project(LiveTraffic VERSION 1.15 DESCRIPTION "LiveTraffic X-Plane plugin")
# By default, use optimized release configuration.
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif ()
set(CMAKE_CXX_STANDARD 17)
# Set include directories used by our code and dependencies.
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Src")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Lib/xplanemp")
include_directories("${CMAKE_SOURCE_DIR}/Lib/XPSDK301/CHeaders/Widgets")
include_directories("${CMAKE_SOURCE_DIR}/Lib/XPSDK301/CHeaders/Wrappers")
include_directories("${CMAKE_SOURCE_DIR}/Lib/XPSDK301/CHeaders/XPLM")
message("CMAKE_CURRENT_SOURCE_DIR = "(${CMAKE_CURRENT_SOURCE_DIR}))
message("CMAKE_SOURCE_DIR = "(${CMAKE_SOURCE_DIR}))
# Specify library search locations.
if (WIN32)
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/XPSDK301/Libraries/Win")
elseif (APPLE)
list(APPEND CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/XPSDK301/Libraries/Mac")
elseif (UNIX)
endif ()
# message (STATUS "CMAKE_LIBRARY_PATH" = ${CMAKE_LIBRARY_PATH})
# Enable all X-Plane SDK APIs up to the newest version.
add_definitions(-DXPLM200=1 -DXPLM210=1 -DXPLM300=1 -DXPLM301=1)
# Define platform macros.
add_definitions(-DAPL=$<BOOL:${APPLE}> -DIBM=$<BOOL:${WIN32}> -DLIN=$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>)
# Force-enable exception support. This is most likely redundant, although for C
# code the default is the opposite. Since we are mixing C++ and C libraries,
# safer to set it on?
add_compile_options(-fexceptions -fpermissive)
# On UNIX systems this makes symbols non-exported by default. On Windows this
# option is simply ignored, since symbol visibility works differently there.
add_compile_options(-fvisibility=hidden)
# Enable stricter warnings and then disable some we are not interested in.
add_compile_options(-Wall -Wshadow -Wfloat-equal -Wextra)
add_compile_options(-Wno-unused)
# Always use position-independent code and highest optimization level (FPS!).
add_compile_options(-O3 -fPIC)
# X-Plane plugin
################################################################################
# Source groups
################################################################################
set(Header_Files
Include/ACInfoWnd.h
Include/Constants.h
Include/CoordCalc.h
Include/DataRefs.h
Include/LiveTraffic.h
Include/LTADSBEx.h
Include/LTAircraft.h
Include/LTChannel.h
Include/LTFlightData.h
Include/LTForeFlight.h
Include/LTOpenSky.h
Include/LTRealTraffic.h
Include/Network.h
Include/parson.h
Include/SettingsUI.h
Include/TextIO.h
Include/TFWidgets.h
Include/XPCompatibility.h
Lib/xplanemp/XPCAircraft.h
Lib/xplanemp/XPMPMultiplayer.h
Lib/xplanemp/XPMPPlaneRenderer.h
)
source_group("Header Files" FILES ${Header_Files})
set(Source_Files
Src/ACInfoWnd.cpp
Src/CoordCalc.cpp
Src/DataRefs.cpp
Src/LiveTraffic.cpp
Src/LTADSBEx.cpp
Src/LTAircraft.cpp
Src/LTChannel.cpp
Src/LTFlightData.cpp
Src/LTForeFlight.cpp
Src/LTMain.cpp
Src/LTOpenSky.cpp
Src/LTRealTraffic.cpp
Src/LTVersion.cpp
Src/Network.cpp
Src/parson.c
Src/SettingsUI.cpp
Src/TextIO.cpp
Src/TFWidgets.cpp
Src/XPCompatibility.cpp
)
source_group("Source Files" FILES ${Source_Files})
set(ALL_FILES ${Header_Files} ${Source_Files})
add_library(LiveTraffic SHARED ${ALL_FILES})
target_compile_features(LiveTraffic PUBLIC cxx_std_17)
if (APPLE)
# X-Plane supports OS X 10.10+, so this should ensure FlyWithLua can run on
# all supported versions.
target_compile_options(LiveTraffic PUBLIC -mmacosx-version-min=10.10)
target_link_libraries(LiveTraffic -mmacosx-version-min=10.10)
endif ()
# Link OpenGL and OpenAL related libraries.
find_package(OpenGL REQUIRED) # apt install freeglut3-dev
if ( OpenGL_FOUND )
include_directories( ${OpenGL_INCLUDE_DIRS} )
target_link_libraries( LiveTraffic ${OpenGL_LIBRARIES} )
endif( OpenGL_FOUND )
find_package(OpenAL REQUIRED) # apt install libopenal-dev
if ( OpenAL_FOUND )
include_directories( ${OpenAL_INCLUDE_DIRS} )
target_link_libraries( LiveTraffic ${OpenAL_LIBRARIES} )
endif( OpenAL_FOUND )
find_package(GLUT REQUIRED) # apt install freeglut3-dev
if ( GLUT_FOUND )
include_directories( ${GLUT_INCLUDE_DIRS} )
target_link_libraries( LiveTraffic ${GLUT_LIBRARIES} )
endif( GLUT_FOUND )
find_package(ZLIB REQUIRED) # sudo apt-get install zlib1g-dev
if ( ZLIB_FOUND )
include_directories( ${ZLIB_INCLUDE_DIRS} )
target_link_libraries( LiveTraffic ${ZLIB_LIBRARIES} )
endif( ZLIB_FOUND )
find_package(PNG REQUIRED) # sudo apt-get install libpng-dev
if ( PNG_FOUND )
include_directories( ${PNG_INCLUDE_DIRS} )
target_link_libraries( LiveTraffic ${PNG_LIBRARIES} )
endif( PNG_FOUND )
# ****************************************************
# This workd correctly with cmake but not with docker
find_package(CURL REQUIRED) # sudo apt-get install curl
if ( CURL_FOUND )
include_directories( ${CURL_INCLUDE_DIRS} )
target_link_libraries( LiveTraffic ${CURL_LIBRARIES} )
endif( CURL_FOUND )
# ***********************************************
# This will allows docker to build but get "undefined symbol: curl_easy_perform"
# When I try to run X-Plane
# FIND_PACKAGE(CURL)
# IF(CURL_FOUND)
# INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
# SET(requiredlibs ${requiredlibs} ${CURL_LIBRARIES} )
# ELSE(CURL_FOUND)
# MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.")
# ENDIF(CURL_FOUND)
# Link X-Plane plugin system libraries. They are only provided for OS X and Windows.
if (WIN32 OR APPLE)
# if (WIN32)
find_library(XPLM_LIBRARY NAMES XPLM XPLM_64.lib)
find_library(XPWIDGETS_LIBRARY NAMES XPWidgets XPWidgets_64.lib)
target_link_libraries(LiveTraffic ${XPLM_LIBRARY} ${XPWIDGETS_LIBRARY})
endif ()
# Link library for dynamic loading of shared objects on UNIX systems.
if (UNIX)
find_library(DL_LIBRARY dl)
target_link_libraries(LiveTraffic ${DL_LIBRARY})
endif ()
# Link OS X core system libraries.
if (APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(GLUT_LIBRARY GLUT)
find_library(OpenGL_LIBRARY OpenGL)
find_library(Cocoa_LIBRARY Cocoa)
target_link_libraries(LiveTraffic ${IOKIT_LIBRARY} ${CORE_FOUNDATION_LIBRARY} ${GLUT_LIBRARY})
target_link_libraries(LiveTraffic ${OpenGL_LIBRARY} ${Cocoa_LIBRARY})
endif ()
if (WIN32)
# Unlike OS X and Linux we build standard libraries statically since X-Plane does not provide them.
target_link_libraries(LiveTraffic -static-libgcc -static-libstdc++ opengl32)
# MSYS2 for some reason always links against winpthread, so we have to work around it by statically linking the
# entire plugin. This allows building the plugin nativaly on Windows.
target_link_libraries(LiveTraffic -static)
elseif (APPLE)
# Restrict set of symbols exported from the plugin. This reduces changes of
# conflict with other plugins, in particular ones with Lua interpreter
# embedded.
target_link_libraries(LiveTraffic "-exported_symbols_list ${CMAKE_SOURCE_DIR}/Src/LiveTraffic.sym_mac")
target_link_libraries(LiveTraffic "-framework XPLM -framework XPWidgets -ldl")
elseif (UNIX)
# Specify additional runtime search laths for dynamically-linked libraries.
# Restrict set of symbols exported from the plugin. This reduces changes of
# conflict with other plugins, in particular ones with Lua interpreter
# embedded.
message(${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Lib/xplanemp")
find_library(XPLANEMP_LIBRARY NAMES libxplanemp.a)
target_link_libraries(LiveTraffic ${XPLANEMP_LIBRARY})
target_link_libraries(LiveTraffic -Wl,--version-script -Wl,${CMAKE_SOURCE_DIR}/Src/LiveTraffic.sym)
endif ()
set_target_properties(LiveTraffic PROPERTIES PREFIX "")
if (WIN32)
set_target_properties(LiveTraffic PROPERTIES OUTPUT_NAME "win")
elseif (APPLE)
set_target_properties(LiveTraffic PROPERTIES OUTPUT_NAME "mac")
elseif (UNIX)
set_target_properties(LiveTraffic PROPERTIES OUTPUT_NAME "lin")
endif ()
set_target_properties(LiveTraffic PROPERTIES SUFFIX ".xpl")
# set_target_properties(LiveTraffic PROPERTIES PREFIX "")
# set_target_properties(LiveTraffic PROPERTIES OUTPUT_NAME "LiveTraffic")
# set_target_properties(LiveTraffic PROPERTIES SUFFIX ".xpl")