diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index d7f88f12ec..6587fed1a3 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -13,6 +13,9 @@ set(LY_UNITY_BUILD OFF CACHE BOOL "UNITY builds") include(CMakeFindDependencyMacro) include(cmake/LyAutoGen.cmake) +if(PAL_TRAIT_BUILD_HOST_QT_SUPPORTED) + include(cmake/Qt.cmake) +endif() ly_get_absolute_pal_filename(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Platform/${PAL_PLATFORM_NAME}) include(${pal_dir}/LYWrappers_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) @@ -334,11 +337,7 @@ function(ly_add_target) detect_qt_dependency(${ly_add_target_NAME} QT_DEPENDENCY) if(QT_DEPENDENCY) - if(NOT COMMAND ly_qt_deploy) - message(FATAL_ERROR "Could not find function \"ly_qt_deploy\", this function should be defined in cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/Qt_${PAL_PLATFORM_NAME_LOWERCASE}.cmake") - endif() - - ly_qt_deploy(TARGET ${ly_add_target_NAME}) + ly_qt_deploy_qtconf(${ly_add_target_NAME}) endif() endif() diff --git a/cmake/Platform/Android/PAL_android.cmake b/cmake/Platform/Android/PAL_android.cmake index dd61e35e53..b68e922aad 100644 --- a/cmake/Platform/Android/PAL_android.cmake +++ b/cmake/Platform/Android/PAL_android.cmake @@ -12,6 +12,7 @@ ly_set(PAL_EXECUTABLE_APPLICATION_FLAG) set(PAL_LINKOPTION_MODULE MODULE) +ly_set(PAL_TRAIT_BUILD_HOST_QT_SUPPORTED FALSE) ly_set(PAL_TRAIT_BUILD_HOST_GUI_TOOLS FALSE) ly_set(PAL_TRAIT_BUILD_HOST_TOOLS FALSE) ly_set(PAL_TRAIT_BUILD_SERVER_SUPPORTED FALSE) diff --git a/cmake/Platform/Linux/PAL_linux.cmake b/cmake/Platform/Linux/PAL_linux.cmake index c15f2bada9..d3e4aba1f8 100644 --- a/cmake/Platform/Linux/PAL_linux.cmake +++ b/cmake/Platform/Linux/PAL_linux.cmake @@ -12,6 +12,7 @@ ly_set(PAL_EXECUTABLE_APPLICATION_FLAG) ly_set(PAL_LINKOPTION_MODULE MODULE) +ly_set(PAL_TRAIT_BUILD_HOST_QT_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_HOST_GUI_TOOLS FALSE) ly_set(PAL_TRAIT_BUILD_HOST_TOOLS TRUE) ly_set(PAL_TRAIT_BUILD_SERVER_SUPPORTED TRUE) diff --git a/cmake/Platform/Linux/QtDeploy_linux.cmake b/cmake/Platform/Linux/QtDeploy_linux.cmake new file mode 100644 index 0000000000..26f56644a3 --- /dev/null +++ b/cmake/Platform/Linux/QtDeploy_linux.cmake @@ -0,0 +1,73 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +# Clear the cache for found executable +unset(WINDEPLOYQT_EXECUTABLE CACHE) +find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_PATH}/bin") +mark_as_advanced(WINDEPLOYQT_EXECUTABLE) # Hiding from GUI + +function(ly_qt_deploy) + + set(options) + set(oneValueArgs TARGET) + set(multiValueArgs) + + cmake_parse_arguments(ly_qt_deploy "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Validate input arguments + if(NOT ly_qt_deploy_TARGET) + message(FATAL_ERROR "You must provide a target to detect qt dependencies") + endif() + + # When winqtdeploy is used on a unix platform it copies over the hardcoded platform abstraction plugin + # of qxcb plugin. The qxcb plugin requires an X server to be running on linux and order to load properly + # To avoid the issue of requiring an X server to be running in a headless setup, the qminimal + # platform plugin is also copied over to the target file output directory. + set(plugin_path "${QT_PATH}/plugins") + set(platform_plugins ${plugin_path}/platforms/libqminimal.so) + set(xcbglintegrations_plugins ${plugin_path}/xcbglintegrations/libqxcb-glx-integration.so) + + add_custom_command(TARGET ${ly_qt_deploy_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -DLY_TIMESTAMP_REFERENCE=$ + -DLY_LOCK_FILE=$/qtdeploy.lock + -P ${LY_ROOT_FOLDER}/cmake/CommandExecution.cmake + EXEC_COMMAND "${CMAKE_COMMAND}" -E + env PATH=${CMAKE_BINARY_DIR}:${QT_PATH}/bin:$ENV{PATH} + "${CMAKE_COMMAND}" -P "${LY_ROOT_FOLDER}/cmake/Platform/Linux/windeployqt_wrapper.cmake" + "$" + "${WINDEPLOYQT_EXECUTABLE}" + --verbose 2 + --no-compiler-runtime + --dir "$" + "$" + EXEC_COMMAND ${CMAKE_COMMAND} -E make_directory + "$/platforms" + EXEC_COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${platform_plugins} + "$/platforms" + EXEC_COMMAND ${CMAKE_COMMAND} -E make_directory + "$/xcbglintegrations" + EXEC_COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${xcbglintegrations_plugins} + "$/xcbglintegrations" + DEPENDS $ + COMMENT "Deploying qt..." + VERBATIM + ) + +endfunction() + +# windeployqt uses qmake -query to introspect a given Qt installation. However, +# qmake is not relocatable, so the paths reported are those from the build +# machine, and not from wherever the user has their 3rdParty libraries. So we +# create a fake qmake executable to report the right paths to windeployqt. +configure_file(${CMAKE_CURRENT_LIST_DIR}/Qt_qmake_${PAL_PLATFORM_NAME_LOWERCASE}.cmake.in ${CMAKE_BINARY_DIR}/qmake) diff --git a/cmake/Platform/Linux/Qt_qmake_linux.cmake.in b/cmake/Platform/Linux/Qt_qmake_linux.cmake.in new file mode 100644 index 0000000000..a02b1aa397 --- /dev/null +++ b/cmake/Platform/Linux/Qt_qmake_linux.cmake.in @@ -0,0 +1,38 @@ +#!${CMAKE_COMMAND} -P + +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + + +execute_process(COMMAND ${CMAKE_COMMAND} -E echo "QT_SYSROOT: +QT_INSTALL_PREFIX:${QT_PATH} +QT_INSTALL_ARCHDATA:${QT_PATH} +QT_INSTALL_DATA:${QT_PATH} +QT_INSTALL_DOCS:${QT_PATH}/doc +QT_INSTALL_HEADERS:${QT_PATH}/include +QT_INSTALL_LIBS:${QT_PATH}/lib +QT_INSTALL_LIBEXECS:${QT_PATH}/libexec +QT_INSTALL_BINS:${QT_PATH}/bin +QT_INSTALL_TESTS:${QT_PATH}/tests +QT_INSTALL_PLUGINS:${QT_PATH}/plugins +QT_INSTALL_IMPORTS:${QT_PATH}/imports +QT_INSTALL_TRANSLATIONS:${QT_PATH}/translations +QT_INSTALL_CONFIGURATION:${QT_PATH}/etc/xdg +QT_INSTALL_EXAMPLES:${QT_PATH}/examples +QT_INSTALL_DEMOS:${QT_PATH}/examples +QT_HOST_PREFIX:${QT_PATH} +QT_HOST_DATA:${QT_PATH} +QT_HOST_BINS:${QT_PATH}/bin +QT_HOST_LIBS:${QT_PATH}/lib +QMAKE_SPEC:linux-g++ +QMAKE_XSPEC:linux-g++ +QMAKE_VERSION:3.1 +QT_VERSION:${QT_PACKAGE_VERSION}") diff --git a/cmake/Platform/Mac/PAL_mac.cmake b/cmake/Platform/Mac/PAL_mac.cmake index f49578a83a..477c8d4afb 100644 --- a/cmake/Platform/Mac/PAL_mac.cmake +++ b/cmake/Platform/Mac/PAL_mac.cmake @@ -12,6 +12,7 @@ ly_set(PAL_EXECUTABLE_APPLICATION_FLAG MACOSX_BUNDLE) ly_set(PAL_LINKOPTION_MODULE MODULE) +ly_set(PAL_TRAIT_BUILD_HOST_QT_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_HOST_GUI_TOOLS TRUE) ly_set(PAL_TRAIT_BUILD_HOST_TOOLS TRUE) ly_set(PAL_TRAIT_BUILD_SERVER_SUPPORTED FALSE) diff --git a/cmake/Platform/Mac/QtDeploy_mac.cmake b/cmake/Platform/Mac/QtDeploy_mac.cmake new file mode 100644 index 0000000000..7ab5f61f5d --- /dev/null +++ b/cmake/Platform/Mac/QtDeploy_mac.cmake @@ -0,0 +1,70 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +# Clear the cache for found executable +unset(MACDEPLOYQT_EXECUTABLE CACHE) +find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${QT_PATH}/bin") +mark_as_advanced(MACDEPLOYQT_EXECUTABLE) # Hiding from GUI + +function(ly_qt_deploy) + + set(options) + set(oneValueArgs TARGET) + set(multiValueArgs) + + cmake_parse_arguments(ly_qt_deploy "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Validate input arguments + if(NOT ly_qt_deploy_TARGET) + message(FATAL_ERROR "You must provide a target to detect qt dependencies") + endif() + + #get_target_property(is_bundle ${ly_qt_deploy_TARGET} MACOSX_BUNDLE) + if (is_bundle) + add_custom_command(TARGET ${ly_qt_deploy_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -DLY_TIMESTAMP_REFERENCE=$ + -DLY_LOCK_FILE=$/qtdeploy.lock + -P ${LY_ROOT_FOLDER}/cmake/CommandExecution.cmake + EXEC_COMMAND "${CMAKE_COMMAND}" -E time + ${MACDEPLOYQT_EXECUTABLE} + $ + -always-overwrite + -no-strip + -verbose=0 + -fs=APFS + DEPENDS $ + COMMENT "Deploying qt to the ${ly_qt_deploy_TARGET} bundle ..." + VERBATIM + ) + else() + set(qt_conf_config "[Paths]\nPlugins=@plugin_path@") + set(plugin_path "${QT_PATH}/plugins") + string(CONFIGURE "${qt_conf_config}" qt_conf_output @ONLY) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "${qt_conf_output}") + + # output the qt_conf file using "echo" and file redirection + add_custom_command(TARGET ${ly_qt_deploy_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -DLY_TIMESTAMP_REFERENCE=$ + -DLY_LOCK_FILE=$/qtdeploy.lock + -P ${LY_ROOT_FOLDER}/cmake/CommandExecution.cmake + EXEC_COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_BINARY_DIR}/qt.conf + $/qt.conf + COMMENT "copying over qt.conf..." + VERBATIM + ) + endif() + +endfunction() + + diff --git a/cmake/Platform/Windows/PAL_windows.cmake b/cmake/Platform/Windows/PAL_windows.cmake index fbf65db63f..fcbd8acb70 100644 --- a/cmake/Platform/Windows/PAL_windows.cmake +++ b/cmake/Platform/Windows/PAL_windows.cmake @@ -12,6 +12,7 @@ ly_set(PAL_EXECUTABLE_APPLICATION_FLAG WIN32) ly_set(PAL_LINKOPTION_MODULE MODULE) +ly_set(PAL_TRAIT_BUILD_HOST_QT_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_HOST_GUI_TOOLS TRUE) ly_set(PAL_TRAIT_BUILD_HOST_TOOLS TRUE) ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED TRUE) diff --git a/cmake/Platform/Windows/QtDeploy_windows.cmake b/cmake/Platform/Windows/QtDeploy_windows.cmake new file mode 100644 index 0000000000..2fb1a71114 --- /dev/null +++ b/cmake/Platform/Windows/QtDeploy_windows.cmake @@ -0,0 +1,50 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +# Clear the cache for found executable +unset(WINDEPLOYQT_EXECUTABLE CACHE) +find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_PATH}/bin") +mark_as_advanced(WINDEPLOYQT_EXECUTABLE) # Hiding from GUI + +function(ly_qt_deploy) + + set(options) + set(oneValueArgs TARGET) + set(multiValueArgs) + + cmake_parse_arguments(ly_qt_deploy "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Validate input arguments + if(NOT ly_qt_deploy_TARGET) + message(FATAL_ERROR "You must provide a target to detect qt dependencies") + endif() + + # CMake has an issue with POST_BUILD commands in msbuild when it is executed from outside VS: + # https://gitlab.kitware.com/cmake/cmake/issues/18530 + + add_custom_command(TARGET ${ly_qt_deploy_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -DLY_TIMESTAMP_REFERENCE=$ + -DLY_LOCK_FILE=$/qtdeploy.lock + -P ${LY_ROOT_FOLDER}/cmake/CommandExecution.cmake + EXEC_COMMAND "${CMAKE_COMMAND}" -E + env PATH="${QT_PATH}/bin" + ${WINDEPLOYQT_EXECUTABLE} + $<$:--pdb> + --verbose 0 + --no-compiler-runtime + $ + DEPENDS $ $ + COMMENT "Deploying qt..." + VERBATIM + ) + +endfunction() \ No newline at end of file diff --git a/cmake/Platform/iOS/PAL_ios.cmake b/cmake/Platform/iOS/PAL_ios.cmake index 981bb9cab1..e9e38ac494 100644 --- a/cmake/Platform/iOS/PAL_ios.cmake +++ b/cmake/Platform/iOS/PAL_ios.cmake @@ -12,6 +12,7 @@ ly_set(PAL_EXECUTABLE_APPLICATION_FLAG MACOSX_BUNDLE) ly_set(PAL_LINKOPTION_MODULE SHARED) # For iOS, 'MODULE' creates a tool/bundle, but we treat it as a shared library +ly_set(PAL_TRAIT_BUILD_HOST_QT_SUPPORTED FALSE) ly_set(PAL_TRAIT_BUILD_HOST_GUI_TOOLS FALSE) ly_set(PAL_TRAIT_BUILD_HOST_TOOLS FALSE) ly_set(PAL_TRAIT_BUILD_SERVER_SUPPORTED FALSE) diff --git a/cmake/Qt.cmake b/cmake/Qt.cmake new file mode 100644 index 0000000000..bf4ecb0f28 --- /dev/null +++ b/cmake/Qt.cmake @@ -0,0 +1,199 @@ +# +# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +# its licensors. +# +# For complete copyright and license terms please see the LICENSE at the root of this +# distribution (the "License"). All use of this software is governed by the License, +# or, if provided, by the license below or the license accompanying this file. Do not +# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# + +include_guard() + +ly_download_associated_package(Qt) +find_package(Qt REQUIRED MODULE) + +# UIC executable +unset(QT_UIC_EXECUTABLE CACHE) +find_program(QT_UIC_EXECUTABLE uic HINTS "${QT_PATH}/bin") +mark_as_advanced(QT_UIC_EXECUTABLE) # Hiding from GUI + +# RCC executable +unset(AUTORCC_EXECUTABLE CACHE) +find_program(AUTORCC_EXECUTABLE rcc HINTS "${QT_PATH}/bin") +mark_as_advanced(AUTORCC_EXECUTABLE) # Hiding from GUI +set(Qt5Core_RCC_EXECUTABLE "${AUTORCC_EXECUTABLE}" CACHE FILEPATH "Qt's resource compiler, used by qt5_add_resources" FORCE) +mark_as_advanced(Qt5Core_RCC_EXECUTABLE) # Hiding from GUI + +# LRELEASE executable +unset(QT_LRELEASE_EXECUTABLE CACHE) +find_program(QT_LRELEASE_EXECUTABLE lrelease HINTS "${QT_PATH}/bin") +mark_as_advanced(QT_LRELEASE_EXECUTABLE) # Hiding from GUI +if(NOT QT_LRELEASE_EXECUTABLE) + message(FATAL_ERROR "Qt's lrelease executbale not found") +endif() +set(Qt5_LRELEASE_EXECUTABLE "${QT_LRELEASE_EXECUTABLE}" CACHE FILEPATH "Qt's lrelease executable, used by qt5_add_translation" FORCE) +mark_as_advanced(Qt5_LRELEASE_EXECUTABLE) # Hiding from GUI + +#! ly_qt_uic_target: handles qt's ui files by injecting uic generation +# +# AUTOUIC has issues to detect changes in UIC files and trigger regeneration: +# https://gitlab.kitware.com/cmake/cmake/-/issues/18741 +# So instead, we are going to manually wrap the files. We dont use qt5_wrap_ui because +# it outputs to ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h and we want to follow the +# same folder structure that AUTOUIC uses +# +function(ly_qt_uic_target TARGET) + + get_target_property(all_ui_sources ${TARGET} SOURCES) + list(FILTER all_ui_sources INCLUDE REGEX "^.*\\.ui$") + if(NOT all_ui_sources) + message(FATAL_ERROR "Target ${TARGET} contains AUTOUIC but doesnt have any .ui file") + endif() + + if(AUTOGEN_BUILD_DIR) + set(gen_dir ${AUTOGEN_BUILD_DIR}) + else() + set(gen_dir ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_autogen/include) + endif() + + foreach(ui_source ${all_ui_sources}) + + get_filename_component(filename ${ui_source} NAME_WE) + get_filename_component(dir ${ui_source} DIRECTORY) + if(IS_ABSOLUTE ${dir}) + file(RELATIVE_PATH dir ${CMAKE_CURRENT_SOURCE_DIR} ${dir}) + endif() + + set(outfolder ${gen_dir}/${dir}) + set(outfile ${outfolder}/ui_${filename}.h) + get_filename_component(infile ${ui_source} ABSOLUTE) + + file(MAKE_DIRECTORY ${outfolder}) + add_custom_command(OUTPUT ${outfile} + COMMAND ${QT_UIC_EXECUTABLE} -o ${outfile} ${infile} + MAIN_DEPENDENCY ${infile} VERBATIM + COMMENT "UIC ${infile}" + ) + + set_source_files_properties(${infile} PROPERTIES SKIP_AUTOUIC TRUE) + set_source_files_properties(${outfile} PROPERTIES + SKIP_AUTOMOC TRUE + SKIP_AUTOUIC TRUE + GENERATED TRUE + ) + list(APPEND all_ui_wrapped_sources ${outfile}) + + endforeach() + + # Add files to the target + target_sources(${TARGET} PRIVATE ${all_ui_wrapped_sources}) + source_group("Generated Files" FILES ${all_ui_wrapped_sources}) + + # Add include directories relative to the generated folder + # query for the property first to avoid the "NOTFOUND" in a list + get_property(has_includes TARGET ${TARGET} PROPERTY INCLUDE_DIRECTORIES SET) + if(has_includes) + get_property(all_include_directories TARGET ${TARGET} PROPERTY INCLUDE_DIRECTORIES) + foreach(dir ${all_include_directories}) + if(IS_ABSOLUTE ${dir}) + file(RELATIVE_PATH dir ${CMAKE_CURRENT_SOURCE_DIR} ${dir}) + endif() + list(APPEND new_includes ${gen_dir}/${dir}) + endforeach() + endif() + list(APPEND new_includes ${gen_dir}) + target_include_directories(${TARGET} PRIVATE ${new_includes}) + +endfunction() + +#! ly_add_translations: adds translations (ts) to a target. +# +# This wrapper will generate a qrc file with those translations and add the files under "prefix" and add them to +# the indicated targets. These files will be added under the "Generated Files" filter +# +# \arg:TARGETS name of the targets that the translations will be added to +# \arg:PREFIX prefix where the translation will be located within the qrc file +# \arg:FILES translation files to add +# +function(ly_add_translations) + + set(options) + set(oneValueArgs PREFIX) + set(multiValueArgs TARGETS FILES) + + cmake_parse_arguments(ly_add_translations "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Validate input arguments + if(NOT ly_add_translations_TARGETS) + message(FATAL_ERROR "You must provide at least one target") + endif() + if(NOT ly_add_translations_FILES) + message(FATAL_ERROR "You must provide at least a translation file") + endif() + + qt5_add_translation(TRANSLATED_FILES ${ly_add_translations_FILES}) + + set(qrc_file_contents +" + +") + foreach(file ${TRANSLATED_FILES}) + get_filename_component(filename ${file} NAME) + string(APPEND qrc_file_contents " ${filename} +") + endforeach() + string(APPEND qrc_file_contents " + +") + set(qrc_file_path ${CMAKE_CURRENT_BINARY_DIR}/i18n_${ly_add_translations_PREFIX}.qrc) + file(WRITE + ${qrc_file_path} + ${qrc_file_contents} + ) + set_source_files_properties( + ${TRANSLATED_FILES} + ${qrc_file_path} + PROPERTIES + GENERATED TRUE + SKIP_AUTORCC TRUE + ) + qt5_add_resources(RESOURCE_FILE ${qrc_file_path}) + + foreach(target ${ly_add_translations_TARGETS}) + target_sources(${target} PRIVATE "${TRANSLATED_FILES};${qrc_file_path};${RESOURCE_FILE}") + endforeach() + +endfunction() + + +#! ly_qt_deploy_qtconf: deploys the qt.conf file for TARGET +# +# Instead of running a qt deploy on regular builds, we are using the qt.conf method: +# https://doc.qt.io/qt-5/qt-conf.html +# With such method we can use Qt from the 3rdParty package folder without requiring to +# copy the dlls/plugins to the output. +# +# A full deploy will be done on cmake install +# +# \arg:TARGET target that defines where to deploy to. This also adds a custom POST_BUILD +# command to TARGET to copy the file. +# +function(ly_qt_deploy_qtconf TARGET) + + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -E copy_if_different + ${CMAKE_BINARY_DIR}/qt.conf + $/qt.conf + COMMENT "Copying over qt.conf..." + VERBATIM + ) + +endfunction() + +# Generate the file once so we copy it per target +file(WRITE "${CMAKE_BINARY_DIR}/qt.conf" "[Paths]\nPlugins=${QT_PATH}/plugins") + +include(${LY_ROOT_FOLDER}/cmake/Platform/${PAL_PLATFORM_NAME}/QtDeploy_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)