diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-06-23 12:16:03 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-06-25 16:33:49 +0200 |
commit | 3d512d17567f365bfd5cc1132830ad814a006dc0 (patch) | |
tree | e388df21b05ae19e1f0c792b213ec94fb17d5ac4 /cmake | |
parent | 36ea0aeacc0480a306a682f54519ad3fffa5e385 (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.
Change-Id: Ife0eba61a1aab4f988d9fe7e2217d30eb96774a7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit e2c6f2ba7ed72195d12e9882c174e59a53317097)
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtExecutableHelpers.cmake | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake index db50f4554a..fba5735803 100644 --- a/cmake/QtExecutableHelpers.cmake +++ b/cmake/QtExecutableHelpers.cmake @@ -240,7 +240,9 @@ function(qt_internal_add_executable name) set(class_names "${class_names_regular}${class_names_separator}${class_names_current_project}") - file(GENERATE OUTPUT ${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> @@ -248,8 +250,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},>>:${out_file}>" + "$<$<NOT:$<STREQUAL:${class_names},>>:${out_file_path}>" ) target_link_libraries(${name} PRIVATE "$<TARGET_PROPERTY:${lib},_qt_initial_repo_plugins>" |