Skip to content

Commit

Permalink
Merge pull request #74 from TwinFan/master
Browse files Browse the repository at this point in the history
Update Next from Master
  • Loading branch information
TwinFan authored Aug 31, 2024
2 parents 2c1377a + 4f6bca1 commit 38579cb
Showing 1 changed file with 53 additions and 56 deletions.
109 changes: 53 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,41 @@ project(XPMP2
VERSION 3.4.0
DESCRIPTION "Multiplayer library for X-Plane 11 and 12")

# Source list
add_library(XPMP2 STATIC
inc/XPCAircraft.h
inc/XPMPAircraft.h
inc/XPMPMultiplayer.h
inc/XPMPRemote.h
inc/XPMPPlaneRenderer.h
src/2D.h
src/2D.cpp
src/AIMultiplayer.h
src/AIMultiplayer.cpp
src/Aircraft.h
src/Aircraft.cpp
src/Contrail.cpp
src/CSLCopy.cpp
src/CSLModels.h
src/CSLModels.cpp
src/Map.h
src/Map.cpp
src/Network.h
src/Network.cpp
src/RelatedDoc8643.h
src/RelatedDoc8643.cpp
src/Remote.h
src/Remote.cpp
src/Sound.h
src/Sound.cpp
src/Utilities.h
src/Utilities.cpp
src/XPMP2.h
src/XPMPMultiplayer.cpp
)

# Provide compile macros from the above project version definition
add_compile_definitions(
target_compile_definitions(XPMP2 PRIVATE
XPMP2_VERSION="${PROJECT_VERSION}"
XPMP2_VER_MAJOR=${PROJECT_VERSION_MAJOR}
XPMP2_VER_MINOR=${PROJECT_VERSION_MINOR}
Expand All @@ -61,72 +94,69 @@ endif()

# Windows: Target Windows 7.0 and later
if (WIN32)
add_compile_definitions(_WIN32_WINNT=0x0601)
target_compile_definitions(XPMP2 PRIVATE _WIN32_WINNT=0x0601)
if (NOT DEFINED ENV{platform})
set(ENV{platform} "win")
endif()
elseif(APPLE)
# MacOS 10.15 is minimum system requirement for X-Plane 12
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
add_compile_options(-mmacosx-version-min=10.15)
add_link_options(-mmacosx-version-min=10.15)
target_compile_options(XPMP2 PRIVATE -mmacosx-version-min=10.15)
target_link_options(XPMP2 PRIVATE -mmacosx-version-min=10.15)
endif()

################################################################################
# C++ Standard required
################################################################################

set(CMAKE_CXX_STANDARD 17)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED 17)
set_property(GLOBAL PROPERTY CXX_STANDARD 17)
set_property(TARGET XPMP2 PROPERTY CXX_STANDARD 17)

################################################################################
# Compile Options
################################################################################

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

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

# Enable stricter warnings and then disable some we are not interested in.
# For XPMP2 compile, we don't need to be warned about our self-defined depreciations
if (MSVC)
add_compile_options(/wd4996 /wd4068)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
target_compile_options(XPMP2 PRIVATE /wd4996 /wd4068)
target_compile_definitions(XPMP2 PRIVATE _CRT_SECURE_NO_WARNINGS)
else()
add_compile_options(-Wall -Wshadow -Wextra -Wno-deprecated-declarations)
target_compile_options(XPMP2 PRIVATE -Wall -Wshadow -Wextra -Wno-deprecated-declarations)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0 AND NOT APPLE)
add_compile_options(-Wno-stringop-truncation)
target_compile_options(XPMP2 PRIVATE -Wno-stringop-truncation)
endif()

# 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)
target_compile_options(XPMP2 PRIVATE -fexceptions)

# Makes symbols non-exported by default.
add_compile_options(-fvisibility=hidden)
target_compile_options(XPMP2 PRIVATE -fvisibility=hidden)
endif()


# Debug vs Release build
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_definitions(DEBUG=1)
target_compile_definitions(XPMP2 PRIVATE DEBUG=1)
if (MSVC)
add_compile_options(/Zi)
target_compile_options(XPMP2 PRIVATE /Zi)
else()
add_compile_options(-O0 -g -fPIC)
target_compile_options(XPMP2 PRIVATE -O0 -g -fPIC)
endif()
else()
add_compile_definitions(NDEBUG=1)
target_compile_definitions(XPMP2 PRIVATE NDEBUG=1)
if(MSVC)
# Fast code, symbols into separate .pdb file, no global optimization (as it produces huge files)
add_compile_options(/Zi /O2 /GL-)
target_compile_options(XPMP2 PRIVATE /Zi /O2 /GL-)
else()
# Use position-independent code and highest optimization level
add_compile_options(-O3 -fPIC)
target_compile_options(XPMP2 PRIVATE -O3 -fPIC)
endif()
endif()

Expand All @@ -140,39 +170,6 @@ endif()
# XPMP2 Library
################################################################################

# Source list
add_library(XPMP2 STATIC
inc/XPCAircraft.h
inc/XPMPAircraft.h
inc/XPMPMultiplayer.h
inc/XPMPRemote.h
inc/XPMPPlaneRenderer.h
src/2D.h
src/2D.cpp
src/AIMultiplayer.h
src/AIMultiplayer.cpp
src/Aircraft.h
src/Aircraft.cpp
src/Contrail.cpp
src/CSLCopy.cpp
src/CSLModels.h
src/CSLModels.cpp
src/Map.h
src/Map.cpp
src/Network.h
src/Network.cpp
src/RelatedDoc8643.h
src/RelatedDoc8643.cpp
src/Remote.h
src/Remote.cpp
src/Sound.h
src/Sound.cpp
src/Utilities.h
src/Utilities.cpp
src/XPMP2.h
src/XPMPMultiplayer.cpp
)

# Define pre-compiled header
target_precompile_headers(XPMP2 PRIVATE src/XPMP2.h)

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

0 comments on commit 38579cb

Please sign in to comment.