我正在使用VulkanMemoryAllocation
,这是一个仅限标题的库。我想使用 cmake 将它编译成一个静态库,但我最终得到一个空的 - 8 字节大小的 - 库文件,并且在链接时有很多未定义的符号。
这是相关部分CMakeList.txt
# The header with the implementation
add_library(VulkanMemoryAllocator STATIC VulkanMemoryAllocator-Hpp/vk_mem_alloc.h)
# The include path for a wrapper which uses above mentionned header
target_include_directories(VulkanMemoryAllocator PUBLIC VulkanMemoryAllocator-Hpp/)
# enable the actual implementation
target_compile_options(VulkanMemoryAllocator PRIVATE VMA_IMPLEMENTATION)
# consider this file as a C++ file
set_target_properties(VulkanMemoryAllocator PROPERTIES LINKER_LANGUAGE CXX)
编辑:我想做与此等效的操作:
clang++ -c -DVMA_IMPLEMENTATION -x c++ -o vk_mem_alloc.o ../lib/VulkanMemoryAllocator-Hpp/vk_mem_alloc.h && ar rc libvma.a vk_mem_alloc.o
但使用 CMake