我有一个 .pri 文件,它可以包含在库项目和应用程序项目中。其中的一些详细信息取决于当前的构建类型(lib 或应用程序)。
检测当前项目是可执行文件、静态库还是动态库的推荐方法是什么?
最佳答案
What is the recommended way to detect if the current project is either an executable, a static library or a dynamic library?
捆绑的脚本会检查TEMPLATE
和CONFIG
变量。下面是执行此类测试的示例代码:
defineReplace(projectType) {
contains(TEMPLATE, ".*lib") {
CONFIG(shared, static|shared): return("dynlib")
return("lib")
}
contains(TEMPLATE, ".*app"): return("app")
return("other")
}
# example usage
prj = $$projectType()
equals(prj, "app"): message("Building the application")
else: message("Doing something different")
关于qt - qmake中如何检测当前项目是应用程序、共享库还是动态库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59368841/