0

我正在将我的 Qt 库从 qmake 迁移到 qbs,并且我正在尝试找到一个体面的模板来帮助我了解简化所述库的构建和安装所需的参数。

目前,我的一个库的 qbs 文件如下所示:

import qbs

DynamicLibrary {
    name: "qparsingtoolkit";
    Depends {name: "cpp"}
    Depends {name: "Qt.core"}

    files: [
        "Headers/qparsingparameters.h",
        "Headers/qparsingtoolkit.h",
        "Headers/qparsingtoolkit_global.h",
        "Sources/qparsingparameters.cpp",
        "Sources/qparsingtoolkit.cpp",
    ]
}

安装比较简单。

我只想要一个放置在/usr/include/qconsoledesigner

.so安装在 /usr/share/qconsoledesigner

4

1 回答 1

2
DynamicLibrary {
    name: "qparsingtoolkit";

    Depends {name: "cpp"}
    Depends {name: "Qt.core"}

    qbs.installPrefix: "usr"

    files: [
        "Sources/qparsingparameters.cpp",
        "Sources/qparsingtoolkit.cpp",
    ]

    Group {
        name: "api_headers"
        files: [
            "Headers/qparsingparameters.h",
            "Headers/qparsingtoolkit.h",
            "Headers/qparsingtoolkit_global.h",
        ]
        qbs.install: true
        qbs.installDir: "include/qconsoledesigner"
    }

    Group {
        fileTagsFilter: ["dynamiclibrary", "dynamiclibrary_symlink"]
        qbs.install: true
        qbs.installDir: "share/qconsoledesigner" 
    }
}

请注意,目标二进制文件的安装在未来将变得更加简单;参见例如http://doc-snapshots.qt.io/qbs/qml-qbsconvenienceitems-dynamiclibrary.html#installDir-prop

正常的“qbs build”安装到构建目录内的安装根目录中。要“全局”安装,请按照“qbs build”和“sudo qbs install --no-build --install-root /”。

于 2018-07-24T17:19:34.883 回答