|
| 1 | + |
| 2 | +This repository contains CMake scripts for finding the `SDL2`, `SDL2_image` and |
| 3 | +`SDL2_ttf` libraries and headers. |
| 4 | + |
| 5 | +CMake itself comes with corresponding scripts for SDL 1.2, which hopefully in |
| 6 | +time will be updated for SDL2 and make this repo redundant. In the mean |
| 7 | +time, I'm putting them up here in case anyone else finds them useful. |
| 8 | + |
| 9 | +I've tested them on Linux and Mac OS using the Makefile and XCode targets. |
| 10 | +On Linux, you'll need the SDL2 development packages installed from your distro |
| 11 | +package manager. On Mac OS you'll need to install the development frameworks |
| 12 | +from the SDL website. |
| 13 | + |
| 14 | +##Usage |
| 15 | + |
| 16 | +In order to use these scripts, you first need to tell CMake where to find them, via |
| 17 | +the `CMAKE_MODULE_PATH` variable. For example, if you put them in a |
| 18 | +subdirectory called `cmake`, then in your root `CMakeLists.txt` add the line |
| 19 | + |
| 20 | +```cmake |
| 21 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${project_SOURCE_DIR}/cmake") |
| 22 | +``` |
| 23 | + |
| 24 | +where `project` is the name of your project. You can then use the packages |
| 25 | +themselves by adding |
| 26 | + |
| 27 | +```cmake |
| 28 | +find_package(SDL2 REQUIRED) |
| 29 | +find_package(SDL2_Image REQUIRED) |
| 30 | +find_package(SDL2_ttf REQUIRED) |
| 31 | +
|
| 32 | +include_directories(${SDL2_INCLUDE_DIR} |
| 33 | + ${SDL2_IMAGE_INCLUDE_DIR} |
| 34 | + ${SDL2_TTF_INCLUDE_DIR}) |
| 35 | +target_link_libraries(target ${SDL2_LIBRARY} |
| 36 | + ${SDL2_IMAGE_LIBRARIES} |
| 37 | + ${SDL2_TTF_LIBRARIES}) |
| 38 | +
|
| 39 | +``` |
| 40 | + |
| 41 | +or whatever is appropriate for your project. |
| 42 | + |
| 43 | +##Licence |
| 44 | + |
| 45 | +I am not the original author of these scripts. I found `FindSDL2.cmake` |
| 46 | +after some Googling, and hacked up the `image` and `ttf` scripts from the |
| 47 | +SDL1 versions that come with CMake. The original scripts, and my changes, |
| 48 | +are released under the two-clause BSD licence. |
| 49 | + |
| 50 | +##Bugs |
| 51 | + |
| 52 | +These scripts are provided in the hope that you might find them useful. They |
| 53 | +work for me and hopefully they'll work for you too. If you fix any |
| 54 | +issues with them then I'd appreciate a pull request so other |
| 55 | +users can get your fixes too, but that's up to you :-). |
| 56 | + |
| 57 | + |
0 commit comments