在qbs项目中添加子模块(使用cmake构建)

问题描述 投票:0回答:1

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

我不认为从cmakeqbs迁移所有子模块构建系统是一个好主意,因为这意味着我必须迁移子模块的子子或子模块的sub子:)

有帮助吗?谢谢!

cmake add subdirectory qbs
1个回答
0
投票

要引入使用不同工具构建的项目,您需要某种包装器。例如,假设您的cmake子项目是一个库,您可以写这个(未经测试):

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的构建目录中。如果事实证明存在合​​理的抽象级别,那么将来可能会有这种方便的功能。

© www.soinside.com 2019 - 2024. All rights reserved.