summaryrefslogtreecommitdiffstats
path: root/cmake/QtExecutableHelpers.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-06-23 12:16:03 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-06-25 12:33:58 +0200
commite2c6f2ba7ed72195d12e9882c174e59a53317097 (patch)
tree196b618ccf3d4548420e618c1f107ab93dd2bf2b /cmake/QtExecutableHelpers.cmake
parent19816826873ebb3a89b2173f8685a8d448410680 (diff)
CMake: Fix 'Cannot find source file' error with older CMakes
Configuring a static qtdeclarative with CMake versions older than 3.18.0 fails at generation phase with CMake Error at cmake/QtExecutableHelpers.cmake:28 (add_executable): Cannot find source file: some_path/some_target_plugin_imports_Gui.cpp Marking the generated file as GENERATED explicitly solves the issue. Pick-to: 6.1 6.2 Change-Id: Ife0eba61a1aab4f988d9fe7e2217d30eb96774a7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtExecutableHelpers.cmake')
-rw-r--r--cmake/QtExecutableHelpers.cmake12
1 files changed, 10 insertions, 2 deletions
diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake
index d1fe6e8096..9ca78f65f9 100644
--- a/cmake/QtExecutableHelpers.cmake
+++ b/cmake/QtExecutableHelpers.cmake
@@ -243,7 +243,9 @@ function(qt_internal_add_executable name)
set(class_names
"${class_names_regular}${class_names_separator}${class_names_current_project}")
- file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${out_file} CONTENT
+ set(out_file_path "${CMAKE_CURRENT_BINARY_DIR}/${out_file}")
+
+ file(GENERATE OUTPUT "${out_file_path}" CONTENT
"// This file is auto-generated. Do not edit.
#include <QtPlugin>
@@ -251,8 +253,14 @@ Q_IMPORT_PLUGIN($<JOIN:${class_names},)\nQ_IMPORT_PLUGIN(>)
"
CONDITION "$<NOT:$<STREQUAL:${class_names},>>"
)
+
+ # 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("${out_file_path}" PROPERTIES GENERATED TRUE)
+
target_sources(${name} PRIVATE
- "$<$<NOT:$<STREQUAL:${class_names},>>:${CMAKE_CURRENT_BINARY_DIR}/${out_file}>"
+ "$<$<NOT:$<STREQUAL:${class_names},>>:${out_file_path}>"
)
target_link_libraries(${name} PRIVATE
"$<TARGET_PROPERTY:${lib},_qt_initial_repo_plugins>"