forked from TheAssemblyArmada/Thyme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (113 loc) · 5.04 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
cmake_minimum_required(VERSION 3.1.0)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to Debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(MSVC)
set(MSVC_INCREMENTAL_DEFAULT ON)
endif()
project(thyme VERSION 1.04.0 LANGUAGES C CXX)
if(MSVC)
string(REPLACE "INCREMENTAL" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DYNAMICBASE:NO /NXCOMPAT:NO /INCREMENTAL:NO ${replacementFlags}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "/DYNAMICBASE:NO /NXCOMPAT:NO /INCREMENTAL:NO ${replacementFlags}")
string(REPLACE "INCREMENTAL" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO ${replacementFlags}")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO ${replacementFlags}")
# Disable Run Time Checking.
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
#message("Processing flags ${flag_var}")
string(REGEX REPLACE "/RTC[^ ]*" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
# Set warning level 3
# disable C4244: conversion from 'double' to 'float', possible loss of data
# disable C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4244 /wd4800")
endif()
set(CMAKE_CXX_STANDARD 14)
# We don't support in tree builds, so help people make the right choice.
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
endif()
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
set(DEFAULT_STANDALONE OFF)
else()
set(DEFAULT_STANDALONE ON)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEFAULT_LOGGING ON)
set(DEFAULT_ASSERTIONS ON)
else()
set(DEFAULT_ASSERTIONS OFF)
set(DEFAULT_LOGGING OFF)
endif()
# This doesn't really work yet, work ongoing to make it usable
option(STANDALONE "Build a standalone version." ${DEFAULT_STANDALONE})
option(USE_GAMEMATH "Use own maths library rather than libc version for this platform." ON)
option(LOGGING "Enable debug logging." ${DEFAULT_LOGGING})
option(ASSERTIONS "Enable debug assertions." ${DEFAULT_ASSERTIONS})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${thyme_SOURCE_DIR}/cmake/modules)
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE) # Needed to prevent FindDirectX screwing up a mingw build.
include(CheckCXXCompilerFlag)
# Go lean and mean on windows.
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
if(NOT STANDALONE)
add_definitions(-D_USE_32BIT_TIME_T) #This is for ABI compatibility with a few functions, remove when original binary no longer required.
endif()
endif()
check_cxx_compiler_flag(-Wno-invalid-offsetof HAVE_NO_INVALID_OFFSETOF)
if(HAVE_NO_INVALID_OFFSETOF)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Prevent lib prefix when built with MinGW to target windows and move to own dir.
if(MINGW)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${thyme_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${thyme_BINARY_DIR}/bin)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -mabi=ms")
endif()
endif ()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
find_package(DirectX COMPONENTS d3d8)
endif()
endif()
find_package(ICU COMPONENTS data i18n io tu uc)
if(NOT WIN32 OR NOT "${CMAKE_SYSTEM}" MATCHES "Windows")
if(NOT ICU_FOUND)
message(FATAL_ERROR "ICU is required on non-windows platforms and was not found.")
endif()
endif()
# Set where the build results will end up
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Set version info for the base config module
set(GITINFO_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(GITINFO_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(GITINFO_VERSION_PATCH ${PROJECT_VERSION_PATCH})
if(NOT STANDALONE)
set(BASECONF_WINSOCK32 TRUE BOOL)
endif()
# Add base module
add_subdirectory(src/libs/baseconfig)
if(NOT STANDALONE)
set(SETSAIL_ENTRY 0x008E0778)
set(SETSAIL_DLL "${PROJECT_NAME}.dll")
set(SETSAIL_EXE "game.dat")
set(SETSAIL_LAUNCHER launch${PROJECT_NAME})
set(SETSAIL_HASH "5b805b4ecba79581fe8ec454b5acf7b7e13d4dd5")
message("Configuring launcher as ${SETSAIL_LAUNCHER} using entry at ${SETSAIL_ENTRY} to inject ${SETSAIL_DLL} into ${SETSAIL_EXE}")
# Build the launcher
add_subdirectory(launcher)
endif()
# Build Thyme
add_subdirectory(src)