【发布时间】:2017-08-02 18:49:01
【问题描述】:
根据标题,CMake 无法找到我使用微软的vcpkg 工具通过CMakes find_package() 宏安装的SFML。
我已验证SFML 已安装在vcpkg 安装目录(~\vcpkg\installed\x86-windows)中。
此外,我还将vcpkg的工具链文件包含在CMakeSettings.json文件中。
具体错误是:
CMake Error at ~\CMakeLists.txt:40 (find_package):
Could not find a package configuration file provided by "SFML" (requested
version 2.4.2) with any of the following names:
SFMLConfig.cmake
sfml-config.cmake
CMakeSettings.json(简化 - 仅调试配置):
"name": "x86-Debug",
"generator": "Visual Studio 15 2017",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\build\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -v:minimal",
"variables": [
{
"name": "CMAKE_TOOLCHAIN_FILE",
"value": "C:\\Microsoft\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
}
]
CMakeLists.txt(也简化了):
cmake_minimum_required(VERSION 3.6)
project(Tempus)
add_subdirectory(src)
# Fails at this step
find_package(SFML 2.4.2 REQUIRED system window graphics)
include_directories(${SFML_INCLUDE_DIR})
add_executable(Tempus ${SRC})
target_link_libraries(Tempus ${SFML_LIBRARIES})
我不认为我错过了什么。 SFML 提供了一个findSFML.cmake,vcpkg 应该通过工具链文件自行处理(假设我已经正确理解了他们的文档)。我一定是错过了什么?
【问题讨论】:
-
'SFML' provides a 'findSFML.cmake'- 不,SFML 安装可能会提供SFMLConfig.cmake,但Find*.cmake脚本由 CMake 本身提供,或者与 您的项目 一起提供(通过已存在的脚本在您的源代码树中)。这并不能回答您的问题,而只是一个提示。 -
@Tsyvarev 感谢您的提示!似乎
vcpkg提供了文件和其他包括和链接的东西,但不提供findSFML.cmake文件。一旦找到SFML,它就会设置所有CMake SFML宏和常量。通过手动将findSFML.cmake文件添加到 CMake 模块目录,它解决了我的问题。您想添加您的评论作为答案吗? -
Your answer 解决了这个问题。你为什么把它删了?如果您担心抄袭,那么: 1. 评论 不是答案。 2.在大多数情况下,答案中的简单“谢谢”就足够了。 3. 你的回答不仅仅是评论。
-
好的,很酷。我担心抄袭。我已经取消删除它。谢谢:)
标签: visual-studio cmake sfml vcpkg