Qt 如何在pro文件中定义配置?

Qt 如何在pro文件中定义配置?,qt,qmake,Qt,Qmake,如何在pro文件中定义配置 默认情况下,我们有两个配置,调试和发布。我想添加2个其他配置,但不在pro.user中!在pro文件中如果我理解您的意思,您可以将所需内容添加到CONFIG变量中: CONFIG += user_setting ... user_setting: message( "compiling with user_setting" ) 请参阅其中谈到CONFIG变量的部分,尤其是在本节末尾附近。如果我理解您的意思,请将所需内容添加到CONFIG变量中: CONFIG +=

如何在pro文件中定义配置


默认情况下,我们有两个配置,调试和发布。我想添加2个其他配置,但不在pro.user中!在pro文件中

如果我理解您的意思,您可以将所需内容添加到
CONFIG
变量中:

CONFIG += user_setting
...
user_setting: message( "compiling with user_setting" )

请参阅其中谈到
CONFIG
变量的部分,尤其是在本节末尾附近。

如果我理解您的意思,请将所需内容添加到
CONFIG
变量中:

CONFIG += user_setting
...
user_setting: message( "compiling with user_setting" )

请参阅它在何处讨论
CONFIG
变量,尤其是在本节末尾附近。

您的问题有点不清楚。听起来可能您当前正在使用命令行中的“debug”和“release”进行构建,并且您希望添加类似的构建变体

如果是这样的话。。。其机制是
addExclusiveBuilds
。这里有一个例子。如果您不喜欢阅读qmake代码,我建议您不要乱来

TEMPLATE = app
SOURCES = main.cpp

# Adds two build variants.
# One of them builds the app with optimal compiler flags,
# the other one builds the app with support for collecting coverage data.
# For the first one, CONFIG will contain `optimized' and a Makefile.Optimized will be     generated.
# For the second, CONFIG will contain `coverage' and a Makefile.Coverage will be generated.
# There will also be a top-level Makefile which invokes both the sub-makefiles.
addExclusiveBuilds(optimized, Optimized, coverage, Coverage)

CONFIG(optimized, coverage|optimized) {
    message(I am in the optimized build variant)
    QMAKE_CXXFLAGS += -O3

    TARGET = myapp-optimized
}
else:CONFIG(coverage, coverage|optimized) {
    message(I am in the coverage build variant)
    QMAKE_CXXFLAGS += --coverage
    QMAKE_LFLAGS += --coverage

    TARGET = myapp-coverage
}
else {
    message(I am in the glue project which contains the build variants)

    # This will cause a `make' to build both optimized and coverage
    # variants by default.
    CONFIG += build_all
}

你的问题有点不清楚。听起来可能您当前正在使用命令行中的“debug”和“release”进行构建,并且您希望添加类似的构建变体

如果是这样的话。。。其机制是
addExclusiveBuilds
。这里有一个例子。如果您不喜欢阅读qmake代码,我建议您不要乱来

TEMPLATE = app
SOURCES = main.cpp

# Adds two build variants.
# One of them builds the app with optimal compiler flags,
# the other one builds the app with support for collecting coverage data.
# For the first one, CONFIG will contain `optimized' and a Makefile.Optimized will be     generated.
# For the second, CONFIG will contain `coverage' and a Makefile.Coverage will be generated.
# There will also be a top-level Makefile which invokes both the sub-makefiles.
addExclusiveBuilds(optimized, Optimized, coverage, Coverage)

CONFIG(optimized, coverage|optimized) {
    message(I am in the optimized build variant)
    QMAKE_CXXFLAGS += -O3

    TARGET = myapp-optimized
}
else:CONFIG(coverage, coverage|optimized) {
    message(I am in the coverage build variant)
    QMAKE_CXXFLAGS += --coverage
    QMAKE_LFLAGS += --coverage

    TARGET = myapp-coverage
}
else {
    message(I am in the glue project which contains the build variants)

    # This will cause a `make' to build both optimized and coverage
    # variants by default.
    CONFIG += build_all
}