QTP0003

Leve em consideração o valor de BUILD_SHARED_LIBS ao criar bibliotecas Qt.

Esta política foi introduzida no Qt 6.7. A política afeta o tipo padrão das bibliotecas criadas usando a API CMake do Qt, como qt_add_library(), qt_add_plugin() e qt_add_qml_module().

Se a política estiver definida como ` OLD`, o tipo padrão de biblioteca selecionado estará alinhado com o tipo de compilação do Qt, seja ` shared ` ou ` static`.

Se a política estiver definida como ` NEW`, o tipo de biblioteca será selecionado de acordo com o valor de `BUILD_SHARED_LIBS`, caso esteja definido. Se ` BUILD_SHARED_LIBS ` não estiver definido, o tipo de biblioteca padrão recai para o tipo de compilação do Qt.

Por exemplo, o código a seguir usará o tipo de compilação do Qt como tipo de biblioteca padrão para o alvo ` MyLib `, mesmo que ` BUILD_SHARED_LIBS ` esteja definido como ` ON`:

set(BUILD_SHARED_LIBS ON)
...
qt_add_library(MyLib sourcefile.h sourcefile.cpp)

Se você definir QTP0003 como ` NEW ` antes da chamada a `qt_add_library()`, ` BUILD_SHARED_LIBS ` afetará o tipo padrão da biblioteca e ` MyLib ` será a biblioteca compartilhada.

set(BUILD_SHARED_LIBS ON)
...
qt_policy(SET QTP0003 NEW)
qt_add_library(MyLib sourcefile.h sourcefile.cpp)

Consulte também qt_policy(), políticas do Qt CMake e qt_add_library().

© 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.