User:Tswindell/Qt Creator And Mer Integration

Introduction
The purpose of this article is to explain how to integrate Qt Creator from the Nokia Qt SDK with the Mer SDK, allowing you to create/build/deploy & run projects through Qt Creator. The methods documented here are currently a Work in Progress.

Requirements

 * 1) Installed Nokia Qt SDK (for recent Qt Creator with Maemo/MeeGo/Harmattan support)
 * 2) Installed Mer Platform SDK Platform_SDK
 * 3) Setup SB2 & Targets Platform_SDK_and_SB2
 * 4) Setup default SB2 target with: sb2-config -d 
 * 5) Have device running a Mer based product (can be an emulated device).

Qt Creator Hook Scripts
In order for Qt Creator to recognised the build environment provided by scratcbox2 inside the Mer SDK, we must create the below hook scripts for Qt Creator, which execute qmake and make inside the sbox2 environment.

/srv/mer/scripts/qmake
sdkroot="/srv/mer/sdks/sdk" sdkscript="${sdkroot}/mer-sdk-chroot" target=$($sdkscript exec sb2 sb2-show which /bin | sed 's/\/bin$//' | sed 's/^\/parentroot//') $sdkscript exec sb2 sh -c "'cd $PWD; qmake $@'" | sed "s/:\//:$(echo $target | sed 's/\//\\\//g')\//g"
 * 1) ! /bin/sh

Qt Creator uses the 'qmake' command to find out information about your target environments Qt versions and configuration. The above script when called acts as though it's being run directly in our sbox2 build environment, it uses the current sbox2 target and remaps the directory information to point to the correct place on the filesystem so QtCreator can find the proper include files and resources.

To make Qt Creator recognise our target development environment, goto: "Tools > Options > Build & Run > Qt Versions" click on "Add", use the file picker to select the above created "qmake" script from "/srv/mer/scripts". If everything went well, Qt Creator should recognise the Qt version. Now set the version name to something like "Mer SDK (SB2)".

/srv/mer/scripts/make
sdkroot="/srv/mer/sdks/sdk" sdkscript="${sdkroot}/mer-sdk-chroot" target=$($sdkscript exec sb2 sb2-show which /bin | sed 's/\/bin$//' | sed 's/^\/parentroot//') $sdkscript exec sb2 sh -c "'cd $PWD; make $@'"
 * 1) ! /bin/sh

Next we need to use the above script in our Projects' build configuration to replace the use of our systems' make command. This step has to be done on all projects that you want to build with your Mer SDK targets in Qt Creator. You'll have to do this step for all your new projects as well.

Load or create a new project in Qt Creator, click on "Projects" on the right hand vertical panel. Edit the build configuration to use our "Mer SDK (SB2)" target. If it's not in the drop down you may have to click the Add button and select it from there. Next, in the "General" section select the "Mer SDK (SB2)" target for the "Qt version" field.

Finally we need to tell Qt Creator to use our special "make" script instead of the system make command. To acheive this find the "Make" build step under the "Build Steps" section of the projects build configuration. Click Details, select our script as the "Override make" field value. Do the same for the "Clean" build step as well. Now our project is ready to build for your Mer target. :)

Deployment & Running on Device
TBD