Files
prog2/BUILDING.md
2026-04-12 23:26:29 +02:00

103 lines
3.1 KiB
Markdown

# Building Motherload
This repository now supports both the original Visual Studio solution files and a CMake-based build.
## Supported build paths
### 1. CMake on Windows
Recommended if you want a modern, editor-friendly build setup.
Requirements:
- Visual Studio 2022 with Desktop development with C++
- CMake 3.21+
The repository already contains the required prebuilt Windows SDL packages in `Libraries/`.
Those bundled packages are intended for **MSVC / Visual Studio**, not MinGW.
Configure and build:
```bash
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Debug
```
### 2. CMake on Linux
Requirements:
- C++ compiler
- CMake 3.21+
- SDL2 development packages
- OpenGL development package
Ubuntu / Debian example:
```bash
sudo apt install build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libgl1-mesa-dev
cmake -S . -B build
cmake --build build
```
### 3. Legacy Visual Studio solution
The existing `.sln` and `.vcxproj` files are still in the repo and can still be opened directly in Visual Studio.
### CLion with MinGW on Windows
This is a different toolchain from MSVC. The bundled SDL packages in `Libraries/` are the Visual C++ SDL package, so they should not be used with MinGW.
Use one of these options instead:
- switch CLion to a Visual Studio toolchain
- or install MinGW-compatible SDL packages and configure CMake with `-DMOTHERLOAD_USE_BUNDLED_WINDOWS_SDL=OFF`
## Build output
The CMake build writes the executable to:
- `build/bin/` for single-config generators
- the active configuration output folder for Visual Studio generators
Resource files from `Resources/` are copied automatically after a successful build.
## Notes about dependencies
### Windows
CMake uses the bundled SDL package config files from:
- `Libraries/SDLMain/.../cmake`
- `Libraries/SDLImage/.../cmake`
- `Libraries/SDLMixer/.../cmake`
- `Libraries/SDLTtf/.../cmake`
These are only used for **MSVC** builds.
### Linux
CMake falls back to `pkg-config` and expects these packages to be installed:
- `sdl2`
- `SDL2_image`
- `SDL2_mixer`
- `SDL2_ttf`
## Troubleshooting
### CMake fails at `find_package(OpenGL REQUIRED)`
Install the OpenGL development package.
Ubuntu / Debian:
```bash
sudo apt install libgl1-mesa-dev
```
### CMake cannot find SDL packages on Linux
Install the SDL development packages listed above.
### CLion / MinGW on Windows fails while linking SDL2main
That usually means the Visual Studio SDL package from `Libraries/` is being used with MinGW.
Use one of these fixes:
- use a Visual Studio toolchain in CLion
- or configure CMake with `-DMOTHERLOAD_USE_BUNDLED_WINDOWS_SDL=OFF` and provide MinGW-compatible SDL libraries
### The game starts but cannot find assets
Run the executable from the build output directory, not from the source directory root. The post-build step copies `Resources/` next to the executable.
### Why are the old MSVC `#pragma comment(lib, ...)` lines still in the code?
They are still there for the legacy Visual Studio project files, but the CMake build disables them explicitly so dependency management stays inside CMake.