Merge pull request 'Add speed-dreams-data as submodule' (#18) from data-submodule into main

Reviewed-on: #18
This commit is contained in:
Xavier Del Campo Romero 2025-01-15 07:17:04 +01:00
commit bd5f11b80b
12 changed files with 247 additions and 106 deletions

View file

@ -9,16 +9,16 @@ jobs:
run: curl -so 3rdparty.tar.gz ${{ vars.THIRDPARTY_URL }}
- name: Untar third-party libraries
run: tar -xf 3rdparty.tar.gz
- name: Clone repository
- name: Clone repository recursively
run: |
git clone -q \
--recursive \
-b ${{ env.GITHUB_HEAD_REF }} \
${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}.git \
src
- name: Configure project
run: |
cmake -B build \
-DSD_ASSUME_DATADIR=1 \
-DCMAKE_FIND_ROOT_PATH=${{ env.GITHUB_WORKSPACE }}/3rdParty \
-DCMAKE_TOOLCHAIN_FILE=packaging/3rdParty-devel/i686-w64-mingw32.cmake
working-directory: src

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "data"]
path = speed-dreams-data
url = https://forge.a-lec.org/speed-dreams/speed-dreams-data.git

View file

@ -33,30 +33,43 @@ IF(APPLE)
SET(CMAKE_CXX_STANDARD_REQUIRED True)
ENDIF(APPLE)
option(SD_ASSUME_DATADIR "Assume default directory for speed-dreams-data if not found")
option(SD_ASSUME_DATADIR "Assume default directory for speed-dreams-data")
include(GNUInstallDirs)
set(data_version 2.3.0)
find_package(speed-dreams-data ${data_version})
if(NOT SD_DATADIR)
if(SD_ASSUME_DATADIR)
include(GNUInstallDirs)
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
set(SD_DATADIR_ABS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
message(STATUS "Data directory: ${SD_DATADIR_ABS} (assumed)")
set(SD_HAS_DATADIR true)
else()
message(WARNING "Data directory not found or incompatible with version "
"${data_version}. Speed Dreams should still "
"be able to build, but it might not run successfully. "
"If speed-dreams-data has been installed to a non-standard location, "
"please add -DCMAKE_PREFIX_PATH=<data-dir> to the command line to "
"find it.")
endif()
if(SD_ASSUME_DATADIR)
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
set(SD_DATADIR_ABS ${SD_DATADIR_INSTALL_PREFIX})
message(STATUS "Data directory: ${SD_DATADIR_ABS} (assumed)")
elseif(EXISTS speed-dreams-data/CMakeLists.txt)
add_subdirectory(speed-dreams-data)
set(SD_DATADIR ${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
set(SD_DATADIR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/games/speed-dreams-2)
set(SD_DATADIR_ABS ${CMAKE_CURRENT_SOURCE_DIR}/speed-dreams-data/data)
message(STATUS "Data directory: ${SD_DATADIR_ABS} (in-tree)")
else()
set(data_version 2.3.0)
find_package(speed-dreams-data ${data_version} QUIET)
if(NOT SD_DATADIR)
message(FATAL_ERROR
"Data directory not found or incompatible with version "
"${data_version}. Please perform one of the following actions:\n"
"- Update the data git submodule to do an in-tree build with the "
" command below, and then configure the project again:\n"
"git submodule update --init --recursive\n"
"- If speed-dreams-data has been installed to a non-standard "
"location, configure the project with "
"-DCMAKE_PREFIX_PATH=<data-dir>.\n"
"- Configure the project with -DSD_ASSUME_DATADIR=1 to assume "
"speed-dreams-data was installed into a standard location. "
"Speed Dreams should then still be able to build, but it might "
"not run successfully. This option is usually only recommended "
"for CI/CD and packagers."
)
endif()
message(STATUS "Data directory: ${SD_DATADIR_ABS}")
set(SD_HAS_DATADIR true)
endif()
INCLUDE(cmake/macros.cmake)

113
README.md
View file

@ -5,7 +5,8 @@ a fork of the [TORCS](https://torcs.sourceforge.net/) project,
it has evolved into a higher level of maturity, featuring realistic physics
with tens of high-quality cars and tracks to choose from.
> **This repository only contains the engine source code.**
> **This repository contains the engine source code,**
> **and the base assets [as a submodule](/data/).**
> **End users are expected to download the pre-built packages listed below.**
>
> The assets repository is located on
@ -22,35 +23,121 @@ Speed Dreams binaries are available for the following platforms:
## Building from source
In-tree builds (i.e., including both code and data on the same build)
are recommended for simplicity. To achieve this, update the [`data/`](/data/)
submodule with:
```
git submodule update --init --recursive
```
Otherwise, CMake will search the `speed-dreams-data` package on a
well-known location, or rely on the
[`CMAKE_PREFIX_PATH`](https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html)
variable to search for an **installed** version of the `speed-dreams-data`
package, which must then be indicated when configuring the project:
```
cmake -DCMAKE_PREFIX_PATH=<path-to-speed-dreams-data> # other args...
```
> **The steps below will assume in-tree builds unless noted otherwise.**
Once configured as described below, the project can be built with:
```
cmake --build build/ # Optionally, add -j8 or any other number for faster builds
```
Optionally, the project can be installed via:
```
cmake --install build/
```
### BSDs, Linux
Speed Dreams can be built from source using the conventional build process
in CMake projects:
```
cmake -B build
cmake --build build/ # Optionally, add -j8 or any other number for faster builds
```
This assumes the
[`speed-dreams-data`](https://forge.a-lec.org/speed-dreams/speed-dreams-data/)
package is already installed on a well-known location. If not, use the
### Windows
- [CMake](https://cmake.org/download/#latest) `3.12.0` or newer
- [Git](https://git-scm.com/download/win)
- [OpenJDK](https://jdk.java.net/) `8` or newer (for the track editor)
- [MinGW](https://winlibs.com/), with support for C++11.
> Please ensure these tools are added to the `%PATH%` environment variable.
On Windows, dependencies cannot be fetched from a package manager as in
conventional Linux distributions. To solve this, Speed Dreams defines
[a separate build system for third-party dependencies](/packaging/3rdParty-devel/).
This would build all dependencies from source, so they can be later found
by CMake.
> **Both methods described below will require the path to the pre-built**
> **dependencies**.
> Please read [the instructions](/packaging/3rdParty-devel/README.md)
> for further reference.
#### Native builds
If building from Windows, append the path to the pre-built dependencies to
the
[`CMAKE_PREFIX_PATH`](https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html)
variable to indicate CMake where to locate an **installed** version of the
`speed-dreams-data` package:
variable:
```
cmake -B build -DCMAKE_PREFIX_PATH=<path-to-speed-dreams-data>
cmake -B build -DCMAKE_PREFIX_PATH=<path-to-dependencies>
```
And then build the project as usual.
If using MinGW, then the `MinGW Makefiles` CMake generator might have to be
manually selected:
> If the `speed-dreams-data` package is not found, the game should still be
> able to build, but it would not be able to run.
```
cmake -B build -G "MinGW Makefiles" -DCMAKE_PREFIX_PATH=<path-to-dependencies>
```
#### Cross-compiling from Linux
Speed Dreams can not only be compiled natively from Windows, but can be also
cross-compiled for Windows from a fully free (as in freedom) operating
system like GNU/Linux. The
[`w64-mingw32`](https://git.code.sf.net/p/mingw-w64/mingw-w64)
toolchain can be used for the cross-compilation, with dedicated
toolchain files for
[`i686-w64-mingw32`](/packaging/3rdParty-devel/i686-w64-mingw32.cmake)
and
[`x86_64-w64-mingw32`](/packaging/3rdParty-devel/x86_64-w64-mingw32.cmake),
referred to by the
[`CMAKE_TOOLCHAIN_FILE`](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html)
variable. Third-party dependencies are then referred to by the
[`CMAKE_FIND_ROOT_PATH`](https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_ROOT_PATH.html)
variable, as intended for cross-builds.
> **`CMAKE_FIND_ROOT_PATH` must be an absolute path.**
##### `x86_64`
```
cmake -B build -DCMAKE_TOOLCHAIN_FILE=packaging/3rdParty-devel/x86_64-w64-mingw32.cmake -DCMAKE_FIND_ROOT_PATH=<path-to-dependencies>
```
#### `i686`
```
cmake -B build -DCMAKE_TOOLCHAIN_FILE=packaging/3rdParty-devel/i686-w64-mingw32.cmake -DCMAKE_FIND_ROOT_PATH=<path-to-dependencies>
```
### Dependencies
#### Debian/Ubuntu
```
```sh
sudo apt install git cmake build-essential libopenscenegraph-dev libcurl4-gnutls-dev libsdl2-dev libsdl2-mixer-dev librhash-dev libenet-dev libpng-dev libjpeg-dev zlib1g-dev libminizip-dev libopenal-dev libplib-dev libexpat1-dev libcjson-dev openjdk-17-jdk openjdk-17-jre
```
@ -71,3 +158,5 @@ located in their respective directories for further reference.
Windows is a registered trademark of Microsoft Corporation.
Ubuntu is a registered trademark of Canonical Ltd.
Linux is a registered trademark of Linus Torvalds.

View file

@ -174,15 +174,9 @@
#endif
/* Run-time directories */
#cmakedefine SD_HAS_DATADIR
#if defined(SD_HAS_DATADIR)
# define SD_DATADIR "${SD_DATADIR}/"
# define SD_DATADIR_ABS "${SD_DATADIR_ABS}/"
#else
# define SD_DATADIR ""
# define SD_DATADIR_ABS ""
#endif
#define SD_DATADIR "${SD_DATADIR}/"
#define SD_DATADIR_ABS "${SD_DATADIR_ABS}/"
#define SD_DATADIR_INSTALL_PREFIX "${SD_DATADIR_INSTALL_PREFIX}/"
#define SD_LIBDIR "${SD_LIBDIR}/"
#define SD_BINDIR "${SD_BINDIR}/"

View file

@ -27,7 +27,7 @@ computer-controlled driver implementations, flexible race configuration
master server to compare your best lap times against other players."
)
if(SD_HAS_DATADIR AND NOT SD_ASSUME_DATADIR)
if(NOT SD_ASSUME_DATADIR)
set(CPACK_PACKAGE_ICON "${SD_DATADIR_ABS}/data/img/header.bmp")
endif()

View file

@ -8,7 +8,7 @@
set(CPACK_NSIS_INSTALLED_ICON_NAME ${PROJECT_NAME})
set(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_NAME})
set(CPACK_NSIS_DISPLAY_NAME "Speed Dreams ${CPACK_PACKAGE_VERSION} (engine and tools)")
set(CPACK_NSIS_DISPLAY_NAME "Speed Dreams ${CPACK_PACKAGE_VERSION}")
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
set(CPACK_NSIS_HELP_LINK "https://forge.a-lec.org/speed-dreams/")
set(CPACK_PACKAGE_EXECUTABLES
@ -23,7 +23,7 @@ set(CPACK_NSIS_MENU_LINKS
"https://forge.a-lec.org/speed-dreams/" "Project source repositories"
"/doc/userman/how_to_drive.html" "User manual")
if(SD_HAS_DATADIR AND NOT SD_ASSUME_DATADIR)
if(NOT SD_ASSUME_DATADIR)
set(CPACK_NSIS_MUI_ICON "${SD_DATADIR_ABS}/data/icons/icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${SD_DATADIR_ABS}/data/icons/icon.ico")
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${SD_DATADIR_ABS}/data/img/header-vert.bmp")

View file

@ -0,0 +1,97 @@
# Third party dependency builds for Speed Dreams
On platforms where a package manager is not available, such as Microsoft
Windows, third party dependencies must be built from source so CMake can find
them when building Speed Dreams. Builds are based on the
[`ExternalProject`](https://cmake.org/cmake/help/latest/module/ExternalProject.html)
CMake module.
Therefore, Speed Dreams holds [a list](./thirdpartydefinitions.cmake) of
pinnings against third-party dependencies. A build consists of:
1. Fetching the source code from different repositories.
2. Building the dependencies.
3. Installing them to the `3rdParty/` directory, inside the build directory.
**This is the directory referred to by the top-level**
**[`CMakeLists.txt`](/CMakeLists.txt)**
**when performing Windows builds, via either `CMAKE_PREFIX_PATH` or**
**`CMAKE_FIND_ROOT_PATH`**. Read
[the relevant section from the top-level `README.md`](/README.md#windows)
for further reference.
## Requirements
### Debian/Ubuntu
```
sudo apt install cmake subversion git
```
A modern version of the C++ compiler is required because
[OpenAL](https://github.com/kcat/openal-soft) makes use of C++11's
`std::mutex`, which was added to `win32` only recently.
So far, only `14.2.0` has been successfully tested.
Therefore, **this might require to build GCC from source,**
**until distributions ship more modern versions of the C++ compiler**.
#### `x86_64`
```
sudo apt install g++-mingw-w64-x86-64-win32
```
#### `i686`
```
sudo apt install g++-mingw-w64-i686-win32
```
### Windows
- [CMake](https://cmake.org/download/#latest) `3.5.0` or newer
- [Git](https://git-scm.com/download/win)
- [TortoiseSVN](https://tortoisesvn.net/)
- [MinGW](https://winlibs.com/), with support for C++11 and `std::mutex`.
So far, `14.2.0` has been tested successfully.
> Please ensure these tools are added to the `%PATH%` environment variable.
## Configuring
### Natively from Windows
```
cmake -B build
```
### Cross-building from Linux
CMake defines the
[`CMAKE_TOOLCHAIN_FILE`](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html)
variable to set up the cross-toolchain. This directory defines several files,
according to the target platform:
#### `x86_64`
```
cmake -B build -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake
```
#### `i686`
```
cmake -B build -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake
```
## Building
Once the project is configured according to the steps above, build with:
```
cmake --build build/ # Optionally, add -j8 or any other number for faster builds
```
The build will probably take a long time, as it builds tens of third-party
libraries fetched from multiple sources. Once finished, a directory called
`3rdParty/` should be available inside the build directory, ready to be
consumed by [the top-level `CMakeLists.txt`](/CMakeLists.txt).

View file

@ -1,58 +0,0 @@
Building the dependencies for Speed-Dreams makes use of CMake's ExternalProject
module. The source for each is downloaded from each project's site, patched if
necessary, and built. This can take considerable time and accesses several
different sites. See the thirdpartydefinitions.cmake file for the exact sites.
The installation also contains a folder 3rdParty/source_info in which you
will find the source link for each project.
=============================================================================
Windows
As of version 2.3, this will download approximately 35MB of compressed source
files.
You will need more than 1GB of free disk space for the build.
Prerequisites:
DirectX SDK (June 2010) - needed by SDL and possibly OpenAL
http://www.microsoft.com/en-us/download/details.aspx?id=6812
CMake version 3.4 or greater.
Building the 3rd Party dependencies for Windows
Get the code
Using Subversion:
svn co https://svn.code.sf.net/p/speed-dreams/code/trunk/packaging/3rdParty-devel C:\src\3rdParty-devel
If you already have the speed-dreams code:
copy <Path-to sd-code>\packaging\3rdParty-devel\*.* C:\src\3rdParty-devel
Important - Keep the path short ie: C:\src\3rdParty-devel
The building of OpenSceneGraph with CMake's ExternalProject_Add creates quite a deep tree and the build may fail.
CMake CLI Build
Make a directory under the source directory (C:\src\3rdParty-devel)
mkdir build-vs2015-release
Change to the new directory:
cd build-vs2015-release
Generate the build system:
cmake -G "Visual Studio 14 2015" .. -D CMAKE_BUILD_TYPE=Release -A Win32
Build the package:
cmake --build . --target PACKAGE --config Release
Note:
To build with VS2019 on Windows 7 or 8x, you may need to add -D CMAKE_SYSTEM_VERSION=10.0 to the command line:
cmake -G "Visual Studio 16 2019" .. -D CMAKE_BUILD_TYPE=Release -D CMAKE_SYSTEM_VERSION=10.0 -A Win32
=============================================================================
OS X
TODO
=============================================================================
Linux
TODO

1
speed-dreams-data Submodule

@ -0,0 +1 @@
Subproject commit 9749171cef65b4bc93094df17fcf2ec79e8d187a

View file

@ -449,6 +449,8 @@ bool GfApplication::parseOptions()
strDataDir = GfSetDataDir(SD_DATADIR);
if (strDataDir.empty() || !GfDirExists(strDataDir.c_str()))
strDataDir = GfSetDataDir(SD_DATADIR_ABS);
if (strDataDir.empty() || !GfDirExists(strDataDir.c_str()))
strDataDir = GfSetDataDir(SD_DATADIR_INSTALL_PREFIX);
// Check if ALL the Speed-dreams dirs have a usable value, and exit if not.
if (strLocalDir.empty() || strLibDir.empty() || strBinDir.empty() || strDataDir.empty())

View file

@ -9,7 +9,7 @@ IF(MSVC)
SET(_SOURCES ${_SOURCES} main.rc resource.h ../../data/data/icons/icon.ico)
ENDIF(MSVC)
IF(SD_HAS_DATADIR AND NOT SD_ASSUME_DATADIR)
IF(NOT SD_ASSUME_DATADIR)
configure_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}.rc.in.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.rc)
SET(_SOURCES ${_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.rc)