Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
If you ever need to create a project around a single C++ file (or just a few C++ files) in CMake, as you might for quick test cases, you might find it tedious to write a CMakeLists.txt file by hand every time. To make this easier, I've written a script called cmake-project that you can use to generate an initial CMakeLists.txt for you. Similar to qmake -project, it allows you to quickly create a project around a single or just a few C++ files. In addition, it automatically adds a link to Qt Widgets when the code uses QApplication.
A few special features that come with CMake are support for many languages (like Fortran, CUDA, and Objective-C), native support from many IDEs (Qt Creator and Visual Studio XCode), many active contributors, many out-of-the-box configuration checks, use of non-recursive make for faster build times, and out-of-the-box support for Ninja for even faster build times. These features are a few of the reasons why Qt 6 switched from QMake to CMake.
Add the cmake-project script on top of all these fantastic features and you can enjoy the only feature people miss from QMake while working in CMake. In turn, your productivity will be better than ever!
The cmake-project script is available for free, as part of KDToolBox:
https://github.com/KDAB/KDToolBox/tree/master/qt/cmake-project
Feel free to give it a try!
If you'd like to know more about working with CMake, we have a CMake and Qt video series on YouTube that might interest you.
About KDAB
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Upgrade your applications from Qt 5 to Qt 6 with KDAB’s migration services. Get a free migration assessment and join a hands-on workshop to prepare your team for a successful transition!
Learn more
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more
3 Comments
21 - Sept - 2021
Markus Liebe
Thanks, that comes in quite handy! My colleagues will love this ;-)
Best regards, Markus
21 - Sept - 2021
David Faure
I just added the feature of being able to choose the Qt version (5, 6, or none for pure C++ projects).
30 - Sept - 2021
Andrew Cunningham
Great for beginning CMake users!