Qmake - Xcode project generator
Posted on June 23rd, 2008 | by yan |
![]()
Since I can’t drop the topic of Qt on Mac OS X I will continue with the train ride. Qt’s qmake allows us to generate Xcode projects from .pro files. This is an awesome feature and I salute the Trolls for providing this capability to us. However, some time ago I noticed a minor issue with it and I wasn’t the only one. A colleague of mine Grant also noticed that searching through the project in Xcode takes quite a long time when searching through qmake generated Xcode projects. What happens is qmake adds the SDK that the project builds against and places it as a PBXFileReference into the “External Frameworks and Libraries” group. This causes each and every search request to go through the entire SDK directory structure and thus causing the poor search performance.
Since Grant and I do not have any time to waste on long searches… we shall patch qmake to attain our desired goal of fast project wide searches when working with qmake generated Xcode projects.
Just apply the below patch, rebuild qmake and voila… problem solved.
5 Responses to “Qmake - Xcode project generator”
By Grant on Jun 23, 2008 | Reply
Yeah, we rule. And be we I mean me for saying, “Yan this is too darned slow what’s going on?” and then Yan going off and fixing it.
What a team.
By Max Howell on Jul 19, 2008 | Reply
At Last.fm we have multiple pro files and a SUBDIR project. QMake fails here as it generates an XcodeProj for each pro file, which makes working on the whole product painful. In the end I made a separate target for qmkspec macx-xcode that just makes one big project with all the library sources compiled into the resulting executable.
This is fine for now, but when we start making our plugin framework it may require some preproc magic in the source code too.
Apologies that this isn’t relevant to your post. It’s just nice to finally find someone else who uses Xcode and QMake!
By Max Howell on Jul 19, 2008 | Reply
Also, your Captcha seems broken. Not only did I not have to fill it in. It didn’t show the Captcha image.
By Danny on Nov 19, 2008 | Reply
“Just apply the below patch, rebuild qmake and voila”
Erm…how? Not all of us are Unix gods
How do you actually apply this ‘patch’ and rebuild just qmake? I couldn’t even find the source for it.
By yan on Nov 20, 2008 | Reply
Danny,
You can run the “patch” command to apply the patch provided here. For example, suppose your Qt resides in /usr/local/qt-mac-opensource-src-4.3.3. You would need to change directory to /usr/local and run the following command:
patch -p0 < /path/to/patch.txt
If you are not comfortable with doing this, you can manually edit the code. Just look at the patch.txt file and you will notice that only a few lines changed. I added the following lines around the generation of the project:
bool is_sdk = (library.endsWith(”.sdk”));
if (!is_sdk)
{
…
…
…
}
The area should be easy to find my looking at the top of patch.txt. You can locate this area by finding the following line in that file:
bool is_frmwrk = (library.endsWith(”.framework”));
Also, the source for qmake is easy to find just by looking at the top of the patch file as well. Line 2 shows which file is being patched, in this case it is:
qt-mac-opensource-src-4.3.3/qmake/generators/mac/pbuilder_pbx.cpp
so qmake source code in located in /usr/local/qt-mac-opensource-src-4.3.3/qmake
after applying the patch you can change over to this directory and run make.
I hope this helps out. Please let me know if you have any additional questions.