两个项目,一个CppApplication和一个DynamicLibrary,将如何重用在基础产品项目中定义的属性?我看起来继承是一种解决方案,但是检查https://doc.qt.io/qbs/language-introduction.html#reusing-project-file-code并没有帮助。我想要这样的东西:
// common.qbs ------------------------------------
Product
{
Properties {
condition: qbs.toolchain.contains("clang")
cpp.defines: ["COMPILER_CLANG"]
}
Properties {
condition: qbs.toolchain.contains("gcc")
cpp.defines: ["COMPILER_GCC"]
}
Group {
name: "Common files"
files: [
"common.cpp",
"common.hpp",
]
}
}
// project.qbs ------------------------------------
import "common.qbs" as Common
// app.qbs
CppApplication <inherits> Common
{
cpp.defines: outer.concat("APP")
}
// dll.qbs
DynamicLibray <inherits> Common
{
cpp.defines: outer.concat("DLL")
}发布于 2021-04-03 23:38:09
没有多重继承,所以基本上你有两个选择:要么在两个产品都知道的项目中声明属性(例如顶级项目),要么使用特定于项目的模块。
https://stackoverflow.com/questions/66931523
复制相似问题