Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-11923

qmake ignores preprocessor conditional inclusion

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 4.6.2
    • Build tools: qmake
    • None
    • Linux

    Description

      Problem

      qmake searches the source files for includes, but does no proper preprocessing. This means that conditional inclusions will break things:

      main.cpp
      #include "foo.h"
      int main( int argc, char* argv[] ) {Foo f;}
      
      foo.h
      #ifndef FOO_H
      #define FOO_H
      class Foo { public: Foo(); };
      
      #ifdef MERGE
      #warning MERGE is on
      #include "foo.cpp" // Comment out this line and anything is fine.
      #endif // MERGE
      
      #endif // FOO_H
      
      foo.cpp
      #include "foo.h"
      
      Foo::Foo() {}
      

      Actual Results - of qmake

      Relevant part of created Makefile:

      SOURCES       = main.cpp
      OBJECTS       = main.o
      

      Expected Results - of qmake

      Relevant part of created Makefile:

      SOURCES       = foo.cpp \
              main.cpp
      OBJECTS       = foo.o \
              main.o
      

      Additional Information

      The key point is the following: If you comment out #include "foo.cpp"
      in foo.h you obtain the expected result, i.e. qmake adds foo.cpp
      to the SOURCES variable in the Makefile.

      Because the row with the statement #include "foo.cpp" is anyway
      excluded by the preprocessor, it should not make a difference to
      qmake if it is commented out (//) or not.


      The -project mode is affected by the problem as well:

      Actual Results - of qmake -project

      Relevant part of created profile.

      HEADERS += foo.h foo.cpp
      SOURCES += foo.cpp main.cpp
      

      Expected Results - of qmake -project

      Relevant part of created profile.

      HEADERS += foo.h
      SOURCES += foo.cpp main.cpp
      

      Attachments

        1. Makefile
          6 kB
        2. qmakebug1.0.0.tar.gz
          10 kB
        3. test.zip
          1.0 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              danbetz Daniel Betz
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: