rts/CMakeLists.txt

88 lines
1.9 KiB
CMake
Raw Normal View History

2021-07-03 00:49:03 +02:00
cmake_minimum_required(VERSION 3.13)
option(PS1_BUILD "Build for the original Sony Playstation" OFF)
option(HOST_BUILD "Build for host platform using SDL-1.2" OFF)
option(WIN9X_BUILD "Build for Win9x using SDL-1.2" OFF)
if(NOT PS1_BUILD AND NOT HOST_BUILD AND NOT WIN9X_BUILD)
message(STATUS "Assuming native build. "
"Please use one of the available options in CMakeLists.txt to "
"cross-compile for a specific target.")
set(HOST_BUILD ON)
2021-07-03 00:49:03 +02:00
endif()
if(PS1_BUILD)
include("cmake/ps1-toolchain.cmake")
2021-07-03 00:49:03 +02:00
elseif(WIN9X_BUILD)
include("cmake/win9x-toolchain.cmake")
2021-07-03 00:49:03 +02:00
endif()
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)
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)
2021-07-03 00:49:03 +02:00
if(PS1_BUILD)
include("cmake/ps1.cmake")
2021-07-03 00:49:03 +02:00
elseif(WIN9X_BUILD)
include("cmake/win9x.cmake")
2021-07-03 00:49:03 +02:00
elseif(HOST_BUILD)
include("cmake/host.cmake")
2021-07-03 00:49:03 +02:00
endif()
add_subdirectory("res")
set(components
building
2022-06-11 23:22:04 +02:00
button
2021-07-03 00:49:03 +02:00
camera
container
font
game
gfx
gui
header
2021-07-03 00:49:03 +02:00
instance
2022-02-24 17:55:57 +01:00
keyboard
mouse
2021-07-03 00:49:03 +02:00
pad
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})
# Dependencies for main.c
target_link_libraries(${PROJECT_NAME} PRIVATE system game)
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)