[Qt-interest] Makefile duplicated rule
Jardel Weyrich
jweyrich at gmail.com
Sat Jan 30 10:25:20 CET 2010
Having a directory structure of source files, and at least 2 of these
files with the same name, but in distinct directories, causes a rule
conflict on the Makefile generated by qmake.
>From what I see, it occurs because qmake produces compiling rules
using a prefix defined by OBJECTS_DIR plus the original name of the
source file, discarding its directory name.
For example, this hypothetical project:
OBJECTS_DIR = obj/
SOURCES = x/test.c y/test.c
Would generate a Makefile with:
OBJECTS = obj/test.o obj/test.o
obj/test.o: x/test.c
obj/test.o: y/test.c <-- note the duplicated rule
But ideally, at least in this case, it should generate:
OBJECTS = obj/x/test.o obj/y/test.o
obj/x/test.o: x/test.c
obj/y/test.o: y/test.c
To make it work properly with a custom Makefile, I'd do:
OBJECTS_DIR = obj/
SOURCES = x/test.c y/test.c
OBJECTS = $(addprefix $(OBJECTS_DIR)/, $(addsuffix .o, $(basename ${SOURCES})))
And the compiling rules would look like:
$(OBJECTS_DIR)/%.o: %.c
So, is there any way to get this behaviour directly from the .pro?
Changing file names is unacceptable for me.
I didn't find any document covering the topic. Maybe I'm missing something.
I appreciate your help.
--
jardel
More information about the Qt-interest-old
mailing list