CMake 未找到 SDL

CMake 未找到 SDL

我正在构建cmake使用 SDL 的应用程序。但此代码显示未找到 SDL:

find_package(SDL)
find_package(SDL_mixer)
find_package(SDL_image)
find_package(SDL_ttf)
...
if( SDL_FOUND STREQUAL "YES" )
    MESSAGE( STATUS "SDL FOUND: " ${SDL_INCLUDE_DIR} " : " ${SDL_LIBRARY} )
    link_directories( ${SDL_LIBRARY} )
else( SDL_FOUND STREQUAL "NO" )
    MESSAGE( STATUS "SDL NOT FOUND: " ${SDL_INCLUDE_DIR} " : " ${SDL_LIBRARY} )
endif( SDL_FOUND STREQUAL "YES" )

打印这个奇怪的消息:

-- SDL NOT FOUND: /usr/include/SDL : /usr/lib/x86_64-linux-gnu/libSDLmain.a/usr/lib/x86_64-linux-gnu/libSDL.so-lpthread

据我检查,/usr/include/SDL存在并包含所有必需的标头,并且库文件(.a.so)位于/usr/lib/x86_64-linux-gnu。出了什么问题?

UPD:STREQUAL通过简单的布尔检查替换后,我可以看到它:

-- SDL FOUND: /usr/include/SDL : /usr/lib/x86_64-linux-gnu/libSDLmain.a/usr/lib/x86_64-linux-gnu/libSDL.so-lpthread
CMake Warning (dev) at CMakeLists.txt:55 (link_directories):
  This command specifies the relative path

    -lpthread

  as a link directory.

  Policy CMP0015 is not set: link_directories() treats paths relative to the
  source dir.  Run "cmake --help-policy CMP0015" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

make失败了:

fatal error: SDL.h: No such file or directory

相关内容