add submodule (built with cmake) in qbs project

不打扰是莪最后的温柔 提交于 2019-12-11 15:39:05

问题


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.

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 :)

Any help? Thanks!


回答1:


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];
        }
    }
}

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.



来源:https://stackoverflow.com/questions/49021295/add-submodule-built-with-cmake-in-qbs-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!