QTP0003

Considere el valor BUILD_SHARED_LIBS al crear bibliotecas Qt.

Esta política se introdujo en Qt 6.7. La política afecta al tipo por defecto de las bibliotecas creadas usando la API CMake de Qt, como qt_add_library, qt_add_plugin, qt_add_qml_module.

Si la directiva se establece en OLD, el tipo de biblioteca predeterminado que se selecciona se alinea con el tipo de compilación de Qt, ya sea shared o static.

Si la política está establecida en NEW, el tipo de biblioteca se selecciona de acuerdo con el valor BUILD_SHARED_LIBS si está establecido. Si BUILD_SHARED_LIBS no está establecido, el tipo de biblioteca por defecto vuelve al tipo de compilación Qt.

Por ejemplo, el siguiente código utilizará el tipo de compilación de Qt como tipo de biblioteca por defecto para el objetivo MyLib, a pesar de que BUILD_SHARED_LIBS esté configurado como ON:

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

Si establece el QTP0003 a NEW antes de la llamada qt_add_library, BUILD_SHARED_LIBS afectará al tipo de biblioteca por defecto y MyLib será la biblioteca compartida.

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

Ver también qt_policy, Qt CMake policies, y 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.