M
M
Mars362021-02-23 23:58:41
Qt
Mars36, 2021-02-23 23:58:41

How to add QT components to cmake?

I want to add a network component to the project. In qmake I would just add QT += network. How to do also in cmake? Tried like this:

find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets Network  REQUIRED)

But it still throws an error like: error: 'QTcpSocket' file not found

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2021-02-24
@Mars36

You need and target_link_libraries. One find_packageis not enough.

J
Jacob E, 2021-02-24
@Zifix

Look at examples of Qt projects that use cmake, for example here: https://github.com/MASKOR/Qt3DPointcloudRenderer/b...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question