0

My setup:
I am creating and updating a form.ui file in Qt Designer, and using the Makefile generated by qmake. Using form.ui, make correctly generates ui_form.h, which is included in myWidget.cc.

The problem:
When form.ui is updated, make correspondingly regenerates ui_form.h. However, myWidget.o is not regenerated and thus the UI updates are not reflected in the recompiled application. On inspecting the Makefile, it turns out that the myWidget.o rule has no dependency on ui_form.h.

The question:
How can I force qmake to include the required dependency in the Makefile it generates?
Note: As the Makefile is auto-generated each time qmake is run, a manual edit of the Makefile is only a temporary solution which I would rather avoid.

Related:
-- This question identifies a similar problem but is still open. The replies do not sufficiently explore the problem (narrow it down to the missing Makefile dependency) and the solutions given do not work.
-- There is a discussion on adding dependencies to the Makefile here but this question, too, is still open and the scenario is different from mine.

Community
  • 1
  • 1
wsaleem
  • 594
  • 8
  • 25
  • 1
    Have you re-run qmake to re-generate the makefile? I have in the past had issues where I changed the code just enough to require a re-run of qmake, but not quite enough to cause the old makefile to trigger the re-run. (I don't remember exactly how I did it, though.) – jwernerny Sep 25 '12 at 14:29
  • And does your myWidget.cc actually #include, directly or indirectly, ui_form.h, in order for qmake to have a dependency to detect? – Clare Macrae Sep 25 '12 at 22:23

1 Answers1

0

I also had the problem that the myWidget.o rule did not list ui_form.h as a dependency in the makefile. In my case ui_form.h was an indirect dependency (myWidget.h includes ui_form.h).

For Qmake to generate makefiles that include header files as dependencies (direct or indirect inclusion), the INCLUDEPATH and DEPENDPATH need to be properly set (here).

Makefile

release/tmp/myWidget.o: src/source/myWidget.cpp src/source/myWidget.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/tmp/myWidget.o src/source/myWidget.cpp

Project.pro

INCLUDEPATH += src/header
DEPENDPATH += src/header

CONFIG += debug_and_release

CONFIG(debug, debug|release) {
     DESTDIR      = debug
     RCC_DIR      = debug/tmp
     OBJECTS_DIR  = debug/tmp
     UI_DIR       = debug/tmp
     MOC_DIR      = debug/tmp
     INCLUDEPATH += debug/tmp
     DEPENDPATH  += debug/tmp
} else {
     DESTDIR      = release
     RCC_DIR      = release/tmp
     OBJECTS_DIR  = release/tmp
     UI_DIR       = release/tmp
     MOC_DIR      = release/tmp
     INCLUDEPATH += release/tmp
     DEPENDPATH  += release/tmp
}

Makefile

release/tmp/myWidget.o: src/source/myWidget.cpp src/source/myWidget.h \
                        release/tmp/ui_form.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o release/tmp/myWidget.o src/source/myWidget.cpp
Community
  • 1
  • 1
Florian Boehmak
  • 431
  • 4
  • 20