我有兴趣为自己尝试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来说比较新,而我只是在尝试它,所以我很抱歉只是因为我误用了某些重要的功能或其中的某些内容。
答案 0 :(得分:2)
尝试在Windows上编译GLFW 3.2.1时遇到了同样的错误。问题是GLFW CMakeLists在“$ {GLFW_SOURCE_DIR} / CMake / modules”中使用了自己的FindVulkan.cmake,这看起来有点过时了。
从CMake发行版(3.10)中的FindVulkan.cmake中获取一些代码以修改GLFW文件按预期工作,并使用.lib文件的路径填充VULKAN_LIBRARY缓存var。