Minimal game template using raylib as a git submodule and CMake.
This repository is intended to be used as a starting point for a new raylib project.
I also have a more modular (lib-based) template,
git clone --recursive to get the raylib submodule local
If you forgot, do:
git submodule update --init --recursive after regular git clone
What your project architecture should ideally look like for the CMakeLists.txt I've included (Can change accordingly, otherwise)
‖
‖——.git*
‖——CMakeLists.txt
‖——CMakePresets.json
‖——include/
‖ ‖——*.h or *.hpp → all *your* header files
‖——src/
‖ ‖——main.cpp
‖ ‖——*.cpp → all other source files
‖——raylib/ → your raylib engine (submodule)mkdir build
cd build
cmake --preset Debug OR cmake --preset Release -- (configuration of cmake)
cmake --build --preset Debug OR cmake --build --preset Release -- (compilation + build of your files, only what has changed since last build)
Executable will appear in build/ under preset name
Raylib requires a lot of libraries that are built-in on Mac and Windows.
No worries, Linux just requires 1 command to install them all:
sudo apt install \
libx11-dev \
libxcursor-dev \
libxrandr-dev \
libxi-dev \
libxinerama-dev \
libgl1-mesa-dev \
libasound2-dev \
libpulse-dev \
libxkbcommon-devPut any new .cpp or .c files in src/
Update CMakeLists.txt as needed, example:
add_executable(YourProjectName
src/main.cpp
src/other_file.cpp
)cd raylib
git pull
cd ..
git add raylib
git commit -m "Updated raylib submodule"- CMake 3.20+
- C++ compiler: GCC / Clang
- Ninja (not required, but it's what the presets use)