forked from TheAssemblyArmada/Thyme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
128 lines (101 loc) · 4.21 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
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}")
# 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)
include(CheckCXXCompilerFlag)
# Go lean and mean on windows.
if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
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(STANDALONE)
add_definitions(-DTHYME_STANDALONE)
endif()
if(NOT STANDALONE AND MSVC)
set(USING_STLPORT TRUE BOOL INTERNAL)
endif()
if(USING_STLPORT)
add_definitions(-DTHYME_USE_STLPORT)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND STANDALONE)
find_package(DirectX COMPONENTS d3d8)
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})
# Add base module
add_subdirectory(src/libs/baseconfig)
if(NOT STANDALONE)
# Build the launcher
add_subdirectory(launcher)
endif()
# Build Thyme
add_subdirectory(src)