Building OS X Application Bundle on Snow Leopard (10.6) and Lion (10.7)

From TomahaWiki

Jump to: navigation, search

Contents

Installing Homebrew & Dependencies

ruby -e "$(curl -fsSL https://raw.github.com/gist/323731/39fc1416e34b9f6db201b4a026181f4ceb7cfa74)"
brew install git
brew update
brew install cmake pkgconfig qt qjson taglib boost attica
brew install --HEAD clucene

Building QTweetLib, libEchonest & Other Recent Dependencies

cd /usr/local
git remote add lfranchi git://github.com/lfranchi/homebrew.git # contains necessary hacks and additional deps
git fetch lfranchi
git checkout lfranchi/master
brew install qtweetlib libechonest jreen qca-ossl kde-phonon phonon-vlc quazip

Now you should revert back to the original Homebrew git repository:

git checkout master

Compiling Tomahawk

git submodule init ; git submodule update # required for QTweetLib in trunk currently
mkdir build && cd build
cmake -DCMAKE_CXX_FLAGS="-g -ggdb3" -DPHONON_INCLUDE_DIR=/usr/local/Cellar/kde-phonon/4.5.0/include -DPHONON_LIBRARY=/usr/local/Cellar/kde-phonon/4.5.0/lib/libphonon.dylib ..
make
open tomahawk.app

Troubleshooting

CMake fails to find something

QCA2

Just add the following to the "cmake .." line above after the "cmake" and before the ".."

-DQCA2_INCLUDE_DIR=/usr/local/Cellar/qca/2.0.2/lib/qca.framework/Headers

Submodule Update Issues

If submodules fail to update properly, do this

git submodule sync
git submodule update

Qt 4.7.3

If you installed Qt 4.7.3 bottle from Homebrew (i.e. brew install qt) you might see the following:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
QT_QTUITOOLS_INCLUDE_DIR (ADVANCED)

Just add the following to the "cmake .." line above after the "cmake" and before the ".."

-DQT_QTUITOOLS_INCLUDE_DIR=/usr/local/Cellar/qt/4.7.3/include

Updating Qt

After updating to a newer Qt version, you need to run the following commands to compile and link the dependencies against the new Qt:

cd /usr/local
brew cleanup
brew remove automoc4 qjson taglib attica libechonest jreen qtweetlib qca qca-ossl kde-phonon phonon-vlc
brew install automoc4 qjson taglib attica qca
git fetch lfranchi
git checkout lfranchi/master
brew install libechonest jreen qtweetlib qca-ossl kde-phonon phonon-vlc
git checkout master # revert back to normal brew
cd tomahawk
rm -rf build

Then start again from creating the build directory.

Runtime Issues

Jabber/Google Connection Problem

If you have recompiled or reinstalled Qt, you need to remove qca and qca-ossl:

brew remove qca qca-ossl

Then follow the instructions in the Homebrew Deps section of this guide to reinstall qca and qca-ossl.

The Alternatively Quick Route to cmake & Qt

Note that this will replace the toolchain in your path (the osx provided one) with the gcc/ld etc provided in the Qt SDK. I would strongly discourage following these instructions just to save a few hours over "brew install cmake qt" as it has side-effects that could affect compiling things unrelated to qt. These instructions are provided here for completeness.

CMake can take a long time to build. Qt can take an incredibly long time to build. (As in, most of a day.) Here's how to get pre-built packages installed and visible to the build system.

(We'll assume your brew cellar is in /usr/local/Cellar/ - please replace as appropriate.)

CMake

Download and install CMake. Make sure the cmake executable is in your path, then

mkdir -p /usr/local/Cellar/cmake/2.8.4/bin
brew link cmake

Qt

Download and run the online installer for the full Qt SDK. When it asks you what and where to install, put it somewhere convenient (I used /usr/local/QtSDK which is the path I'm using in the commands below) and choose a Custom install. The only thing you need here is the part of the tree named Development Tools -> Desktop Qt -> (LATEST VERSION). You can untick everything else, which will make it install much faster.

Then, assuming you're installing version 4.7.4 (otherwise, edit the numbers below):

mkdir /usr/local/Cellar/qt
ln -s /usr/local/QtSDK/Desktop/Qt/474/gcc /usr/local/Cellar/qt/474
brew link qt

Finally, add /usr/local/QtSDK/Desktop/Qt/474/gcc/bin to your $PATH so that CMake can find all the Qt tools.

(Much love to Poppy for the detective work here.)

Personal tools