gpt4 book ai didi

c++ - CMake:如何将 .obj 3d 模型添加到 C++ Visual Studio UWP 项目

转载 作者:行者123 更新时间:2023-11-30 04:56:54 24 4
gpt4 key购买 nike

我正在尝试在 cmake 构建中将 3d 模型添加到 Appx 的资源中。我已经成功地处理了大多数格式,但以 .obj 结尾的文件被视为已编译的目标文件。

cmake Visual Studio 生成器似乎总是将任何扩展名为 .obj 的文件视为目标文件,并将其添加到带有标记的 vcxproj 中。

有没有办法更改 cmake 使用的文件的内部类型?我可以指定此文件不是“EXTERNAL_OBJECT”吗?

将 VS_DEPLOYMENT_CONTENT 设置为 1 没有帮助。将它添加到 RESOURCES 属性没有帮助。

看起来这可能是 cmake 源代码本身的问题,它在检查任何其他标志或类型之前检查文件类型是否为 EXTERNAL_OBJECT,我不知道如何取消设置该类型。

最佳答案

根据 cmake gitlab repo 上的这个问题 https://gitlab.kitware.com/cmake/cmake/issues/18820 ,有一个 hacky 修复解决方案,但还没有“正确”的修复。

布拉德金:

As a very hacky not very futureproof workaround that abuses current implementation details, try:

get_property(loc SOURCE myfile.obj PROPERTY LOCATION)

set_property(SOURCE myfile.obj PROPERTY EXTERNAL_OBJECT 0)

The first line forces this code and therefore this code to run, causing CMake to initialize the EXTERNAL_OBJECT property earlier than it normally would. Once that is done then we can set the property back to 0.

A possible fix would be to teach the latter code (in CheckExtension) to not set the EXTERNAL_OBJECT property if it is already set. We can't change the default behavior of treating .obj files as objects to link, but we can at least make an explicit property setting work without the above hack.

我已确认这适用于我们解决方案中的 .obj 文件。

关于c++ - CMake:如何将 .obj 3d 模型添加到 C++ Visual Studio UWP 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52301883/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com