2021-07-03 00:49:03 +02:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
2022-06-06 21:51:44 +02:00
|
|
|
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})
|
|
|
|
|
2021-07-03 00:49:03 +02:00
|
|
|
project(rts)
|
|
|
|
|
2022-06-19 03:09:28 +02:00
|
|
|
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()
|
|
|
|
|
2021-07-03 00:49:03 +02:00
|
|
|
add_executable(${PROJECT_NAME} "src/main.c")
|
2022-02-08 15:17:49 +01:00
|
|
|
set(cdroot ${CMAKE_BINARY_DIR}/cdimg)
|
2022-05-24 22:19:34 +02:00
|
|
|
# Avoid C11 since it is not supported by the i386-mingw32 toolchain.
|
|
|
|
set(cflags -Wall -g3 -ffunction-sections -fdata-sections -pedantic -std=c99)
|
2021-07-03 00:49:03 +02:00
|
|
|
|
|
|
|
if(PS1_BUILD)
|
2022-05-24 22:19:34 +02:00
|
|
|
include("cmake/ps1.cmake")
|
2021-07-03 00:49:03 +02:00
|
|
|
elseif(WIN9X_BUILD)
|
2022-05-24 22:19:34 +02:00
|
|
|
include("cmake/win9x.cmake")
|
2021-07-03 00:49:03 +02:00
|
|
|
elseif(HOST_BUILD)
|
2022-05-24 22:19:34 +02:00
|
|
|
include("cmake/host.cmake")
|
2021-07-03 00:49:03 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_subdirectory("res")
|
|
|
|
|
|
|
|
set(components
|
|
|
|
building
|
|
|
|
camera
|
|
|
|
container
|
|
|
|
font
|
|
|
|
game
|
|
|
|
gfx
|
|
|
|
gui
|
2022-02-20 19:04:21 +01:00
|
|
|
header
|
2021-07-03 00:49:03 +02:00
|
|
|
instance
|
2022-02-24 17:55:57 +01:00
|
|
|
keyboard
|
2022-06-24 17:53:46 +02:00
|
|
|
menu
|
2022-02-24 17:55:57 +01:00
|
|
|
mouse
|
2021-07-03 00:49:03 +02:00
|
|
|
pad
|
2022-06-12 22:34:23 +02:00
|
|
|
peripheral
|
2021-07-03 00:49:03 +02:00
|
|
|
player
|
|
|
|
resource
|
|
|
|
sfx
|
|
|
|
system
|
|
|
|
terrain
|
|
|
|
unit
|
|
|
|
util
|
|
|
|
)
|
|
|
|
|
|
|
|
set(interfaces
|
|
|
|
tech
|
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_options(${PROJECT_NAME} PUBLIC ${cflags})
|
2022-06-11 23:55:07 +02:00
|
|
|
# Dependencies for main.c
|
2022-06-24 17:53:46 +02:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE system menu)
|
2021-07-03 00:49:03 +02:00
|
|
|
|
|
|
|
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)
|