panda8246 / LearnOpenGL-Own

A project for myself to fellow the LearnOpenGL
GNU General Public License v3.0
0 stars 0 forks source link

Cmake后获取Shader文件的问题 #1

Open panda8246 opened 3 years ago

panda8246 commented 3 years ago

目前是将src/shader/下的shader文件通过cmake的file命令复制到输出文件夹debug下

file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/src/shader/" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shader/")

src/shader是源目录,最终会在debug下的shader/存在源文件的复制。shader文件修改后,debug下的复制文件不会更新,需要重新cmake。

TODO :需要了解file的详细作用,动态更新shader。

panda8246 commented 3 years ago

good stuff:

https://stackoverflow.com/questions/36483801/cmake-softlink-resource-such-as-glsl-shaders-or-copy-each-complilation

https://cmake.org/cmake/help/latest/command/file.html#:~:text=file(%3CCOPY%7CINSTALL%3E%20%3Cfiles%3E...%20DESTINATION%20%3Cdir%3E

panda8246 commented 3 years ago

最终结合两个参考

用CMake在建置時複製檔案到輸出執行檔的目錄

用copy_directory替换上面的copy

` add_custom_target(

自定义名称

copy_shader_files
${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src/shader ${CMAKE_CURRENT_BINARY_DIR}/shader

) add_dependencies(LearnOpenGL copy_shader_files) `

实现在编译时自动复制Shader