如何安装SDL开发库,以便CMake可以找到它

时间:2015-05-06 01:07:19

标签: cmake sdl

我正在运行Windows,我想在一个地方安装SDL开发文件,以便find_package(SDL)正常工作。

我应该在PATH中包含部分内容还是什么?

编辑: 我创建了环境变量SDLDIR并将其设置为包含lib /和include /

的目录

Cmake输出:

cmake -G "Visual Studio 12 2013 Win64" ..
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler using: Visual Studio 12 2013 Win64
-- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64
-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found
-- Found Threads: TRUE  
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find SDL (missing: SDL_LIBRARY) (found version "2.0.3")
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindSDL.cmake:199 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "E:/Code/Projects/OpenGL-SDL/build/CMakeFiles/CMakeOutput.log".
See also "E:/Code/Projects/OpenGL-SDL/build/CMakeFiles/CMakeError.log".

的CMakeLists.txt:

project(OpenGL-Sample-SDL)
cmake_minimum_required(VERSION 2.8)

find_package(SDL REQUIRED)


include_directories(${SDL_INCLUDE_DIR})
link_libraries(PRIVATE ${SDL_LIBRARY})

add_executable(OpenGL-SDL main.cpp)

2 个答案:

答案 0 :(得分:1)

我在维基页面上读了一下,发现了一个小小的解决方法。我不认为它很完美,但现在还不错。

cmake -G "Visual Studio 12 2013 Win64" -D SDL_LIBRARY_TEMP=%SDLDIR%\lib\x64\SDL2.lib ..

这正确地找到了SDL2,虽然我遇到了另一个问题,但我会为它制作一个新主题。

答案 1 :(得分:0)

检查应该找到您的包的CMace模块的文档和来源

FindSDL.cmake包含以下文档注释:

# $SDLDIR is an environment variable that would correspond to the
# ./configure --prefix=$SDLDIR used in building SDL.  l.e.galup 9-20-02