PDA

View Full Version : Qmake for subdirs w/ custom makefile name



Frank J. Lhota
8th June 2009, 14:58
I'm working on a Qt project which uses the qmake subdirs template to create one makefile for building everything. Recently, the merger of two projects has resulted in some non-Qt code being added to our Qt subdirectories, and with this code came makefiles. Needless to say, I'm not happy with this situation, but we're required to live with this. Among other problems, we now have a name conflict from trying to create a Makefile in each of our subdirectories, since we now have a file with that name in Configuration Management.

One way to deal with this situation is to have a custom name for the Makefile that would be used for our Qt development project, e.g. "makefile_myproj". I know how to modify the qmake app and lib project files to produce a makefile with a given name. What I'm not sure how to do is how to produce a qmake subdirs project file that will use a given alternative makefile name in each of the subdirectories, .i.e. I want each "make" in the subdirectories to use the make file with our custom name, instead of Makefile. What's the best way to go about this?

QbelcorT
10th June 2009, 00:59
Hi
I was in the same situation as you. Maybe there is an easier way, however it worked out for me
In each directory you need a .pro file, so say for example my main (root, project) directory is called projectdir. You would 'make' from this directory, and all subdirectory folders will be made. Just remember to use a subdir template in the directory without source code, and an app template in the directory with your sources. The result would be a makefile in each directory and the projectdir pointing to the directories to be made.
Example:
/projectdir
../source1dir
../source2dir
../librarydir
(put this pro in the projectdir)
TEMPLATE = subdirs
SUBDIRS = source1dir source2dir librarydir

source1dir,source2dir,librarydir each contains a pro file with my cpp/h files and whatever else.
Edit: After reading your post again you said custom makefile name. I don't see the need for using a custom makefile. Put your build requirements in the pro file. (sources/headers, build, link commands) and then qmake will 'build' the makefile for you. I had a custom makefile, then I decided not to use it, and just put my sources in the pro file. Its much cleaner.