cmake add_custom_command永远不会运行

发布于 2025-02-01 19:45:21 字数 1466 浏览 2 评论 0原文

我的问题与 cmake” /a>

但是指定的答案无法解决我的问题,也是针对较新版本的Cmake(3.20),

我希望每次阴暗器源更改时都将某些文件(着色器文件)复制到可执行的目录中,

所以我有CMAKE中的以下代码:

add_custom_command(
    OUTPUT ${CMAKE_BINARY_DIR}/Shaders.txt
    COMMAND ${CMAKE_COMMAND} -E echo "Actually Copying shaders"
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets/ $<TARGET_FILE_DIR:Editor>/assets
    COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/Shaders.txt
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/assets
)

add_custom_target(CopyShaders ALL DEPENDS ${CMAKE_BINARY_DIR}/Shaders.txt)

据我了解,现在将始终构建CopyShaders(因为它总是过时的),但是Shaders.txt只能构建一次(更改着着色器源后),之后它开始了迄今为止,

我正在尝试使用cmake构建目标检查员 - 构建构建 - 目标copyshaders

如果我使用的是mingw,则“实际上复制着着色器”就永远不会打印,如果存在着色器.txt.txt ,即使我使用的MSVC使用了包含着色器的资产文件夹已修改

,我也会在终端上获取以下警告:

 warning MSB8064: Custom build for item "D:\Acads\Programming\opengl\SummerOfCode\build\CMakeFiles\05fb3856b7a5e1f6ce1ea66ca9091779\Shaders.txt.rule" succeeded, but specified dependency "d:\acads\programming\opengl\summerofcode\editor\assets" does not exist. This may cause incremental build to work incorrectly. [D:\Acads\Programming\opengl\SummerOfCode\build\Editor\CopyShaders.vcxproj]

同样,我确实有存在的文件夹

My question is very similar to cmake: add_custom_command / add_custom_target ignoring dependency

But the answer specified does not solve my issue, and also it is for a newer version of cmake (3.20)

I want some files (shader files) to be copied to the executable directory every time the shader source changes

So I have the following code in cmake:

add_custom_command(
    OUTPUT ${CMAKE_BINARY_DIR}/Shaders.txt
    COMMAND ${CMAKE_COMMAND} -E echo "Actually Copying shaders"
    COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets/ 
lt;TARGET_FILE_DIR:Editor>/assets
    COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/Shaders.txt
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/assets
)

add_custom_target(CopyShaders ALL DEPENDS ${CMAKE_BINARY_DIR}/Shaders.txt)

Now, as I understand, CopyShaders will always be built (since it is always out of date), but Shaders.txt should only be built once (after the shader source is changed), after which it is up to date

I'm trying to build the target CopyShaders using cmake --build build --target CopyShaders

If I'm using MinGW, then "Actually copying shaders" never gets printed if Shaders.txt is present, even if the assets folder containing the shaders has been modified

If I'm using MSVC, I get the following warning on the terminal:

 warning MSB8064: Custom build for item "D:\Acads\Programming\opengl\SummerOfCode\build\CMakeFiles\05fb3856b7a5e1f6ce1ea66ca9091779\Shaders.txt.rule" succeeded, but specified dependency "d:\acads\programming\opengl\summerofcode\editor\assets" does not exist. This may cause incremental build to work incorrectly. [D:\Acads\Programming\opengl\SummerOfCode\build\Editor\CopyShaders.vcxproj]

Again, I do have the folder existing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮倦 2025-02-08 19:45:21

我认为它的

依赖性仅应为输入文件,而不是

用内部 /资产的所有文件替换它的文件夹

I figured it out

DEPENDS should only take as input files, not folders

Replacing it with all the files inside /assets works

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文