Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [SOLVED] Conditions on Qt Project not working

    General and Desktop
    2
    3
    1534
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Cayan last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • C
          Cayan last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post