diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-06-23 12:16:03 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-25 10:39:56 +0000 |
commit | 96306c4bb23ee0c7407547495589b0f9a5ef4881 (patch) | |
tree | dddc162d1daddd3301263e5057a6291412802756 | |
parent | e642a3456db05c0b58b90621217c0efc1455b1d8 (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)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 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>" |