[SOLVED] Conditions on Qt Project not working



  • Using:
    @contains(CONFIG, value)@

    implies in the same output.

    @#-------------------------------------------------

    Project created by QtCreator 2013-07-02T15:18:36

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = untitled
    TEMPLATE = app

    CONFIG += TEST1
    #CONFIG += TEST2

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    contains(CONFIG, TEST1)
    {
    warning(test1)
    DEFINES += TEST1
    }

    TEST2
    {
    warning(test2)
    DEFINES += TEST2
    }

    warning($$CONFIG)
    warning($$DEFINES)
    @

    qMake output:
    @16:11:43: Running steps for project untitled...
    16:11:43: Starting: "C:\Qt\5.0.2\mingw47_32\bin\qmake.exe" untitled\untitled.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug"
    Project WARNING: test1
    Project WARNING: test2
    Project WARNING: lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl debug_and_release debug_and_release_target precompile_header copy_dir_files release shared rtti qpa win32 mingw gcc debug declarative_debug qml_debug TEST1
    Project WARNING: UNICODE TEST1 TEST2
    Project WARNING: test1
    Project WARNING: test2
    Project WARNING: lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl debug_and_release debug_and_release_target precompile_header copy_dir_files release shared rtti qpa win32 mingw gcc debug declarative_debug qml_debug debug DebugBuild Debug build_pass TEST1
    Project WARNING: UNICODE TEST1 TEST2
    Project WARNING: test1
    Project WARNING: test2
    Project WARNING: lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl debug_and_release debug_and_release_target precompile_header copy_dir_files release shared rtti qpa win32 mingw gcc debug declarative_debug qml_debug release ReleaseBuild Release build_pass TEST1
    Project WARNING: UNICODE TEST1 TEST2@

    DEFINES on Makefile.Debug:
    @DEFINES = -DUNICODE -DTEST1 -DTEST2 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN@

    DEFINES on Makefile.Release:
    @DEFINES = -DUNICODE -DTEST1 -DTEST2 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN@

    Any ideas?


  • Lifetime Qt Champion

    Hi,

    You should put the { on the same line as the condition:
    @contains(CONFIG, TEST1) {
    warning(test1)
    DEFINES += TEST1
    }
    @

    Otherwise it starts a new series of instructions hence your result.



  • It worked, thank you. I'd never thought that was the issue.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.