`gui` was tighly coupled to game logic, and could not be extended for other purposes. Therefore, a generic GUI implementation, loosely inspired by well-known GUI frameworks such as GTK, is now provided, with the following properties: - Does not depend on dynamic or static memory allocation, only automatic (i.e., stack) memory allocation required. - Portable among existing implementations. - Simple to extend. - Tiny memory footprint. `gui` is now composed by GUI elements that can be chained to form a tree structure. This is useful e.g.: to calculate X/Y coordinates for a given GUI element given its parent(s). This commit also refactors the older implementation, moving game-specific logic into `player` and making use of the new component.
78 lines
1.6 KiB
CMake
78 lines
1.6 KiB
CMake
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)
|
|
|
|
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)
|
|
# 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
|
|
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 game)
|
|
|
|
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)
|