C++ Adventures: QT5 and CMake

Lately I have been learning more and more about CMake, at first sight CMake looks like one of those build tools that you wouldn’t want to mess with because it can get quite messy when you start introducing conditions to your project.

I’ve been organizing the project structure of an application I’m working which I’m hoping to release this November. My main aim was to release it for Windows 10 which is the upcoming version of Windows set for summer. Personally after seeing the improvements of Windows 10 I can’t wait to use it myself.

That’s another subject to talk about later though. Configuring CMake to use QT5 isn’t hard, however if you are a novice like me with this build system then it becomes obvious that you have to research a bit more about it.

The first structure I came up for the project was this:

/ (root)
/Include (headers)
/Include/[modules] (headers)
/Sources/[modules] (headers)
/Tools/ (whatever scripts needs to be done, let’s say packaging)

Which means letting CMake recursively search each folder.

What’s been worrying me is that personally I want to separate the UI files from QT Designer from the sources files. I have yet to write a rule for that in CMake.

Why worry about project structures? Well, for one I know that sooner or later I will have to refactor and I don’t really fear refactoring. However, it becomes clear that if I want to keep working on this project I need to have folder structure that sucks less, simply put I don’t feel like wasting time moving files over and over again. Making the project modular also helps me separate the concerns of what a module should do and what it should provide rather than throwing everything in a /src folder.

After setting a basic structure I was able to compile the application. There’s still a lot more to be done though, such is development.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.