如何在cmake中的资源文件更改上重建? [英] How to rebuild on resource file change in cmake?
本文介绍了如何在cmake中的资源文件更改上重建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在资源目录 Shaders中有一些着色器文件。我希望我的应用程序在构建之前每次在其中一个文件中进行更改时都将该文件夹复制到运行时目录。我该如何实现?
I have some shader files inside of a resource directory 'Shaders'. I want my app to copy this folder to the runtime directory everytime there are changes inside of one file in it before the build. How can I achieve this?
现在我在这里使用它:
add_custom_command(TARGET my_app PRE_BUILD
COMMAND rm ARGS -rf ${CMAKE_CURRENT_BINARY_DIR}/Shaders
COMMAND cp ARGS -a ${CMAKE_CURRENT_SOURCE_DIR}/my_app/Viewer/Shaders ${CMAKE_CURRENT_BINARY_DIR}
)
但这仅在我更改另一个文件所以需要内置文件时起作用,而不是着色器文件本身。我该怎么办?
But this does only work when I change another file so a built is needed, not the shader files themselves. What can I do?
推荐答案
我知道这是可行的:
file(GLOB shaders "${CMAKE_CURRENT_SOURCE_DIR}/my_app/Viewer/Shaders/*")
message(status Copy shaders)
foreach(shader ${shaders})
message(status "From ${shader}")
get_filename_component(outputFileName ${shader} NAME)
message(status "To ${CMAKE_CURRENT_BINARY_DIR}/Shaders/${outputFileName}")
configure_file(${shader} ${CMAKE_CURRENT_BINARY_DIR}/Shaders/${outputFileName} COPYONLY)
endforeach()
这篇关于如何在cmake中的资源文件更改上重建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文