-
Notifications
You must be signed in to change notification settings - Fork 89
/
CMakeLists.txt
125 lines (104 loc) · 2.94 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
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0)
# root
PROJECT(vangers)
# modules
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# options
OPTION(BINARY_SCRIPT "Use binary script for interface" ON)
OPTION(DIAGEN_TEST "Dialog generator and test subsystem" OFF)
# hide optons
OPTION(ACTINT "Actint user interface in road game" ON)
SET(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
IF(MINGW)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
ENDIF()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# depends
FIND_PACKAGE(SDL2 REQUIRED)
FIND_PACKAGE(SDL2_net REQUIRED)
FIND_PACKAGE(Ogg REQUIRED)
FIND_PACKAGE(Vorbis REQUIRED)
FIND_PACKAGE(VorbisFile REQUIRED)
FIND_PACKAGE(Clunk REQUIRED)
FIND_PACKAGE(FFMPEG REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
set(WINDOWS_RES "../vangers.res")
IF(BINARY_SCRIPT)
ADD_DEFINITIONS(-D_BINARY_SCRIPT_)
ENDIF(BINARY_SCRIPT)
IF(ACTINT)
ADD_DEFINITIONS(-DACTINT)
ENDIF(ACTINT)
IF(DIAGEN_TEST)
ADD_DEFINITIONS(-DDIAGEN_TEST)
ENDIF(DIAGEN_TEST)
# globals
INCLUDE_DIRECTORIES(SYSTEM
${ZLIB_INCLUDE_DIR}
${SDL2_INCLUDE_DIR}
${SDL2_NET_INCLUDE_DIRS}
${FFMPEG_INCLUDE_DIRS}
${CLUNK_INCLUDE_DIR}
${OGG_INCLUDE_DIR}
${VORBIS_INCLUDE_DIR}
${VORBISFILE_INCLUDE_DIR}
${STEAM_INCLUDE_DIR}
)
INCLUDE(CheckCXXCompilerFlag)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -ftree-vectorize -ffast-math")
CHECK_CXX_COMPILER_FLAG("-msse2" HAVE_SIMDSSE)
IF(HAVE_SIMDSSE)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2")
ENDIF()
# For modern gcc
add_definitions(-D_USE_MATH_DEFINES)
add_compile_options(-Werror=shift-negative-value)
add_compile_options(-Werror=dangling-else)
add_compile_options(-Werror=parentheses)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=delete-non-virtual-dtor>)
add_compile_options(-Werror=write-strings)
add_compile_options(-fsigned-char)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Werror=mismatched-new-delete )
endif()
IF(WIN32)
SET(WIN_DBG
dbghelp
)
ENDIF(WIN32)
# Get the current working branch
IF(NOT($ENV{GITHUB_REF_NAME}))
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
COMMAND_ECHO STDOUT
ECHO_OUTPUT_VARIABLE
ECHO_ERROR_VARIABLE
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
# Get the latest commit hash
IF(NOT($ENV{GITHUB_SHA}))
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
COMMAND_ECHO STDOUT
ECHO_OUTPUT_VARIABLE
ECHO_ERROR_VARIABLE
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
# subdirs
ADD_SUBDIRECTORY("src")
ADD_SUBDIRECTORY("lib/xgraph")
ADD_SUBDIRECTORY("lib/xsound")
ADD_SUBDIRECTORY("lib/xtool")
if(NOT ANDROID)
ADD_SUBDIRECTORY("lib/utils")
ADD_SUBDIRECTORY("server")
ADD_SUBDIRECTORY("surmap")
endif()