![]() ![]() ![]() And of course you can define your own variables: for instance, I used my variable sources to gather all the source files for add_executable(). So instead of writing the name of the project ( qt-widgets-cmake) I just refer to the CMAKE_PROJECT_NAME variable. Set( CMAKE_AUTOUIC ON) message( "Looking for Qt.") # Qt modules () you're using in your applicationįind_package( Qt5 REQUIRED Widgets) if ( $ construction - that’s how you use variables in CMake. Set( CMAKE_AUTOMOC ON) # if you're using Widgets and editing. ![]() Set( CMAKE_INCLUDE_CURRENT_DIR ON) # run moc automatically Project( "qt-widgets-cmake") # find includes in the corresponding build directories Qt WidgetsĪnyway, here a project file for a Qt Widgets based application:Ĭmake_minimum_required( VERSION 3.10) # your project name Surprisingly, the simplest one turned out to be the one from the official Qt documentation - who would have thought, as usually it’s the other way around. Lots of examples from the internet didn’t work and were way too complex and overloaded in general. And having spent some time I’ve managed to create correct CMakeLists.txt files for both projects, although I can’t tell that it was very straightforward. I’ve never used CMake for anything before, so to get familiar with it I decided to create two very basic applications, one with Qt Widgets and another with Qt Quick. I tried it on Windows 10 with MSVC 2017, however it will work on other systems too. ![]() I also wanted to try Qt development with Visual Studio Code, and now is a good occasion for that. Let’s see then what it takes to switch from qmake to CMake with a couple of basic examples. So I guess we should start using CMake for building Qt applications as well. After numerous promises of how Qbs will be the Qt’s default build system, The Qt Company suddenly killed it, announced that qmake is a dead man walking too, and actually Qt is switching to CMake. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |