How do I check for SDL2_ttf in CMakeLists.txt?

2019-05-27 02:34发布

问题:

I am currently writing an SDL2 program with the SDL2-ttf library and wanted to add a check for it in CMakeLists.txt. How do I do that?

I am using CMake 3.1.

回答1:

FindSDL_ttf.cmake is part of cmake 3.x just use

find_package(SDL_ttf REQUIRED)


回答2:

The FindSDL_ttf doesn't work with SDL2, so you'll have to use a third party option.

I've used this and it works: https://raw.githubusercontent.com/Deraen/ohj2710/master/cmake_modules/FindSDL2TTF.cmake

Just put it in a directory included by set(CMAKE_MODULE_PATH /path/to/file)

and then use it find_package(SDL2TTF)