Alvos importados
Cada módulo Qt carregado define um alvo de biblioteca do CMake. Os nomes dos alvos começam com Qt6::, seguidos pelo nome do módulo. Por exemplo: Qt6::Core, Qt6::Gui. Passe o nome do alvo da biblioteca para target_link_libraries para usar a respectiva biblioteca.
Observação: Os alvos também estão disponíveis com o prefixo Qt::: Qt::Core, Qt::Gui e assim por diante. Consulte também a compatibilidade entre o Qt 5 e o Qt 6.
Os alvos importados são criados com as mesmas configurações utilizadas na configuração do Qt. Ou seja:
- Se o Qt foi configurado com a opção `
-debug`, é criado um alvo importado com a configuração `DEBUG`. - Se o Qt foi configurado com a opção `
-release`, é criado um alvo importado com a configuração `RELEASE`. - Se o Qt foi configurado com a opção `
-debug-and-release`, os alvos importados são criados com as configurações `RELEASE` e `DEBUG`.
Se o seu projeto tiver configurações de compilação personalizadas do ` CMake `, você precisará mapear sua configuração personalizada para a configuração de depuração ou de lançamento do Qt.
find_package(Qt6 REQUIRED COMPONENTS Core)
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
# set up a mapping so that the Release configuration for the Qt imported target is
# used in the COVERAGE CMake configuration.
set_target_properties(Qt6::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.