Home » Code » qmake and the Info.plist File

qmake and the Info.plist File

posted by Andy Maloney

I use the Qt library and qmake to build my bloodstain pattern analysis software. qmake is a great tool for cross-platform development because it lets you use one relatively succinct description [a .pro file] to generate Xcode projects, MSVC projects, and makefiles. On the Mac OS X side of things, I use one qmake .pro file to generate three xcode projects: release, beta, and demo. My directory structure looks like this:

Example File Structure

Example File Structure

Overall this works well, but there’s an issue with the Info.plist file.

I have something like this in Example.pro:

The problem is that when qmake generates the Xcode project, it copies the Info.plist file specified using QMAKE_INFO_PLIST into the directory next to the Xcode project it’s generating.

Example Info.plist Copying

Example Info.plist Copying

This means that when I generate my three projects, it simply overwrites the other Info.plist files resulting the last one I generated being the active one. Then I have to copy over the correct one by hand every time I want to build a different project. Not ideal and prone to mistakes.

What I want to happen – and what I expected to happen when specifying QMAKE_INFO_PLIST in the .pro file – is for qmake to, well, use the one I specified for the project!

So how do we fix this? The only way I could figure out was to modify qmake itself. I found that someone had reported this issue – qmake: Using QMAKE_INFO_PLIST should modify the xcode project to reference it and not copy this file to Info.plist [QTBUG-2720], but it was closed and nobody had a solution, so I took a shot at it.

My solution does three things:

  1. Adds a warning if the file referenced in QMAKE_INFO_PLIST does not exist.
  2. Uses the name of the file in QMAKE_INFO_PLIST instead of always changing it to “Info.plist”.
  3. Adds PLIST_DIR which specifies where to put the copy of QMAKE_INFO_PLIST for building [copying is necessary because of substitution of @EXECUTABLE@ etc.]. This is analogous to RCC_DIR.

Here is the diff against Qt v4.7.3-2192-g1dd89b6, though I know it works against the 4.8 strain since I’m using that as well:

I’m certainly not an expert on the qmake code, so I have two questions for the more knowledgeable among you:

  1. In the output for INFOPLIST_FILE, I use the fixForOutput() function. Is this the correct function?
  2. I added PLIST_DIR in makefile.cpp so that the directory will be created. Is this the proper place to do this?

I hope someone else finds this useful!

Leave a Reply

Your email address will not be published. Required fields are marked *