QTP0003
Ten en cuenta el valor de BUILD_SHARED_LIBS al crear bibliotecas Qt.
Esta política se introdujo en Qt 6.7. Afecta al tipo predeterminado de las bibliotecas creadas mediante la API de CMake de Qt, como qt_add_library(), qt_add_plugin() y qt_add_qml_module().
Si la política se establece en « OLD », el tipo de biblioteca predeterminado que se selecciona se ajusta al tipo de compilación de Qt, ya sea « shared » o « static ».
Si la política se establece en « NEW », el tipo de biblioteca se selecciona según el valor de «BUILD_SHARED_LIBS», si está definido. Si « BUILD_SHARED_LIBS » no está definido, el tipo de biblioteca por defecto recurre al tipo de compilación de 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é establecido en « ON »:
set(BUILD_SHARED_LIBS ON)
...
qt_add_library(MyLib sourcefile.h sourcefile.cpp)Si se establece QTP0003 en « NEW » antes de la llamada a qt_add_library(), « BUILD_SHARED_LIBS » afectará al tipo predeterminado de la biblioteca y « MyLib » será la biblioteca compartida.
set(BUILD_SHARED_LIBS ON)
...
qt_policy(SET QTP0003 NEW)
qt_add_library(MyLib sourcefile.h sourcefile.cpp)Véase también qt_policy(), las políticas de Qt CMake 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.