From c28b5a398520b71ea95f3160de29f59183dd3433 Mon Sep 17 00:00:00 2001 From: Jordan Halase Date: Mon, 30 Sep 2019 12:30:24 -0500 Subject: Build with CMake --- .gitignore | 1 + CMakeLists.txt | 7 +++++++ main.c | 2 +- readme.md | 15 +++++++-------- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..89a43d3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.6) +project(Asteroids) + +find_package(SDL2 REQUIRED) +include_directories(${SDL2_INCLUDE_DIRS}) +add_executable(Asteroids main.c) +target_link_libraries(Asteroids ${SDL2_LIBRARIES} m) diff --git a/main.c b/main.c index a80e1fb..2faeeda 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,7 @@ #include #include -#include +#include #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 diff --git a/readme.md b/readme.md index 87b2125..114a846 100644 --- a/readme.md +++ b/readme.md @@ -4,14 +4,13 @@ Simple Asteroids clone in C as an exercise in game development. * Requires [SDL2](https://libsdl.org) for input and drawing. -* Compiles with gcc or clang. Can compile on Windows with clang or mingw. Visual Studio is not supported. +* Compiles with gcc or clang. Can compile on Windows with clang or mingw. MSVC is not supported. -In order to compile, the SDL2 development libraries are needed. +## Building -* Debian, Ubuntu, Raspbian: `sudo apt install libsdl2-dev` +This project is built with [CMake](https://cmake.org). On Windows, CMake must be manually configured to locate the include and library paths for SDL2. -* Red Hat, Fedora, CentOS: `sudo yum install SDL2-devel` - -* Arch: `sudo pacman -S sdl2` - -* macOS (with [Homebrew](https://brew.sh)): `brew install sdl2` +Simplest way to build on most \*nix systems: + 1. `mkdir build && cd build` + 2. `cmake ..` + 3. `make` -- cgit v1.2.1