Archive for May, 2014

CMake Conditionals

16th May 2014

[edited 17/04/14]

CMake has many wonderful features. However, CMake’s if() command handles variables in a way that can often trip people up. In particular, comparison operators like STREQUAL try to interpret their arguments as variable names, and only treat them as actual strings if there is no matching variable. Combined with the fact that basically any string you can write in a CMake file is a valid variable name, this can lead to some subtle bugs.

This script highlights all the potential pitfalls I could think of. The “FATAL_ERROR” branches are the ones that will not be taken, but many of them are ones you might expect to be taken if you either didn’t have a solid grasp of how if() parses its arguments or if you weren’t aware of what variables had been defined.


KF5 Sprint in Barcelona

6th May 2014

Two weeks ago, I landed back in my home country after spending a long weekend in Barcelona for the KDE Frameworks 5 sprint. It was a tiring weekend, but fun and productive.

I arrived in the early evening of the first day, happening to reach the door of the Blue Systems office at about the same time as Kai Uwe Broulik. This was after the discussion about what tasks needed completing had happened, so we both were greeted with a board full of post-it notes. I snuck a few more onto the board when Kévin Ottens wasn’t looking, as there were some failing autotests that needed fixing before another release happened, and I felt we needed to have a proper discussion about where we were installing things (having seen that Kubuntu were patching the KDEInstallDirs module of Extra CMake Modules).

That first evening, I mostly committed some changes that I’d been waiting for approval on, and either finished or delegated the last few parts of the “removing references to KDE4” task that I’d been working on. We went out for a very nice dinner, and sometime after midnight, Kai, Mark Gaiser and I headed to the apartment we were sharing to sleep.

The next day, Kai set off early to see his old school choir, who happened to be on tour to Barcelona, and beat Mark and I to the office (we rocked up around 11am, having been breakfast-shopping before going back to the apartment to eat). I pinned people down for approval on several things I’d had sitting on my hard drive or on Review Board for a while, clearing out my backlog of “completed but not yet committed” tasks. This included a lot of improvements and clean-ups for Extra CMake Modules.

Most of Friday afternoon and evening, however, was spent trying to understand the KItemModels unit tests and figure out why one of the tests was failing. I eventually determined that the pattern of signal emission when moving rows around had probably changed between Qt4 and Qt5, and the fix was fairly simple. I also found time to apply at least a temporary fix to a KImageFormats unit test that was failing on i386, and take part in discussions on install paths (with David Faure and Aleix Pol) and the Framework metadata files (with Kévin, Aurélien Gâteau, and Aleix). I didn’t have the energy to join in the release cycle discussion, although I subsequently decided that Extra CMake Modules would tend to release in sync with Frameworks (largely because David Faure has kindly agreed to deal with the ECM release process if it does), but won’t necessarily have a new release for every Frameworks release.

The install paths discussion resulted in the decision that “kf5” (or, indeed, “kde5”) shouldn’t appear in paths that we expect applications to use (such as where applications install plugins for their own use) – application versions are not necessarily related in any way to KDE Frameworks versions. As a result, we altered a bunch of paths in KDEInstallDirs, and added some KF5-specific variables for the use of the frameworks themselves, as well as making sure some other framework-releated directories were properly versioned. Aleix and I worked through the resulting tasks throughout Saturday. One nice outcome of these changes was that we moved a step closer to deprecating KPluginLoader: it is no longer needed to find plugins installed using the variables in KDEInstallDirs, and other than that it mostly provides plugin versioning (as in a version number for the plugin or plugin interface), which could be upstreamed to QPluginLoader.

In the metadata file discussion, we decided to rename the metadata files from <framework>.yaml (eg: kconfig.yaml) to the more consistent metadata.yaml (which is easier for scripts to find). We also decided that these files would be the canonical location for information such as the maintainer, tier (an indication of a framework’s dependencies) and lifecycle (yet-to-be-released, actively developed, deprecated, no-longer-released), and so set out a list of fields they needed to contain. Kévin and Aurélien did most of the work of implementing these changes, I believe.

As well as dealing with install paths and other coinstallability issues, I spent part of Saturday adding a section to the KDE git manual called Advanced Git. This details how to merge history between repositories, including use of git-filter-branch. I’ve ended up doing a lot of these merges for KDE Frameworks as we’ve realised files have ended up in the wrong repository, and had to pick it up as I went along, learning from my mistakes. Hopefully this will make it easier for other people.

Having been noticably short of sleep on Saturday (getting into the office late doesn’t mean waking up late, and I’d only left the office at 2am on Friday night), I got an early night in, so I would be refreshed for Sunday, which mostly involved similar tasks to Saturday. We got all the coinstallability tasks done by early Sunday afternoon, and I spent the rest of the day working on the failing unit tests for the SoftImage PIC format plugin in KImageFormats. In the end, I completely rewrote the plugin using QDataStream, ensuring it would handle endianness correctly (which the old code emphatically did not), and that wasn’t finished until last Friday.

All in all, it was a successful sprint, and it was great to meet the people I’d been working with over the last several months. Bring on KDE Frameworks 5.0!