Deprecate <TARGET>_BUILD in favor of CMAKE_TOOLCHAIN_FILE

This commit is contained in:
Xavier Del Campo Romero 2022-06-19 03:09:28 +02:00
parent 3cb276b19f
commit 7c1795401b
2 changed files with 32 additions and 23 deletions

View File

@ -1,22 +1,5 @@
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)
endif()
if(PS1_BUILD)
include("cmake/ps1-toolchain.cmake")
elseif(WIN9X_BUILD)
include("cmake/win9x-toolchain.cmake")
endif()
set(TOOLS_PREFIX ${CMAKE_BINARY_DIR}/tools)
include(ExternalProject)
ExternalProject_Add(tools
@ -26,6 +9,14 @@ ExternalProject_Add(tools
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.

View File

@ -34,6 +34,8 @@ hardware.
## Building from source
### Native build
A native version of **RTS** can be built using the typical CMake build
process:
@ -41,21 +43,25 @@ process:
mkdir build
cd build
cmake ..
make -j$(nproc --all)
```
The following options can be otherwise defined:
### Cross-compilation
- `PS1_BUILD`: builds for Sony Playstation 1
- `HOST_BUILD`: builds for the host operating system using SDL-1.2
- `WIN9X_BUILD`: builds for Microsoft Win9x operating systems using
SDL-1.2. A `i386-mingw32` cross-toolchain must be available.
[`CMAKE_TOOLCHAIN_FILE`](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html)
can be used to set up the cross-toolchain. Files labeled as
`cmake/*-toolchain.cmake` can be used as values.
#### Sony PlayStation 1
For example, the Sony PlayStation 1 version can be built using:
```sh
mkdir build
cd build
cmake .. -DPS1_BUILD=1 -DVIDEO_MODE=VMODE_PAL
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../cmake/ps1-toolchain.cmake \
-DVIDEO_MODE=VMODE_PAL # VMODE_NTSC can be otherwise used
make -j$(nproc --all)
```
@ -63,6 +69,18 @@ This will generate a `.bin`/`.cue` file pair in `build` that can be
played on an emulator or burnt into a CD-r in order to play the game
on real hardware.
#### Microsoft Win9x
```sh
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/win9x-toolchain.cmake
make -j$(nproc --all)
```
A stripped version of the executable, as well as game assets, will be
located in `build/cdimg`.
## License
Unless stated otherwise, **RTS** follows the license described by the