blob: 37a6a94b13bc5fe0fa86557f6b1d5443a3b19e0c (
plain) (
blame)
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
|
cmake_minimum_required(VERSION 3.13)
set(TOOLS_PREFIX ${CMAKE_BINARY_DIR}/tools)
include(ExternalProject)
ExternalProject_Add(tools
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools
CMAKE_ARGS
-D CMAKE_INSTALL_PREFIX=${TOOLS_PREFIX})
project(rts C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
if(CMAKE_TOOLCHAIN_FILE MATCHES "ps1")
set(PS1_BUILD 1)
elseif(CMAKE_TOOLCHAIN_FILE MATCHES "win9x")
set(WIN9X_BUILD 1)
else()
set(HOST_BUILD 1)
endif()
add_executable(${PROJECT_NAME} "src/main.c")
set(cdroot ${CMAKE_BINARY_DIR}/cdimg)
file(MAKE_DIRECTORY ${cdroot})
# Avoid C11 since it is not supported by the i386-mingw32 toolchain.
set(cflags -Wall -g3 -ffunction-sections -fdata-sections -pedantic -std=c99)
if(PS1_BUILD)
include("cmake/ps1.cmake")
elseif(WIN9X_BUILD)
include("cmake/win9x.cmake")
elseif(HOST_BUILD)
include("cmake/host.cmake")
endif()
add_subdirectory("res")
set(components
building
camera
container
font
game
gfx
gui
header
instance
keyboard
menu
mouse
pad
peripheral
player
resource
sfx
system
terrain
unit
util
)
set(interfaces
tech
)
target_compile_options(${PROJECT_NAME} PUBLIC ${cflags})
# Dependencies for main.c
target_link_libraries(${PROJECT_NAME} PRIVATE system menu)
foreach(c ${components})
add_subdirectory("src/${c}")
target_compile_options(${c} PUBLIC ${cflags})
endforeach()
foreach(i ${interfaces})
add_subdirectory("src/${i}")
target_compile_options(${i} INTERFACE ${cflags})
target_link_libraries(${PROJECT_NAME} PRIVATE ${c})
endforeach()
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--gc-sections)
|