This is simple startup project using CMake for multidirectory C++ project with SDL, SDL_Image, GoogleTest and Github Workflows for automated tests run.
- Install Mingw-w64
- Install cmake
- Download SDL development library
- Download SDL image development library
- Rename
CMakeLists.txt.example
toCMakeLists.txt
- Replace
[PATH_TO_SDL]
inCMakeLists.txt
with path where you keep SDL source - Replace
[PATH_TO_SDL_image]
inCMakeLists.txt
with path where you keep SDL source
- Rename
.vscode/c_cpp_properties.json.example
to.vscode/c_cpp_properties.json
- Replace
[PATH_TO_SDL]
in.vscode/c_cpp_properties.json
with path where you keep SDL source - Replace
[PATH_TO_SDL_image]
in.vscode/c_cpp_properties.json
with path where you keep SDL source
- Set
prefix
,SDL2_PREFIX
,SDL2_EXEC_PREFIX
insdl2-config.cmake
in[PATH_TO_SDL]/lib/cmake/SDL2
directory to[PATH_TO_SDL]
- Replace
[PATH_TO_SDL_image]
inutils/sdl2_image-config.cmake.example
- Copy
utils/sdl2_image-config.cmake.example
to[PATH_TO_SDL_image]/SDL2_image-2.0.5/lib/x64/cmake/sdl2_image-config.cmake
(create folder if not exists)- Alternatively you can just rename
utils/sdl2_image-config.cmake.example
toutils/sdl2_image-config.cmake
and pointSDL2_image_DIR
inCMakeLists.txt
to utils folder
- Alternatively you can just rename
- Copy
SDL2.dll
,SDL2_image.dll
,libpng16-16.dll
,zlib.1.dll
tooutput
directory
- From root directory run command
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=True -G "MinGW Makefiles" .
- Run command
mingw32-make.exe
- Run executable
./output/game.exe
- For tests run executable
./output/test.exe
To build project from VSCode go to Terminal -> Run Build Task
To debug project in VSCode go to Run -> Start Debugging
or Run -> Start without Debugging
- Having separate
CmakeLists.txt
for Github Workflows is probably not the best solution. Although configuring SDL on Windows Workflow Machine seems like tedious task thats why i went with running build on Ubuntu machine with dedicated CmakeLists.txt (stored in.github/workflows/utils
) and installing required libraries with apt-get. It probably would be possible to make parameterized cmakelists that would handle all cases.