summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-03 17:35:59 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-06 12:46:52 +0000
commit0baf73e8bd1a872ca234bd581ac7fba0c60d6f88 (patch)
tree759744bb0423d094565b3c5d3fa018b9dd7f5b2e
parent406f33e24706e92532efa2afeac40f13421db463 (diff)
CMake: Fix 'Cannot find source file' error with older CMakes
Configuring a static plugin init library with CMake versions earlier than 3.18.0 fails at generation phase with CMake Error at Qt6CoreMacros.cmake:2071 (add_library): Cannot find source file: example/plugins/basictools/pnp_basictools_init.cpp Call Stack (most recent call first): qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1998 (_qt_internal_add_library) qtbase/lib/cmake/Qt6/QtPublicPluginHelpers.cmake:243 (qt6_add_library) qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1967 (__qt_internal_add_static_plugin_init_object_library) qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:1989 (qt6_add_plugin) qtbase/plugins/basictools/CMakeLists.txt:1 (qt_add_plugin) Marking the generated file as GENERATED explicitly solves the issue. Similar to e2c6f2ba7ed72195d12e9882c174e59a53317097 Fixes: QTBUG-96197 Change-Id: If730a1fcbe6910d6041eb6eba03d6e45a025c424 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit d7c6d69a8c54d4ac3b6872f619dfefe2c47377b1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--cmake/QtPublicPluginHelpers.cmake5
1 files changed, 5 insertions, 0 deletions
diff --git a/cmake/QtPublicPluginHelpers.cmake b/cmake/QtPublicPluginHelpers.cmake
index fed9e4264b..cbe8a5c8aa 100644
--- a/cmake/QtPublicPluginHelpers.cmake
+++ b/cmake/QtPublicPluginHelpers.cmake
@@ -233,6 +233,11 @@ function(__qt_internal_add_static_plugin_init_object_library
CONTENT "${import_content}"
)
+ # CMake versions earlier than 3.18.0 can't find the generated file for some reason,
+ # failing at generation phase.
+ # Explicitly marking the file as GENERATED fixes the issue.
+ set_source_files_properties("${generated_qt_plugin_file_name}" PROPERTIES GENERATED TRUE)
+
__qt_internal_get_static_plugin_init_target_name("${plugin_target}" plugin_init_target)
qt6_add_library("${plugin_init_target}" OBJECT "${generated_qt_plugin_file_name}")