PDA

View Full Version : qmake: create a dependency to an arbitrary file.



33333
28th June 2014, 04:46
Hi,

I want to create a dependency between a file in my project and an arbitrary other file that may or may not be in the project. Say for example foo.cpp is dependent /etc/passwd. This is pretty much basic `make` but I can't figure out how to do this from qmake.

To clarify; qmake will generate a makefile with the following lines:


...
all: Makefile $(TARGET)

$(TARGET): $(OBJECTS)
...

I want to add an arbitrary dependency to $(TARGET). So its becomes:


...
all: Makefile $(TARGET)

$(TARGET): $(OBJECTS) /etc/passwd
...

Thanks.

ChrisW67
28th June 2014, 06:49
Either PRE_TARGETDEPS or POST_TARGETDEPS:


TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
PRE_TARGETDEPS += doit_before
POST_TARGETDEPS += doit_after

# Input
SOURCES += main.cpp

generates:


...
all: Makefile $(TARGET)

$(TARGET): doit_before $(OBJECTS) doit_after
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
...

and if doit_before or doit_after are files changing them has the desired effect of rebuilding the target.

33333
28th June 2014, 07:21
To easy! Thx.