gpt4 book ai didi

cmake - 为什么 VULKAN_LIBRARY 设置为 VULKAN_LIBRARY-NOTFOUND 而 VULKAN_FOUND 为 TRUE?

转载 作者:行者123 更新时间:2023-12-02 03:10:21 27 4
gpt4 key购买 nike

我有兴趣亲自尝试 Vulkan,但我很难让 CMake 可靠地链接到它。我决定使用 CMake 的 FindVulkan module ...或者至少我认为它应该如何运作。我是这样做的:

# Hey CMake. Look for Vulkan.
find_package(Vulkan REQUIRED)

# Alright, no errors? Tell me what you found!
message("Vulkan found? " ${VULKAN_FOUND})
message("Alright, where is it? " ${VULKAN_LIBRARY})
message("And I can include it? " ${VULKAN_INCLUDE_DIR})

稍后在文件中:

# Let's make a library and link vulkan
include_directories(${VULKAN_INCLUDE_DIR})
add_library(myLib myLib.cpp myLib.h)
target_link_libraries(myLib ${VULKAN_LIBRARY})

所以,我得到了结果!首先,我的 CMake 输出:

Vulkan found? TRUE
Alright, where is it? VULKAN_LIBRARY-NOTFOUND
And I can include it? C:/VulkanSDK/1.0.65.1/Include
-- Could NOT find Vulkan (missing: VULKAN_LIBRARY)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Using Win32 for window creation
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
VULKAN_LIBRARY (ADVANCED)
linked by target "TOVE" in directory C:/Users/User/Desktop/TOVE

奇怪,看起来您找到了我的包含目录,但找不到我的库。中间的消息实际上是GLFW。我把它们留在里面以防万一它们意味着更多的东西。最后,CMake 因错误而停止。

一些额外的测试表明,${VULKAN_LIBRARIES}${VULKAN_INCLUDE_DIRS} 均为空白。正如预期的那样,将它们替换为单独的对应项会使 Visual Studio 2017 对我的 vulkan/vulkan.h 包含感到困惑。

我在互联网上找不到任何有人获得 VULKAN_LIBRARY-NOTFOUND 的案例,但可能有另一个库也存在类似问题。为什么我在这里只找到一半的信息?这是 Vulkan 或 CMake 的问题,还是我真的不擅长使用 CMake 编写。我对 CMake 比较陌生,我只是在尝试它,所以如果只是我误用了一些重要功能或其中的某些内容,我深表歉意。

最佳答案

我在 Windows 上尝试编译 GLFW 3.2.1 时遇到了同样的错误。问题是 GLFW CMakeLists 在“${GLFW_SOURCE_DIR}/CMake/modules”中使用自己的 FindVulkan.cmake,这似乎有点过时。

从 CMake 发行版 (3.10) 内的 FindVulkan.cmake 中获取一些代码来修改 GLFW 文件,该文件按预期工作,并且 VULKAN_LIBRARY 缓存变量填充了 .lib 文件的路径。

关于cmake - 为什么 VULKAN_LIBRARY 设置为 VULKAN_LIBRARY-NOTFOUND 而 VULKAN_FOUND 为 TRUE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48014518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com