valdemar-const / cmake-modern-findsdl2

Modern CMake modules to find SDL2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


sdl2-logo
CMake Modern FindSDL2

CMake modules to find SDL2 and its extensions.

UsageLicenseAcknowledgments

Usage

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.

License

This project is licensed under the ISC license. Please see the LICENSE.md file for details.

Acknowledgments

  • Thanks to aminosbh for creating similar cmake scripts which I referenced

About

Modern CMake modules to find SDL2

License:ISC License


Languages

Language:CMake 100.0%