2011-04-18 24 views

回答

4

你的問題有點不清楚。這聽起來像你可能正在用命令行中的「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 
} 
0

如果我明白你說什麼,你添加你想要的CONFIG變量:

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

qmake manual它談到了CONFIG變量,特別是近段的結束。

相關問題