【发布时间】:2020-03-17 11:42:32
【问题描述】:
到目前为止,我已经安装了 MinGW、CMake 和 Vulkan SDK。我还根据this answer 下载了 GLFW 预编译的二进制文件、GLM 和 PkgConfig。然后我在 CLion 中创建了一个 CMake 项目。这是 CMakeLists.txt 的内容(我从here 得到的):
cmake_minimum_required(VERSION 3.16)
project(VulkanTest)
set(CMAKE_CXX_STANDARD 17)
add_executable(VulkanTest main.cpp)
find_package(Vulkan REQUIRED)
target_include_directories(${PROJECT_NAME} PUBLIC ${Vulkan_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} Vulkan::Vulkan)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLM REQUIRED glm)
include_directories(${GLM_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLM_LIBRARY_DIRS})
find_package(glfw3 3.2 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLFW_LIBRARIES})
错误信息如下:
CMake Error at CMakeLists.txt:15 (find_package):
By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glfw3", but
CMake did not find one.
Could not find a package configuration file provided by "glfw3" (requested
version 3.2) with any of the following names:
glfw3Config.cmake
glfw3-config.cmake
Add the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or set
"glfw3_DIR" to a directory containing one of the above files. If "glfw3"
provides a separate development package or SDK, be sure it has been
installed.
我还尝试将 find_package(glfw3 3.2 REQUIRED) 替换为 pkg_search_module(GLFW REQUIRED glfw3),如 GLFW website 所述,但我收到错误“None of找到所需的'glfw3'”和“没有找到所需的'glm'”。
【问题讨论】:
-
欢迎来到 Stack Overflow!您是否尝试过消息中的说明?有没有尝试将glfw3的安装目录添加到
CMAKE_PREFIX_PATH变量中? -
@squareskittles 我该怎么做?
-
您可以在运行时将此变量传递给
cmake。请看this的回答。 -
@squareskittles 我添加了 -DCMAKE_INSTALL_PREFIX 和 -DCMAKE_PREFIX_PATH 并将它们指向包含文件的目录,但我收到相同的错误。