learosema / sdltest

Minimal C++ application using SDL2 with CMake

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDL2Test

This is a minimal C++ application using SDL2 with CMake.

It is based on the following resources:

Prerequisites

MacOS

Given you have brew and the XCode command line tools (xcode-select -install) You can install SDL2 for development via:

brew install cmake
brew install sdl2

Linux

sudo apt install libsdl2-dev cmake g++

Windows

  • Install cmake
  • Install the latest development archive for windows from the SDL2 releases page.
  • Unpack that somewhere
  • Configure cmake to find that directory

To configure CMake to find SDL2, use this configuration, name it sdl2-config.cmake and put it next to where you downloaded the development libraries. This is based on the blog linked above.

set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")

# Support both 32 and 64 bit builds
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
  set(SDL2_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x64/SDL2main.lib")
else ()
  set(SDL2_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2.lib;${CMAKE_CURRENT_LIST_DIR}/lib/x86/SDL2main.lib")
endif ()

string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)

About

Minimal C++ application using SDL2 with CMake

License:The Unlicense


Languages

Language:C++ 73.6%Language:CMake 26.4%