Skip to content

Commit 38579cb

Browse files
authored
Merge pull request #74 from TwinFan/master
Update Next from Master
2 parents 2c1377a + 4f6bca1 commit 38579cb

File tree

1 file changed

+53
-56
lines changed

1 file changed

+53
-56
lines changed

CMakeLists.txt

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,41 @@ project(XPMP2
3535
VERSION 3.4.0
3636
DESCRIPTION "Multiplayer library for X-Plane 11 and 12")
3737

38+
# Source list
39+
add_library(XPMP2 STATIC
40+
inc/XPCAircraft.h
41+
inc/XPMPAircraft.h
42+
inc/XPMPMultiplayer.h
43+
inc/XPMPRemote.h
44+
inc/XPMPPlaneRenderer.h
45+
src/2D.h
46+
src/2D.cpp
47+
src/AIMultiplayer.h
48+
src/AIMultiplayer.cpp
49+
src/Aircraft.h
50+
src/Aircraft.cpp
51+
src/Contrail.cpp
52+
src/CSLCopy.cpp
53+
src/CSLModels.h
54+
src/CSLModels.cpp
55+
src/Map.h
56+
src/Map.cpp
57+
src/Network.h
58+
src/Network.cpp
59+
src/RelatedDoc8643.h
60+
src/RelatedDoc8643.cpp
61+
src/Remote.h
62+
src/Remote.cpp
63+
src/Sound.h
64+
src/Sound.cpp
65+
src/Utilities.h
66+
src/Utilities.cpp
67+
src/XPMP2.h
68+
src/XPMPMultiplayer.cpp
69+
)
70+
3871
# Provide compile macros from the above project version definition
39-
add_compile_definitions(
72+
target_compile_definitions(XPMP2 PRIVATE
4073
XPMP2_VERSION="${PROJECT_VERSION}"
4174
XPMP2_VER_MAJOR=${PROJECT_VERSION_MAJOR}
4275
XPMP2_VER_MINOR=${PROJECT_VERSION_MINOR}
@@ -61,72 +94,69 @@ endif()
6194

6295
# Windows: Target Windows 7.0 and later
6396
if (WIN32)
64-
add_compile_definitions(_WIN32_WINNT=0x0601)
97+
target_compile_definitions(XPMP2 PRIVATE _WIN32_WINNT=0x0601)
6598
if (NOT DEFINED ENV{platform})
6699
set(ENV{platform} "win")
67100
endif()
68101
elseif(APPLE)
69102
# MacOS 10.15 is minimum system requirement for X-Plane 12
70103
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
71-
add_compile_options(-mmacosx-version-min=10.15)
72-
add_link_options(-mmacosx-version-min=10.15)
104+
target_compile_options(XPMP2 PRIVATE -mmacosx-version-min=10.15)
105+
target_link_options(XPMP2 PRIVATE -mmacosx-version-min=10.15)
73106
endif()
74107

75108
################################################################################
76109
# C++ Standard required
77110
################################################################################
78111

79-
set(CMAKE_CXX_STANDARD 17)
80-
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED 17)
81-
set_property(GLOBAL PROPERTY CXX_STANDARD 17)
112+
set_property(TARGET XPMP2 PROPERTY CXX_STANDARD 17)
82113

83114
################################################################################
84115
# Compile Options
85116
################################################################################
86117

87118
# Enable all X-Plane SDK APIs up to the newest version.
88-
add_compile_definitions(XPLM200=1 XPLM210=1 XPLM300=1 XPLM301=1 XPLM303=1 XPLM400=1)
119+
target_compile_definitions(XPMP2 PUBLIC XPLM200=1 XPLM210=1 XPLM300=1 XPLM301=1 XPLM303=1 XPLM400=1)
89120

90121
# Define platform macros.
91-
add_compile_definitions(APL=$<BOOL:${APPLE}> IBM=$<BOOL:${WIN32}> LIN=$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>)
122+
target_compile_definitions(XPMP2 PUBLIC APL=$<BOOL:${APPLE}> IBM=$<BOOL:${WIN32}> LIN=$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>)
92123

93124
# Enable stricter warnings and then disable some we are not interested in.
94125
# For XPMP2 compile, we don't need to be warned about our self-defined depreciations
95126
if (MSVC)
96-
add_compile_options(/wd4996 /wd4068)
97-
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
127+
target_compile_options(XPMP2 PRIVATE /wd4996 /wd4068)
128+
target_compile_definitions(XPMP2 PRIVATE _CRT_SECURE_NO_WARNINGS)
98129
else()
99-
add_compile_options(-Wall -Wshadow -Wextra -Wno-deprecated-declarations)
130+
target_compile_options(XPMP2 PRIVATE -Wall -Wshadow -Wextra -Wno-deprecated-declarations)
100131
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0 AND NOT APPLE)
101-
add_compile_options(-Wno-stringop-truncation)
132+
target_compile_options(XPMP2 PRIVATE -Wno-stringop-truncation)
102133
endif()
103134

104135
# Force-enable exception support. This is most likely redundant, although for C
105136
# code the default is the opposite. Since we are mixing C++ and C libraries,
106137
# safer to set it on?
107-
add_compile_options(-fexceptions)
138+
target_compile_options(XPMP2 PRIVATE -fexceptions)
108139

109140
# Makes symbols non-exported by default.
110-
add_compile_options(-fvisibility=hidden)
141+
target_compile_options(XPMP2 PRIVATE -fvisibility=hidden)
111142
endif()
112143

113-
114144
# Debug vs Release build
115145
if(CMAKE_BUILD_TYPE MATCHES "Debug")
116-
add_compile_definitions(DEBUG=1)
146+
target_compile_definitions(XPMP2 PRIVATE DEBUG=1)
117147
if (MSVC)
118-
add_compile_options(/Zi)
148+
target_compile_options(XPMP2 PRIVATE /Zi)
119149
else()
120-
add_compile_options(-O0 -g -fPIC)
150+
target_compile_options(XPMP2 PRIVATE -O0 -g -fPIC)
121151
endif()
122152
else()
123-
add_compile_definitions(NDEBUG=1)
153+
target_compile_definitions(XPMP2 PRIVATE NDEBUG=1)
124154
if(MSVC)
125155
# Fast code, symbols into separate .pdb file, no global optimization (as it produces huge files)
126-
add_compile_options(/Zi /O2 /GL-)
156+
target_compile_options(XPMP2 PRIVATE /Zi /O2 /GL-)
127157
else()
128158
# Use position-independent code and highest optimization level
129-
add_compile_options(-O3 -fPIC)
159+
target_compile_options(XPMP2 PRIVATE -O3 -fPIC)
130160
endif()
131161
endif()
132162

@@ -140,39 +170,6 @@ endif()
140170
# XPMP2 Library
141171
################################################################################
142172

143-
# Source list
144-
add_library(XPMP2 STATIC
145-
inc/XPCAircraft.h
146-
inc/XPMPAircraft.h
147-
inc/XPMPMultiplayer.h
148-
inc/XPMPRemote.h
149-
inc/XPMPPlaneRenderer.h
150-
src/2D.h
151-
src/2D.cpp
152-
src/AIMultiplayer.h
153-
src/AIMultiplayer.cpp
154-
src/Aircraft.h
155-
src/Aircraft.cpp
156-
src/Contrail.cpp
157-
src/CSLCopy.cpp
158-
src/CSLModels.h
159-
src/CSLModels.cpp
160-
src/Map.h
161-
src/Map.cpp
162-
src/Network.h
163-
src/Network.cpp
164-
src/RelatedDoc8643.h
165-
src/RelatedDoc8643.cpp
166-
src/Remote.h
167-
src/Remote.cpp
168-
src/Sound.h
169-
src/Sound.cpp
170-
src/Utilities.h
171-
src/Utilities.cpp
172-
src/XPMP2.h
173-
src/XPMPMultiplayer.cpp
174-
)
175-
176173
# Define pre-compiled header
177174
target_precompile_headers(XPMP2 PRIVATE src/XPMP2.h)
178175

@@ -203,7 +200,7 @@ endif()
203200
# (The actual FMOD lib is not included here, that needs to be done by the plugin target)
204201
if(INCLUDE_FMOD_SOUND)
205202
# Compile options
206-
add_compile_definitions(INCLUDE_FMOD_SOUND=1)
203+
target_compile_definitions(XPMP2 PRIVATE INCLUDE_FMOD_SOUND=1)
207204
target_sources(XPMP2 PRIVATE
208205
src/SoundFMOD.h
209206
src/SoundFMOD.cpp

0 commit comments

Comments
 (0)