How do I check for SDL2_ttf in CMakeLists.txt?

2019-05-27 02:08发布

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.

2条回答
欢心
2楼-- · 2019-05-27 02:51

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)

查看更多
祖国的老花朵
3楼-- · 2019-05-27 02:59

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

find_package(SDL_ttf REQUIRED)
查看更多
登录 后发表回答