[Development] Build system for Qt 6

Kyle Edwards kyle.edwards at kitware.com
Fri Dec 7 23:06:01 CET 2018


On Fri, 2018-12-07 at 22:39 +0100, Christian Ehrlicher wrote:
> It's using QtCore and QtGui by default, the rest must be specified
> on 
> the command line: qmake -project QT += "widgets network"
> will add the line 'QT += widgets network' to the pro file (*)
> Therefore my idea with the template
> cmake -project qt -modules widgets, network -->  simple
> CMakeLists.txt 
> with Qt components core, gui, widgets, network
> cmake -project c++ --> simple CMakeLists.txt without any Qt
> dependency
> Or a simple helper script which creates the project file.

If we're going to make the helper pull in external dependencies, I'd
want it to be general-purpose and not specific to Qt. In CMake, pulling
in external dependencies is generally a two-step process:

1) "Find" the external package with find_package(). For example:
find_package(Qt5 COMPONENTS Core Gui). This would create a number of
imported targets, such as Qt5::Core and Qt5::Gui.
2) Link against the imported targets with target_link_libraries(). For
example: target_link_libraries(foo Qt5::Core Qt5::Gui).

I'm imagining a command-line syntax like this:

cmake --generate-project . --library LibraryName --find-packages Qt5 --
imported-targets Qt5::Core Qt5::Gui

If Qt wants to do something more complicated, I think it would be best
for you folks to write your own helper script with the custom logic and
put it in the qtcore tree. Then you could run it like this:

cmake "-DQT_MODULES=core;gui" -P path/to/qtcore/generate_project.cmake

Then the script could do a file(GLOB) for .cpp/.cxx files and generate
an add_library() command out of them.

Kyle



More information about the Development mailing list