3.1 KiB
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:
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:
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/.../cmakeLibraries/SDLImage/.../cmakeLibraries/SDLMixer/.../cmakeLibraries/SDLTtf/.../cmake
These are only used for MSVC builds.
Linux
CMake falls back to pkg-config and expects these packages to be installed:
sdl2SDL2_imageSDL2_mixerSDL2_ttf
Troubleshooting
CMake fails at find_package(OpenGL REQUIRED)
Install the OpenGL development package.
Ubuntu / Debian:
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=OFFand 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.