Enforce that plugins can't be used as library dependencies

We want to use the libraries in different projects where the plugins
are not present.

Change-Id: Ia3b183dcf57c7c63c75a17e9d5e3c3ef672e668e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marco Bubke
2024-08-22 12:56:33 +02:00
parent 612e11dc50
commit f5bb913c9d
2 changed files with 28 additions and 0 deletions

View File

@@ -129,6 +129,9 @@ function(add_qtc_library name)
"CONDITION;DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;SYSTEM_INCLUDES;PUBLIC_INCLUDES;PUBLIC_SYSTEM_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES;PRIVATE_COMPILE_OPTIONS;PUBLIC_COMPILE_OPTIONS" ${ARGN}
)
check_library_dependencies(${_arg_DEPENDS})
check_library_dependencies(${_arg_PUBLIC_DEPENDS})
get_default_defines(default_defines_copy ${_arg_ALLOW_ASCII_CASTS})
if (${_arg_UNPARSED_ARGUMENTS})
@@ -336,6 +339,9 @@ function(add_qtc_plugin target_name)
${ARGN}
)
check_library_dependencies(${_arg_DEPENDS})
check_library_dependencies(${_arg_PUBLIC_DEPENDS})
if (${_arg_UNPARSED_ARGUMENTS})
message(FATAL_ERROR "add_qtc_plugin had unparsed arguments")
endif()
@@ -615,6 +621,9 @@ function(extend_qtc_plugin target_name)
return()
endif()
check_library_dependencies(${_arg_DEPENDS})
check_library_dependencies(${_arg_PUBLIC_DEPENDS})
extend_qtc_target(${target_name} ${ARGN})
endfunction()
@@ -624,6 +633,9 @@ function(extend_qtc_library target_name)
return()
endif()
check_library_dependencies(${_arg_DEPENDS})
check_library_dependencies(${_arg_PUBLIC_DEPENDS})
extend_qtc_target(${target_name} ${ARGN})
endfunction()

View File

@@ -361,6 +361,10 @@ function(find_dependent_plugins varName)
if(NOT TARGET ${i})
continue()
endif()
get_property(_class_name TARGET "${i}" PROPERTY QTC_PLUGIN_CLASS_NAME)
if (NOT _class_name)
message(SEND_ERROR "${i} is a library, not a plugin!")
endif()
set(_dep)
get_property(_dep TARGET "${i}" PROPERTY _arg_DEPENDS)
if (_dep)
@@ -377,6 +381,18 @@ function(find_dependent_plugins varName)
set("${varName}" ${_RESULT} PARENT_SCOPE)
endfunction()
function(check_library_dependencies)
foreach(i ${ARGN})
if (NOT TARGET ${i})
continue()
endif()
get_property(_class_name TARGET "${i}" PROPERTY QTC_PLUGIN_CLASS_NAME)
if (_class_name)
message(SEND_ERROR "${i} is a plugin, not a library!")
endif()
endforeach()
endfunction()
function(enable_pch target)
if (BUILD_WITH_PCH)
# Skip PCH for targets that do not use the expected visibility settings: