A cross-platform template for C++ raylib projects using cmake
There are two ways to use this project template. You can either create a your own GitHub repo using this template (very similar to forking) or your can directly clone this repo on your local machine. Here are steps for both these ways:
-
GitHub repo using template
-
Make sure you are logged into your GitHub account.
-
Click on the "Use this template" button.
-
Provide a name for your new repo.
-
Click "Create repositoy from template".
-
Clone your new repo recursively.
git clone --recursive <your-repo-link-here>
-
-
Local repo by direcly cloning
Step 1. Clone this repo recusrively using this command:
git clone --recursive https://github.com/ufrshubham/raylib-project-template.git
Note: If you've already cloned this repo without using --recursive flag, just run git submodule update --init to update the submodules.
-
Source files should be placed under
srcdirectory. -
Header files should be placed under
includedirectory. HeaderVersion.hppcan be remove completely as it is just for demo. -
Source code for Raylib is pulled as a submodule under
vendors/rayliband is built along with your code. -
Assets like images, audio and fonts can be placed under
resourcesdirectory. If you choose to use a custom directory for this, you'll have to handle how your executable finds those assets. The demo code insrc/main.cppprogramitically changes the working directory to the path whereresourcesdirectory is located (see the static functionmodifyCurrentWorkingDirectory).
-
Make a directory for build in your project root.
cmake -E make_directory ./build
-
Go to the build directory.
cd build/ -
Generate project files (For debug builds, replace
ReleasewithDebug).cmake .. -DCMAKE_BUILD_TYPE=Release
-
Build (For debug builds, replace
ReleasewithDebug).cmake --build . --config Release -
You should find the executables under
build/bin
