diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake index db50f4554a9..fba57358032 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 @@ -248,8 +250,14 @@ Q_IMPORT_PLUGIN($) " CONDITION "$>" ) + + # 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 - "$<$>:${out_file}>" + "$<$>:${out_file_path}>" ) target_link_libraries(${name} PRIVATE "$"