在qbs项目中添加子模块(使用cmake构建) [英] add submodule (built with cmake) in qbs project

查看:276
本文介绍了在qbs项目中添加子模块(使用cmake构建)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 cmake 来构建我的项目,我希望将来迁移到 qbs 。我有一些来自github的开源子模块,这些子模块当前使用 cmake 构建,并包含在我的项目中,使用 cmake add_subdirectory
我尝试研究,但是在qbs中找不到 add_subdirectory 的替代方案。

I'm using cmake to build my project now and I want to migrate to qbs in the future. I have some opensource sub-modules from github, which are currently built with cmake, and are included in my project using cmake's add_subdirectory. I've tried to research but found no alternatives of add_subdirectory in qbs.

我不知道t认为将所有子模块构建系统从 cmake 迁移到 qbs 是一个好主意,因为这意味着我必须进行迁移子模块的子模块或子模块的子模块:)

I don't think migrating all sub-modules build system from cmake to qbs is a good idea because that means I have to migrate sub of sub-modules or sub of sub of sub-modules as well :)

有帮助吗?谢谢!

推荐答案

要引入使用其他工具构建的项目,您需要某种包装。例如,假设您的cmake子项目是一个库,则可以编写以下内容(未经测试):

To pull in projects built with a different tool, you'll need some sort of wrapper. For instance, assuming your cmake sub-project is a library, you could write this (untested):

Product {
    type: ["dynamiclibrary"]
    Group {
        files: ["subdir/CMakeLists.txt"]
        fileTags: ["cmake_project"]
    }
    Group {
        files: ["subdir/*"]
        excludedFiles: ["subdir/CMakeLists.txt"]
        fileTags: ["cmake_sources"]
    }
    Rule {
        inputs: ["cmake_project"]
        auxiliaryInputs: ["cmake_sources"]
        Artifact {
            filePath: ... // Whatever cmake produces
            fileTags: ["dynamiclibrary"]
        }
        prepare: {
            var cmd = new Command("cmake", [/*cmake arguments*/]);
            cmd.description = "building cmake project xyz";
            cmd.workingDirectory = product.sourceDirectory + "/subdir";
            return [cmd];
        }
    }
}

您可能应该调整cmake调用,以便生成的二进制文件最终出现在qbs的build目录中。
如果事实证明存在合​​理的抽象级别,将来可能会为此类事情提供便利功能。

You should probably tweak the cmake call so that the generated binaries end up in qbs's build directory. There might be convenience functionality for this sort of thing in the future, if it turns out that there's a sensible abstraction level.

这篇关于在qbs项目中添加子模块(使用cmake构建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆