CMake modules to find SDL2 and its extensions.
Usage • License • Acknowledgments
Add this repository as a submodule to your project.
git submodule add https://github.com/opeik/cmake-modern-findsdl2 cmake/sdl2
Include the new modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
Find the package you want to use.
find_package(SDL2 REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(SDL2_gfx REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_net REQUIRED)
Link against it.
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2 SDL2::TTF
SDL2::Image SDL2::Mixer SDL2::Net SDL2::Gfx)
If you're writing an application, link against SDL2::SDL2
. If you're writing
a library, link against SDL2::Core
instead.
This project is licensed under the ISC license. Please see the LICENSE.md
file for details.
- Thanks to aminosbh for creating similar cmake scripts which I referenced