Created
November 20, 2024 03:57
-
-
Save Zenger/146dd45d057b2b75bf6185c9094a099e to your computer and use it in GitHub Desktop.
Hassle free SDL2 CMake config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In this example we assume mingw32 and x86_64-w64-mingw32 SDL2 is used | |
# In your main.cxx file make sure to use this macro before including SDL2 header or you'll get issues | |
# define SDL2_MAIN_HANDLED | |
# include <SDL2/SDL.h> | |
cmake_minimum_required(VERSION 3.22) | |
project(YourProject) | |
set(CMAKE_CXX_STANDARD 14) | |
set(SDL2PATH "C:/Your/Path/To/SDL2-2.30.9/x86_64-w64-mingw32") | |
set(CMAKE_PREFIX_PATH "${SDL2PATH}/lib/cmake/SDL2") | |
find_package(SDL2 REQUIRED) | |
include_directories(${SDL2_INCLUDE_DIRS}) | |
add_executable(YourProject main.cpp) | |
target_link_libraries(YourProject ${SDL2_LIBRARIES}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment