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

标签 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)

最佳答案

我在 wiki 页面上阅读了一些内容,发现了一个小的解决方法。我认为它并不完美,但目前还不错。

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

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

关于cmake - 如何安装 SDL 开发库以便 CMake 可以找到它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30065786/

相关文章:

c++ - cmake交叉编译boost链接错误

C++ 单元测试在运行所有测试时或在某个测试之后失败

android - 我如何找到要为 android studio 下载的 cmake

android - SDL 一直无法在 Android 上找到字体

c++ - 如何使用 SDL 修改像素?

textures - 如何将两个 SDL2 纹理混合为一个纹理?

c++ - cmake source_group 无效

android - 使用通过 CMAKE 构建的 Android NDK 时如何获取构建类型?

c - SDL 编写文本

sdl - 将 SDL 添加到我的路径