forked from stuntrally/stuntrally3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists-WindowsRelease.txt
executable file
·430 lines (320 loc) · 13.2 KB
/
CMakeLists-WindowsRelease.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# INFO
# This config assumes you used bat script to get and build latest Ogre-next from sources
# and your Ogre source code is above, in ../Ogre/ogre-next and ../Ogre/ogre-next-deps
# Also assuming all dependencies were built from sources.
# This is only for Windows, Release version.
# Have to set manual paths below to yours. All start with D:/_/sr/
# To use: rename this file to CMakeLists.txt and folder CMakeManual\ to CMake\
# Details in docs\BuildingVS.md
# Tested on Windows 10.
# see CMake/DependenciesConfig.cmake
# Conan is not used
cmake_minimum_required( VERSION 3.16 )
# Include path for additional CMake library finding scripts
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/" ${CMAKE_MODULE_PATH})
message(STATUS "Build DIR: ${CMAKE_BINARY_DIR}")
# Include path for additional CMake library finding scripts
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/" ${CMAKE_MODULE_PATH})
# Add a sensible build type default and warning because empty means no optimization and no debug info.
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" CACHE STRING "Configuration types")
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.22")
cmake_policy(SET CMP0127 OLD)
endif()
cmake_policy(SET CMP0111 NEW)
include(CMakeDependentOption)
include(Macros)
#find_package(PkgConfig REQUIRED)
include(FeatureSummary)
project( StuntRally3 )
# User Options to disable building components --------
option(BUILD_GAME "Build the game binary." ON)
option(BUILD_EDITOR "Build the track editor." ON)
option(BUILD_MASTER_SERVER "Build the game list master server." OFF)
option(BUILD_TRANSL_TOOL "Build the tool for translation updating, it creates .pot" ON)
#^ ?
# Linux prefers lower-case exe names
if (WIN32 OR APPLE)
set(GAME_EXE StuntRally3)
set(EDITOR_EXE SR-Editor3)
set(SERVER_EXE SR-MasterServer)
set(TRANSL_EXE SR-Translator)
else()
set(GAME_EXE stuntrally3)
set(EDITOR_EXE sr-editor3)
set(SERVER_EXE sr-masterserver)
set(TRANSL_EXE sr-translator)
endif()
set(_PREFIX "SR_")
# Test if conan is installed
#- find_program(CONAN_CMD_TEST conan NO_CACHE) // fixme?
#- cmake_dependent_option(USE_PACKAGE_MANAGER "Use conan" ON "NOT CONAN_CMD_TEST STREQUAL CONAN_CMD_TEST-NOTFOUND" OFF)
set(USE_PACKAGE_MANAGER OFF)
message(STATUS "Using conan: ${USE_PACKAGE_MANAGER}")
# Allow user to globally set the library preference for external libraries
cmd_option(${_PREFIX}LIB_PREFERENCE
"Library preference [SYSTEM (if available), CONAN]"
"CONAN"
STRINGS "SYSTEM" "CONAN"
)
# Special mode, that will force dependencies to the packages provided by system unless they were set to conan explicitly.
option(${_PREFIX}FORCE_SYSTEM_DEPENDENCIES "Force the use of system packages")
# Avoid source tree pollution
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\nmkdir build; cd build; cmake ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
# exe path ----
set( EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}" )
# Set CXX compile flags
if( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-comment -Wno-dangling-else -Wno-deprecated-declarations -Wno-parentheses")
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "GCC detected, adding compile flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
if( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
if( NOT PLATFORM_X64 )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
endif()
add_definitions( -DUNICODE -D_UNICODE )
endif()
# deps ----
# Check for dependencies
# include(DependenciesConfig)
#- message( STATUS "---------- resolve_conan_dependencies" )
#- resolve_conan_dependencies()
# root dir
message( STATUS "---------- root dir above" )
get_filename_component( DIR_ONE_ABOVE ../og3/ ABSOLUTE )
# ^-
message( STATUS ${DIR_ONE_ABOVE} )
set( OGRE_NEXT_DIR ${DIR_ONE_ABOVE}/Ogre/ogre-next )
# Fix 1 Ogre
set( OGRE_SOURCE ${OGRE_NEXT_DIR}/ )
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
set( OGRE_BINARIES ${OGRE_NEXT_DIR}/build/Debug )
else()
set( OGRE_BINARIES ${OGRE_NEXT_DIR}/build/Release )
endif()
include( CMake/Dependencies/OGRE.cmake )
# This scripts will add all the cpp and h files from src and include folders
message( STATUS "---------- setup Ogre" )
setupOgre( OGRE_SOURCE, OGRE_BINARIES, OGRE_LIBRARIES, FALSE, FALSE )
# Fix 2 SDL
include_directories( "/usr/include/SDL2" )
include_directories( ${DIR_ONE_ABOVE}/Ogre/ogre-next-deps/build/ogredeps/include ) #for rapidjson
# MyGui
include_directories( ${DIR_ONE_ABOVE}/mygui-next/MyGUIEngine/include )
include_directories( ${DIR_ONE_ABOVE}/mygui-next/Platforms/Ogre2/Ogre2Platform/include )
macro( add_recursive dir retVal )
file( GLOB GLOB_RESULT ${dir}/*.h ${dir}/*.cpp ${dir}/*.c )
list( APPEND ${retVal} ${GLOB_RESULT})
endmacro()
message( STATUS "---------- SR sources" )
# Compiler ----
set( COMMON_SRC_DIRS
# not really sources
data/gui
data/materials
data/particles
# libs
./src/btOgre2
# sources
./src/common
./src/common/data
./src/common/MessageBox
./src/road
./src/OgreCommon
./src/OgreCommon/System
./src/OgreCommon/System/Android
./src/OgreCommon/System/Desktop
./src/OgreCommon/Threading
./src/OgreCommon/Utils
./src/Terra
./src/Terra/Hlms
./src/Terra/Hlms/PbsListener
# both game and ed meh-
#./src/vdriftCommon
./src/sound
./src/vdrift
)
# game
set( GAME_SRC_DIRS ${COMMON_SRC_DIRS} )
list( APPEND GAME_SRC_DIRS ./src/game )
#list( APPEND GAME_SRC_DIRS ./src/sound )
#list( APPEND GAME_SRC_DIRS ./src/vdrift )
list( APPEND GAME_SRC_DIRS ./src/oics ) # libs
list( APPEND GAME_SRC_DIRS ./src/network )
# editor
set( EDITOR_SRC_DIRS ${COMMON_SRC_DIRS} )
list( APPEND EDITOR_SRC_DIRS ./src/editor )
# exe list game and editor
if (BUILD_GAME)
list( APPEND EXE_LIST ${GAME_EXE} )
endif()
if (BUILD_EDITOR)
list( APPEND EXE_LIST ${EDITOR_EXE} )
endif()
# fix 4 OpenAL since conan failed - common, meh
# find_package( OpenAL REQUIRED )
# include_directories( ${OPENAL_INCLUDE_DIR} )
find_package( Threads )
# find_package( Boost COMPONENTS system thread REQUIRED )
# fix 5 bullet
# find_package( Bullet REQUIRED )
message( STATUS "--- Bullet: " ${BULLET_FOUND} )
# message( STATUS "--- Bullet: " ${BULLET_INCLUDE_DIRS} )
# message( STATUS "--- Bullet: " ${BULLET_LIBRARIES} )
# find_package(OGG REQUIRED)
# find_package(Vorbis REQUIRED)
## Executables
##------------------------------------------------------------------------------------------------------
foreach( EXE ${EXE_LIST} )
message( STATUS "Configuring: " ${EXE} )
# sources ----
set( EXE_SOURCES "")
if ( ${EXE} STREQUAL ${EDITOR_EXE} ) # ed
set( SRC_DIRS ${EDITOR_SRC_DIRS} )
else()
set( SRC_DIRS ${GAME_SRC_DIRS} )
endif()
foreach( subdir ${SRC_DIRS} )
#message( STATUS ${subdir} )
add_recursive( ${subdir} EXE_SOURCES )
endforeach()
# exe ----
add_executable( ${EXE} WIN32 ${EXE_SOURCES} )
# add includes ----
foreach( subdir ${SRC_DIRS} )
#message( STATUS ${subdir} )
target_include_directories( ${EXE} PRIVATE ${subdir} )
endforeach()
target_include_directories( ${EXE} PRIVATE ${BULLET_INCLUDE_DIRS} )
# fix 5 ENet since conan fails
# find_package( ENet REQUIRED ) # inside Dep..cmake
if ( ${EXE} STREQUAL ${GAME_EXE} ) # game, once
target_include_directories( ${EXE} PRIVATE ${ENet_INCLUDE_DIRS} )
target_include_directories( ${EXE} PRIVATE ${Boost_INCLUDE_DIRS} )
endif()
# vs2019 paths ------------------------
SET(BUILD_TYPE "Release")
# tinyxml2
target_include_directories( ${EXE} PRIVATE "D:/_/sr/tinyxml2-9.0.0" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/tinyxml2-9.0.0/build/" ${BUILD_TYPE} )
target_link_libraries( ${EXE} "tinyxml2.lib" )
# boost
target_include_directories( ${EXE} PRIVATE "C:/b/boost_1_81_0" )
target_link_directories( ${EXE} PRIVATE "C:/b/boost_1_81_0/lib64-msvc-14.2" )
# enet
target_include_directories( ${EXE} PRIVATE "D:/_/sr/enet-1.3.17/include" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/enet-1.3.17/build/" ${BUILD_TYPE} )
target_link_libraries( ${EXE} "enet.lib" )
target_link_libraries( ${EXE} "winmm.lib" )
target_link_libraries( ${EXE} "Ws2_32.lib" )
# vorbis
target_include_directories( ${EXE} PRIVATE "D:/_/sr/libvorbis-1.3.7/include" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/libvorbis-1.3.7/build/lib/" ${BUILD_TYPE} )
target_link_libraries( ${EXE} "vorbis.lib" )
target_link_libraries( ${EXE} "vorbisfile.lib" )
# ogg
target_include_directories( ${EXE} PRIVATE "D:/_/sr/libogg-1.3.5/include" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/libogg-1.3.5/build/" ${BUILD_TYPE} )
target_link_libraries( ${EXE} "ogg.lib" )
# sdl2
target_include_directories( ${EXE} PRIVATE "D:/_/sr/og3/Ogre/ogre-next-deps/src/SDL2/include" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/og3/Ogre/ogre-next-deps/build/ogredeps/lib/" )
target_link_libraries( ${EXE} "SDL2.lib" )
# bullet
# target_compile_definitions( ${EXE} PRIVATE BT_USE_DOUBLE_PRECISION=1 )
target_include_directories( ${EXE} PRIVATE "D:/_/sr/bullet3-3.25/src" )
target_include_directories( ${EXE} PRIVATE "D:/_/sr/bullet3-3.25/Extras/Serialize" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/bullet3-3.25/bin" )
message(STATUS "BUILD_TYPE: " ${BUILD_TYPE})
target_link_libraries( ${EXE} "LinearMath_vs2010_x64_release.lib" )
target_link_libraries( ${EXE} "BulletCollision_vs2010_x64_release.lib" )
target_link_libraries( ${EXE} "BulletDynamics_vs2010_x64_release.lib" )
target_link_libraries( ${EXE} "BulletFileLoader_vs2010_x64_release.lib" )
target_link_libraries( ${EXE} "BulletWorldImporter_vs2010_x64_release.lib" )
# openal-soft
target_include_directories( ${EXE} PRIVATE "D:/_/sr/openal-soft/include" )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/openal-soft/build/" ${BUILD_TYPE} )
target_link_libraries( ${EXE} "OpenAL32.lib" )
# ogre
target_compile_definitions( ${EXE} PRIVATE _HAS_AUTO_PTR_ETC=1 )
target_link_directories( ${EXE} PRIVATE "D:/_/sr/og3/Ogre/ogre-next/build/lib/" ${BUILD_TYPE} )
if (${BUILD_TYPE} STREQUAL "Debug")
set(SUFFIX_D "_d")
else()
set(SUFFIX_D "")
endif()
target_link_libraries( ${EXE} "OgreMain.lib" )
target_link_libraries( ${EXE} "OgreHlmsPbs.lib" )
target_link_libraries( ${EXE} "OgreHlmsUnlit.lib" )
target_link_libraries( ${EXE} "OgreAtmosphere.lib" )
target_link_libraries( ${EXE} "Plugin_ParticleFX.lib" )
target_link_libraries( ${EXE} "RenderSystem_Direct3D11.lib" )
target_link_libraries( ${EXE} "RenderSystem_GL3Plus.lib" )
# mygui
target_link_directories( ${EXE} PRIVATE "D:/_/sr/og3/mygui-next/build/Release/lib/Release" )
target_link_libraries( ${EXE} "MyGUIEngine.lib" )
target_link_libraries( ${EXE} "MyGUI.Ogre2Platform.lib" )
# -------------------------------------
# pch.h
if ( ${EXE} STREQUAL ${EDITOR_EXE} ) # ed
set_target_properties( ${EXE} PROPERTIES COMPILE_FLAGS "-DSR_EDITOR" )
target_precompile_headers( ${EXE} PRIVATE src/editor/pch.h )
else()
target_precompile_headers( ${EXE} PRIVATE src/game/pch.h )
endif()
# c++
#target_compile_options( ${EXE} PRIVATE -Wswitch )
target_compile_features( ${EXE} PRIVATE cxx_std_17 )
# add linker ----
# threads
target_link_libraries( ${EXE} ${CMAKE_THREAD_LIBS_INIT} )
# OpenAL
#target_link_libraries( ${EXE} "${OPENAL_LIBRARY}" )
# bullet
#target_link_libraries( ${EXE} ${BULLET_LIBRARIES} -lBulletWorldImporter )
# Ogre ----
target_link_libraries( ${EXE} ${OGRE_LIBRARIES} )
# SDL
#target_link_libraries( ${EXE} "-lSDL2" )
# MyGui ---- # todo: windows ..
#if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
# set(SUFFIX_D "_d")
#else()
set(SUFFIX_D "")
#endif()
#target_link_libraries( ${EXE} ${DIR_ONE_ABOVE}/mygui-next/build/${CMAKE_BUILD_TYPE}/lib/libMyGUI.Ogre2Platform${SUFFIX_D}.a )
if ( ${EXE} STREQUAL ${GAME_EXE} ) # game, once
#add_library( libMyGUIEngine SHARED IMPORTED )
endif()
#set_target_properties( libMyGUIEngine PROPERTIES IMPORTED_LOCATION ${DIR_ONE_ABOVE}/mygui-next/build/${CMAKE_BUILD_TYPE}/lib/libMyGUIEngine${SUFFIX_D}.so )
#target_link_libraries( ${EXE} libMyGUIEngine )
# ENet, boost for networking ----
if ( ${EXE} STREQUAL ${GAME_EXE} ) # game, once
#target_link_libraries( ${EXE} ${Boost_LIBRARIES} )
#target_link_libraries( ${EXE} ${ENet_LIBRARIES} )
endif()
# rest
#message( STATUS "Libs " ${EXE} " " ${LIBS} )
target_link_libraries( ${EXE} ${LIBS} )
endforeach()
## Translations tool
##------------------------------------------------------------------------------------------------------
if (BUILD_TRANSL_TOOL)
message( STATUS "Configuring: " ${TRANSL_EXE} )
add_executable( ${TRANSL_EXE} WIN32 ./src/transl/main.cpp )
target_include_directories( ${TRANSL_EXE} PRIVATE ./src/transl )
target_precompile_headers( ${TRANSL_EXE} PRIVATE src/transl/pch.h )
# c++
# target_compile_options( ${TRANSL_EXE} PRIVATE -Wswitch )
target_compile_features( ${TRANSL_EXE} PRIVATE cxx_std_17 )
set_target_properties( ${TRANSL_EXE} PROPERTIES LINKER_LANGUAGE CXX )
# target_link_libraries( ${TRANSL_EXE} ${LIBS} )
endif()
message( STATUS "---------- SR end" )