CMake: Deprecate _add_app/executable/test/tool PUBLIC_LIBRARIES option
Warn projects not to use it because PUBLIC_LIBRARIES don't make sense for executable targets and it also led to some issues in the internal functions where some of them did not expect to receive PUBLIC_LIBRARIES. To ensure builds don't needlessly break, treat PUBLIC_LIBRARIES values as regular LIBRARIES. In the future we might add an error instead. Using PUBLIC_LIBRARIES in qt_internal_add_app, etc, accidentally worked because the option name and the values following it were parsed as values of the "previous" option, like SOURCES or INCLUDE_DIRECTORIES or LIBRARIES, and when those got passed through to qt_internal_extend_target, things magically worked. We have a lot of projects using PUBLIC_LIBRARIES, mostly due to the way qmake pro files were written and how pro2cmake converted them. We'll have to clean up each repo. Change-Id: I69e09d34afdf98f0d47c08d324643fc986f8131c Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
2ffab52a4f
commit
ea8645d846
@ -5,7 +5,7 @@ function(qt_internal_add_app target)
|
||||
"qt_internal_add_app"
|
||||
"NO_INSTALL;INSTALL_VERSIONED_LINK;EXCEPTIONS"
|
||||
"${__default_target_info_args};INSTALL_DIR"
|
||||
"${__default_private_args}"
|
||||
"${__default_private_args};PUBLIC_LIBRARIES"
|
||||
${ARGN})
|
||||
|
||||
set(exceptions "")
|
||||
@ -26,6 +26,12 @@ function(qt_internal_add_app target)
|
||||
set(no_install NO_INSTALL)
|
||||
endif()
|
||||
|
||||
if(arg_PUBLIC_LIBRARIES)
|
||||
message(WARNING
|
||||
"qt_internal_add_app's PUBLIC_LIBRARIES option is deprecated, and will be removed in "
|
||||
"a future Qt version. Use the LIBRARIES option instead.")
|
||||
endif()
|
||||
|
||||
qt_internal_add_executable("${target}"
|
||||
QT_APP
|
||||
DELAY_RC
|
||||
@ -39,7 +45,10 @@ function(qt_internal_add_app target)
|
||||
${arg_INCLUDE_DIRECTORIES}
|
||||
DEFINES
|
||||
${arg_DEFINES}
|
||||
LIBRARIES ${arg_LIBRARIES} Qt::PlatformAppInternal
|
||||
LIBRARIES
|
||||
${arg_LIBRARIES}
|
||||
${arg_PUBLIC_LIBRARIES}
|
||||
Qt::PlatformAppInternal
|
||||
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
|
||||
LINK_OPTIONS ${arg_LINK_OPTIONS}
|
||||
MOC_OPTIONS ${arg_MOC_OPTIONS}
|
||||
|
@ -104,12 +104,21 @@ function(qt_internal_add_executable name)
|
||||
${arg_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
|
||||
if(arg_PUBLIC_LIBRARIES)
|
||||
message(WARNING
|
||||
"qt_internal_add_executable's PUBLIC_LIBRARIES option is deprecated, and will be "
|
||||
"removed in a future Qt version. Use the LIBRARIES option instead.")
|
||||
endif()
|
||||
|
||||
qt_internal_extend_target("${name}"
|
||||
SOURCES ${arg_SOURCES}
|
||||
INCLUDE_DIRECTORIES ${private_includes}
|
||||
DEFINES ${arg_DEFINES}
|
||||
LIBRARIES ${arg_LIBRARIES} Qt::PlatformCommonInternal
|
||||
PUBLIC_LIBRARIES ${extra_libraries} ${arg_PUBLIC_LIBRARIES}
|
||||
LIBRARIES
|
||||
${arg_LIBRARIES}
|
||||
${arg_PUBLIC_LIBRARIES}
|
||||
Qt::PlatformCommonInternal
|
||||
${extra_libraries}
|
||||
DBUS_ADAPTOR_SOURCES "${arg_DBUS_ADAPTOR_SOURCES}"
|
||||
DBUS_ADAPTOR_FLAGS "${arg_DBUS_ADAPTOR_FLAGS}"
|
||||
DBUS_INTERFACE_SOURCES "${arg_DBUS_INTERFACE_SOURCES}"
|
||||
|
@ -240,6 +240,12 @@ function(qt_internal_add_test name)
|
||||
set(version_arg VERSION "${arg_VERSION}")
|
||||
endif()
|
||||
|
||||
if(arg_PUBLIC_LIBRARIES)
|
||||
message(WARNING
|
||||
"qt_internal_add_test's PUBLIC_LIBRARIES option is deprecated, and will be "
|
||||
"removed in a future Qt version. Use the LIBRARIES option instead.")
|
||||
endif()
|
||||
|
||||
# Handle cases where we have a qml test without source files
|
||||
if (arg_SOURCES)
|
||||
set(private_includes
|
||||
@ -260,8 +266,11 @@ function(qt_internal_add_test name)
|
||||
${private_includes}
|
||||
DEFINES
|
||||
${arg_DEFINES}
|
||||
PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Core ${QT_CMAKE_EXPORT_NAMESPACE}::Test ${arg_PUBLIC_LIBRARIES}
|
||||
LIBRARIES ${arg_LIBRARIES}
|
||||
LIBRARIES
|
||||
${arg_LIBRARIES}
|
||||
${arg_PUBLIC_LIBRARIES}
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::Core
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::Test
|
||||
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
|
||||
LINK_OPTIONS ${arg_LINK_OPTIONS}
|
||||
MOC_OPTIONS ${arg_MOC_OPTIONS}
|
||||
@ -284,7 +293,7 @@ function(qt_internal_add_test name)
|
||||
|
||||
# QMLTest specifics
|
||||
qt_internal_extend_target("${name}" CONDITION arg_QMLTEST
|
||||
PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::QuickTest
|
||||
LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::QuickTest
|
||||
)
|
||||
|
||||
qt_internal_extend_target("${name}" CONDITION arg_QMLTEST AND NOT ANDROID
|
||||
@ -299,7 +308,7 @@ function(qt_internal_add_test name)
|
||||
|
||||
# Android requires Qt::Gui so add it by default for tests
|
||||
qt_internal_extend_target("${name}" CONDITION ANDROID
|
||||
PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Gui
|
||||
LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Gui
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -43,6 +43,7 @@ function(qt_internal_add_tool target_name)
|
||||
set(multi_value_keywords
|
||||
EXTRA_CMAKE_FILES
|
||||
EXTRA_CMAKE_INCLUDES
|
||||
PUBLIC_LIBRARIES
|
||||
${__default_private_args})
|
||||
qt_parse_all_arguments(arg "qt_internal_add_tool" "${option_keywords}"
|
||||
"${one_value_keywords}"
|
||||
@ -194,6 +195,12 @@ function(qt_internal_add_tool target_name)
|
||||
|
||||
set(output_dir "${QT_BUILD_DIR}/${install_dir}")
|
||||
|
||||
if(arg_PUBLIC_LIBRARIES)
|
||||
message(WARNING
|
||||
"qt_internal_add_tool's PUBLIC_LIBRARIES option is deprecated, and will be "
|
||||
"removed in a future Qt version. Use the LIBRARIES option instead.")
|
||||
endif()
|
||||
|
||||
qt_internal_add_executable("${target_name}"
|
||||
OUTPUT_DIRECTORY "${output_dir}"
|
||||
${exceptions}
|
||||
@ -205,7 +212,10 @@ function(qt_internal_add_tool target_name)
|
||||
QT_USE_QSTRINGBUILDER
|
||||
${arg_DEFINES}
|
||||
${corelib}
|
||||
LIBRARIES ${arg_LIBRARIES} Qt::PlatformToolInternal
|
||||
LIBRARIES
|
||||
${arg_LIBRARIES}
|
||||
${arg_PUBLIC_LIBRARIES}
|
||||
Qt::PlatformToolInternal
|
||||
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
|
||||
LINK_OPTIONS ${arg_LINK_OPTIONS}
|
||||
MOC_OPTIONS ${arg_MOC_OPTIONS}
|
||||
|
Loading…
x
Reference in New Issue
Block a user