From 9fe06453d316087af863ef2993fd70feecdea46c Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Thu, 3 Jun 2021 17:42:24 -0700 Subject: [PATCH 01/16] Initial commit to use qt.conf for all builds --- cmake/LYWrappers.cmake | 9 +- cmake/Platform/Android/PAL_android.cmake | 1 + cmake/Platform/Linux/PAL_linux.cmake | 1 + cmake/Platform/Linux/QtDeploy_linux.cmake | 73 +++++++ cmake/Platform/Linux/Qt_qmake_linux.cmake.in | 38 ++++ cmake/Platform/Mac/PAL_mac.cmake | 1 + cmake/Platform/Mac/QtDeploy_mac.cmake | 70 ++++++ cmake/Platform/Windows/PAL_windows.cmake | 1 + cmake/Platform/Windows/QtDeploy_windows.cmake | 50 +++++ cmake/Platform/iOS/PAL_ios.cmake | 1 + cmake/Qt.cmake | 199 ++++++++++++++++++ 11 files changed, 439 insertions(+), 5 deletions(-) create mode 100644 cmake/Platform/Linux/QtDeploy_linux.cmake create mode 100644 cmake/Platform/Linux/Qt_qmake_linux.cmake.in create mode 100644 cmake/Platform/Mac/QtDeploy_mac.cmake create mode 100644 cmake/Platform/Windows/QtDeploy_windows.cmake create mode 100644 cmake/Qt.cmake 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) From 47c3c3a5d04af5130bf0b7bdb5dd374782089235 Mon Sep 17 00:00:00 2001 From: pappeste Date: Wed, 9 Jun 2021 17:50:17 -0700 Subject: [PATCH 02/16] Solution that wraps qt deploy with cmake --- .../Platform/Windows/lrelease_windows.cmake | 16 -- Gems/QtForPython/Code/CMakeLists.txt | 3 +- cmake/CommandExecution.cmake | 5 + cmake/LYWrappers.cmake | 63 ------ cmake/Platform/Android/PAL_android.cmake | 1 - cmake/Platform/Common/Install_common.cmake | 23 +- .../Common/RuntimeDependencies_common.cmake | 38 +++- cmake/Platform/Linux/PAL_linux.cmake | 1 - cmake/Platform/Linux/QtDeploy_linux.cmake | 73 ------- cmake/Platform/Linux/Qt_qmake_linux.cmake.in | 38 ---- .../Platform/Linux/platform_linux_files.cmake | 1 - .../Platform/Linux/windeployqt_wrapper.cmake | 121 ----------- cmake/Platform/Mac/PAL_mac.cmake | 1 - cmake/Platform/Mac/QtDeploy_mac.cmake | 70 ------ cmake/Platform/Windows/PAL_windows.cmake | 1 - cmake/Platform/Windows/QtDeploy_windows.cmake | 50 ----- cmake/Qt.cmake | 199 ------------------ 17 files changed, 35 insertions(+), 669 deletions(-) delete mode 100644 cmake/Platform/Linux/QtDeploy_linux.cmake delete mode 100644 cmake/Platform/Linux/Qt_qmake_linux.cmake.in delete mode 100644 cmake/Platform/Linux/windeployqt_wrapper.cmake delete mode 100644 cmake/Platform/Mac/QtDeploy_mac.cmake delete mode 100644 cmake/Platform/Windows/QtDeploy_windows.cmake delete mode 100644 cmake/Qt.cmake diff --git a/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake b/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake index 73e1fb82c1..4d5680a30d 100644 --- a/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake +++ b/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake @@ -8,19 +8,3 @@ # 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. # - -add_custom_command(TARGET LmbrCentral.Editor POST_BUILD - COMMAND "${CMAKE_COMMAND}" - -DLY_TIMESTAMP_REFERENCE=$/lrelease.exe - -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 - $/lrelease.exe - COMMENT "Patching lrelease..." - VERBATIM -) diff --git a/Gems/QtForPython/Code/CMakeLists.txt b/Gems/QtForPython/Code/CMakeLists.txt index c11d93634e..e7b4723dfb 100644 --- a/Gems/QtForPython/Code/CMakeLists.txt +++ b/Gems/QtForPython/Code/CMakeLists.txt @@ -23,7 +23,6 @@ endif() ly_add_target( NAME QtForPython.Editor.Static STATIC NAMESPACE Gem - find_package(Qt) FILES_CMAKE qtforpython_editor_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake PLATFORM_INCLUDE_FILES @@ -41,7 +40,7 @@ ly_add_target( Gem::EditorPythonBindings.Static RUNTIME_DEPENDENCIES 3rdParty::pyside2 - Qt5::Test + 3rdParty::Qt::Test ) ly_add_target( diff --git a/cmake/CommandExecution.cmake b/cmake/CommandExecution.cmake index b37664c048..a10e30eb26 100644 --- a/cmake/CommandExecution.cmake +++ b/cmake/CommandExecution.cmake @@ -87,4 +87,9 @@ endif() if(LY_TIMESTAMP_REFERENCE) # Touch the timestamp file file(TOUCH ${LY_TIMESTAMP_FILE}) +endif() + +if(LY_LOCK_FILE) + file(LOCK ${LY_LOCK_FILE} RELEASE) + file(REMOVE ${LY_LOCK_FILE}) endif() \ No newline at end of file diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 6587fed1a3..81c36a9c56 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -13,9 +13,6 @@ 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) @@ -292,8 +289,6 @@ function(ly_add_target) foreach(prop IN ITEMS AUTOMOC AUTORCC) if(${ly_add_target_${prop}}) set_property(TARGET ${ly_add_target_NAME} PROPERTY ${prop} ON) - # Flag this target as depending on Qt - set_property(GLOBAL PROPERTY LY_DETECT_QT_DEPENDENCY_${ly_add_target_NAME} ON) endif() endforeach() if(${ly_add_target_AUTOUIC}) @@ -335,10 +330,6 @@ function(ly_add_target) VERBATIM ) - detect_qt_dependency(${ly_add_target_NAME} QT_DEPENDENCY) - if(QT_DEPENDENCY) - ly_qt_deploy_qtconf(${ly_add_target_NAME}) - endif() endif() if(ly_add_target_AUTOGEN_RULES) @@ -429,60 +420,6 @@ function(ly_delayed_target_link_libraries) endfunction() -#! detect_qt_dependency: Determine if a target will link directly to a Qt library -# -# qt deployment introspects a shared library or executable for its direct -# dependencies on Qt libraries. In CMake, this will be true if a target, or any -# of its link libraries which are static libraries, recursively, links to Qt. -function(detect_qt_dependency TARGET_NAME OUTPUT_VARIABLE) - - if(TARGET ${TARGET_NAME}) - get_target_property(alias ${TARGET_NAME} ALIASED_TARGET) - if(alias) - set(TARGET_NAME ${alias}) - endif() - endif() - - get_property(cached_is_qt_dependency GLOBAL PROPERTY LY_DETECT_QT_DEPENDENCY_${TARGET_NAME}) - if(cached_is_qt_dependency) - set(${OUTPUT_VARIABLE} ${cached_is_qt_dependency} PARENT_SCOPE) - return() - endif() - - if(${TARGET_NAME} MATCHES "^3rdParty::Qt::.*") - set_property(GLOBAL PROPERTY LY_DETECT_QT_DEPENDENCY_${TARGET_NAME} ON) - set(${OUTPUT_VARIABLE} ON PARENT_SCOPE) - return() - endif() - - get_property(delayed_link GLOBAL PROPERTY LY_DELAYED_LINK_${TARGET_NAME}) - set(exclude_library_types SHARED_LIBRARY MODULE_LIBRARY) - foreach(library IN LISTS delayed_link) - - if(TARGET ${library}) - get_target_property(child_target_type ${library} TYPE) - - # If the dependency to Qt has to go through a shared/module library, - # it is not a direct dependency - if (child_target_type IN_LIST exclude_library_types) - continue() - endif() - endif() - - detect_qt_dependency(${library} child_depends_on_qt) - if(child_depends_on_qt) - set_property(GLOBAL PROPERTY LY_DETECT_QT_DEPENDENCY_${TARGET_NAME} ON) - set(${OUTPUT_VARIABLE} ON PARENT_SCOPE) - return() - endif() - - endforeach() - - set_property(GLOBAL PROPERTY LY_DETECT_QT_DEPENDENCY_${TARGET_NAME} OFF) - set(${OUTPUT_VARIABLE} OFF PARENT_SCOPE) - -endfunction() - #! ly_parse_third_party_dependencies: Validates any 3rdParty library dependencies through the find_package command # # \arg:ly_THIRD_PARTY_LIBRARIES name of the target libraries to validate existance of through the find_package command. diff --git a/cmake/Platform/Android/PAL_android.cmake b/cmake/Platform/Android/PAL_android.cmake index b68e922aad..dd61e35e53 100644 --- a/cmake/Platform/Android/PAL_android.cmake +++ b/cmake/Platform/Android/PAL_android.cmake @@ -12,7 +12,6 @@ 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/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 933d64149b..2842b1448d 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -389,16 +389,7 @@ function(ly_setup_runtime_dependencies) # Common functions used by the bellow code install(CODE -"function(ly_deploy_qt_install target_output) - execute_process(COMMAND \"${WINDEPLOYQT_EXECUTABLE}\" --verbose 0 --no-compiler-runtime \"\${target_output}\" ERROR_VARIABLE deploy_error RESULT_VARIABLE deploy_result) - if (NOT \${deploy_result} EQUAL 0) - if(NOT deploy_error MATCHES \"does not seem to be a Qt executable\" ) - message(SEND_ERROR \"Deploying qt for \${target_output} returned \${deploy_result}: \${deploy_error}\") - endif() - endif() -endfunction() - -function(ly_copy source_file target_directory) +"function(ly_copy source_file target_directory) file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) endfunction()" ) @@ -419,18 +410,6 @@ endfunction()" file(RELATIVE_PATH target_runtime_output_subdirectory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${target_runtime_output_directory}) endif() - # Qt - get_property(has_qt_dependency GLOBAL PROPERTY LY_DETECT_QT_DEPENDENCY_${target}) - if(has_qt_dependency) - # Qt deploy needs to be done after the binary is copied to the output, so we do a install(CODE) which effectively - # puts it as a postbuild step of the "install" target. Binaries are copied at that point. - if(NOT EXISTS ${WINDEPLOYQT_EXECUTABLE}) - message(FATAL_ERROR "Qt deploy executable not found: ${WINDEPLOYQT_EXECUTABLE}") - endif() - set(target_output "${install_output_folder}/${target_runtime_output_subdirectory}/$") - list(APPEND runtime_commands "ly_deploy_qt_install(\"${target_output}\")\n") - endif() - # runtime dependencies that need to be copied to the output set(target_file_dir "${install_output_folder}/${target_runtime_output_subdirectory}") ly_get_runtime_dependencies(runtime_dependencies ${target}) diff --git a/cmake/Platform/Common/RuntimeDependencies_common.cmake b/cmake/Platform/Common/RuntimeDependencies_common.cmake index 4ae914744f..57484da9eb 100644 --- a/cmake/Platform/Common/RuntimeDependencies_common.cmake +++ b/cmake/Platform/Common/RuntimeDependencies_common.cmake @@ -35,6 +35,8 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET) return() # Nothing to do endif() + ly_de_alias_target(${ly_TARGET} ly_TARGET) + # To optimize the search, we are going to cache the dependencies for the targets we already walked through. # To do so, we will create a variable named LY_RUNTIME_DEPENDENCIES_${ly_TARGET} which will contain a list # of all the dependencies @@ -96,15 +98,7 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET) # Add the imported locations get_target_property(is_imported ${ly_TARGET} IMPORTED) if(is_imported) - # Skip Qt if this is a 3rdParty - # Qt is deployed using qt_deploy, no need to copy the dependencies set(skip_imported FALSE) - string(REGEX MATCH "3rdParty::([^:,]*)" target_package ${ly_TARGET}) - if(target_package) - if(${CMAKE_MATCH_1} STREQUAL "Qt") - set(skip_imported TRUE) - endif() - endif() if(target_type MATCHES "(STATIC_LIBRARY)") # No need to copy these dependencies since the outputs are not used at runtime set(skip_imported TRUE) @@ -118,12 +112,34 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET) else() set(imported_property IMPORTED_LOCATION) endif() - get_target_property(target_locations ${ly_TARGET} ${imported_property}) + set(target_locations) + get_target_property(current_target_locations ${ly_TARGET} ${imported_property}) + if(current_target_locations) + string(APPEND target_locations ${current_target_locations}) + else() + # Check if the property exists for configurations + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + unset(current_target_locations) + get_target_property(current_target_locations ${ly_TARGET} ${imported_property}_${UCONF}) + if(current_target_locations) + string(APPEND target_locations $<$:${current_target_locations}>) + else() + # try to use the mapping + get_target_property(mapped_conf ${ly_TARGET} MAP_IMPORTED_CONFIG_${UCONF}) + if(mapped_conf) + get_target_property(current_target_locations ${ly_TARGET} ${imported_property}_${mapped_conf}) + if(current_target_locations) + string(APPEND target_locations $<$:${current_target_locations}>) + endif() + endif() + endif() + endforeach() + endif() if(target_locations) list(APPEND all_runtime_dependencies ${target_locations}) endif() - endif() endif() @@ -238,6 +254,8 @@ function(ly_copy source_file target_directory) if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") file(LOCK \"\${target_directory}/\${target_filename}.lock\" GUARD FUNCTION TIMEOUT 30) file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) + file(LOCK \"\${target_directory}/\${target_filename}.lock\" RELEASE) + file(REMOVE \"\${target_directory}/\${target_filename}.lock\") endif() endif() endfunction() diff --git a/cmake/Platform/Linux/PAL_linux.cmake b/cmake/Platform/Linux/PAL_linux.cmake index d3e4aba1f8..c15f2bada9 100644 --- a/cmake/Platform/Linux/PAL_linux.cmake +++ b/cmake/Platform/Linux/PAL_linux.cmake @@ -12,7 +12,6 @@ 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 deleted file mode 100644 index 26f56644a3..0000000000 --- a/cmake/Platform/Linux/QtDeploy_linux.cmake +++ /dev/null @@ -1,73 +0,0 @@ -# -# 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 deleted file mode 100644 index a02b1aa397..0000000000 --- a/cmake/Platform/Linux/Qt_qmake_linux.cmake.in +++ /dev/null @@ -1,38 +0,0 @@ -#!${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/Linux/platform_linux_files.cmake b/cmake/Platform/Linux/platform_linux_files.cmake index 8b6bdf1361..0a9a244ef0 100644 --- a/cmake/Platform/Linux/platform_linux_files.cmake +++ b/cmake/Platform/Linux/platform_linux_files.cmake @@ -19,6 +19,5 @@ set(FILES LYWrappers_linux.cmake PAL_linux.cmake PALDetection_linux.cmake - windeployqt_wrapper.cmake RPathChange.cmake ) diff --git a/cmake/Platform/Linux/windeployqt_wrapper.cmake b/cmake/Platform/Linux/windeployqt_wrapper.cmake deleted file mode 100644 index 320b49aa7a..0000000000 --- a/cmake/Platform/Linux/windeployqt_wrapper.cmake +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/cmake -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. -# - -# We use windeployqt on Linux to copy the necessary Qt libraries and files to -# the build directory. After these files are copied, we need to adjust their -# rpath to point to Qt from the build tree. - -# This script is invoked through the CommandExecution.cmake script. The invoked -# commandline is something like: -# cmake -P CommandExecution.cmake EXEC_COMMAND cmake -E env ... cmake -P windeployqt_wrapper.cmake args -# ^ 1 ^ 2 ^ 3 -# cmake #1 invokes cmake #2 which invokes cmake #3. But cmake #1 also sees 2 -P -# arguments, so cmake #1 also invokes windeployqt_wrapper.cmake after -# CommandExecution.cmake finishes. We don't want to run this script 2x, so -# detect this case and exit early - -# Find the first -P argument -foreach(argi RANGE 1 ${CMAKE_ARGC}) - if("${CMAKE_ARGV${argi}}" STREQUAL "-P") - math(EXPR script_argi "${argi} + 1") - set(script_file "${CMAKE_ARGV${script_argi}}") - break() - endif() -endforeach() - -if(NOT script_file STREQUAL "${CMAKE_CURRENT_LIST_FILE}") - return() -endif() - -set(runtime_directory ${CMAKE_ARGV3}) - -foreach(argi RANGE 4 ${CMAKE_ARGC}) - list(APPEND command_arguments "${CMAKE_ARGV${argi}}") -endforeach() -execute_process(COMMAND ${command_arguments} RESULT_VARIABLE command_result OUTPUT_VARIABLE command_output ERROR_VARIABLE command_err) - -if(command_result) - message(FATAL_ERROR "windeployqt returned a non-zero exit status. stdout: ${command_output} stderr: ${command_err}") -endif() - -# Process the output to find the list of files that were updated - -# Transform the output to a list -string(REGEX REPLACE ";" "\\\\;" command_output "${command_output}") -string(REGEX REPLACE "\n" ";" command_output "${command_output}") - -foreach(line IN LISTS command_output) - # windeployqt has output that looks like this if it updated a file: - # > Checking /path/to/src/file.so, /path/to/dst/file.so - # > Updating file.so - # If the file was not modified, it will look like this: - # > Checking /path/to/src/file.so, /path/to/dst/file.so - # > file.so is up to date - if(line MATCHES "^Checking .*") - set(curfile "${line}") - continue() - endif() - - if(line MATCHES "^Updating .*") - # curline has 3 parts, 1) "Checking ", 2) source_file, 3) updated_target_file. We - # just need part 3. But we also want to handle the unfortunate - # possibility of spaces in the filename. - - string(REGEX REPLACE "^Checking " "" curfile "${curfile}") - string(REPLACE ", " ";" curfile "${curfile}") - list(LENGTH curfile curfile_parts_count) - if(NOT curfile_parts_count EQUAL 2) - message(SEND_ERROR "Unable to parse output of windeployqt output line ${curfile}") - continue() - endif() - list(GET curfile 1 updated_file) - - file(RELATIVE_PATH relative_file "${runtime_directory}" "${updated_file}") - - get_filename_component(basename "${relative_file}" NAME) - if(basename MATCHES "^libQt5Core\\.so.*") - # We don't need to patch QtCore - continue() - endif() - - # READ_ELF has a CAPTURE_ERROR argument, but that is only set on - # platforms that don't support cmake's elf parser. On linux, no error - # will be set, even when the input is not an ELF formatted file. We - # want to skip any non-executable files, so check for the ELF tag at - # the head of the file. - file(READ "${updated_file}" elf_tag LIMIT 4 HEX) - if(NOT elf_tag STREQUAL 7f454c46) # Binary \0x7f followed by ELF - continue() - endif() - - # READ_ELF is an undocumented command that allows us to introspect the - # current rpath set in the file - file(READ_ELF "${updated_file}" RUNPATH plugin_runpath) - - get_filename_component(dirname "${relative_file}" DIRECTORY) - if(dirname) - file(RELATIVE_PATH parent_dirs "${updated_file}" "${runtime_directory}") - string(REGEX REPLACE "/../$" "" parent_dirs "${parent_dirs}") - set(new_runpath "\$ORIGIN/${parent_dirs}") - else() - set(new_runpath "\$ORIGIN") - endif() - - # RPATH_CHANGE is an undocumented command that allows for replacing an - # existing rpath entry with a new value, as long as the new value's - # strlen is <= the current rpath - file(RPATH_CHANGE FILE "${updated_file}" OLD_RPATH "${plugin_runpath}" NEW_RPATH "${new_runpath}") - - unset(curfile) - endif() -endforeach() diff --git a/cmake/Platform/Mac/PAL_mac.cmake b/cmake/Platform/Mac/PAL_mac.cmake index 477c8d4afb..f49578a83a 100644 --- a/cmake/Platform/Mac/PAL_mac.cmake +++ b/cmake/Platform/Mac/PAL_mac.cmake @@ -12,7 +12,6 @@ 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 deleted file mode 100644 index 7ab5f61f5d..0000000000 --- a/cmake/Platform/Mac/QtDeploy_mac.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# -# 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 fcbd8acb70..fbf65db63f 100644 --- a/cmake/Platform/Windows/PAL_windows.cmake +++ b/cmake/Platform/Windows/PAL_windows.cmake @@ -12,7 +12,6 @@ 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 deleted file mode 100644 index 2fb1a71114..0000000000 --- a/cmake/Platform/Windows/QtDeploy_windows.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# -# 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/Qt.cmake b/cmake/Qt.cmake deleted file mode 100644 index bf4ecb0f28..0000000000 --- a/cmake/Qt.cmake +++ /dev/null @@ -1,199 +0,0 @@ -# -# 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) From 355c5ced1ff2283cd4b5cb0969061f39940e3abe Mon Sep 17 00:00:00 2001 From: pappeste Date: Thu, 10 Jun 2021 14:48:09 -0700 Subject: [PATCH 03/16] fixing runtime dependencies for cases with multiple values --- Code/Sandbox/Editor/CMakeLists.txt | 1 - .../Common/RuntimeDependencies_common.cmake | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Code/Sandbox/Editor/CMakeLists.txt b/Code/Sandbox/Editor/CMakeLists.txt index e1fce97067..51620c6e37 100644 --- a/Code/Sandbox/Editor/CMakeLists.txt +++ b/Code/Sandbox/Editor/CMakeLists.txt @@ -104,7 +104,6 @@ ly_add_target( 3rdParty::Qt::Gui 3rdParty::Qt::Widgets 3rdParty::Qt::Concurrent - 3rdParty::Qt::WebEngineWidgets 3rdParty::tiff 3rdParty::squish-ccr 3rdParty::zlib diff --git a/cmake/Platform/Common/RuntimeDependencies_common.cmake b/cmake/Platform/Common/RuntimeDependencies_common.cmake index 57484da9eb..10fcae6297 100644 --- a/cmake/Platform/Common/RuntimeDependencies_common.cmake +++ b/cmake/Platform/Common/RuntimeDependencies_common.cmake @@ -113,12 +113,13 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET) set(imported_property IMPORTED_LOCATION) endif() - set(target_locations) - get_target_property(current_target_locations ${ly_TARGET} ${imported_property}) - if(current_target_locations) - string(APPEND target_locations ${current_target_locations}) + unset(target_locations) + get_target_property(target_locations ${ly_TARGET} ${imported_property}) + if(target_locations) + list(APPEND all_runtime_dependencies ${target_locations}) else() # Check if the property exists for configurations + unset(target_locations) foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER ${conf} UCONF) unset(current_target_locations) @@ -129,6 +130,7 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET) # try to use the mapping get_target_property(mapped_conf ${ly_TARGET} MAP_IMPORTED_CONFIG_${UCONF}) if(mapped_conf) + unset(current_target_locations) get_target_property(current_target_locations ${ly_TARGET} ${imported_property}_${mapped_conf}) if(current_target_locations) string(APPEND target_locations $<$:${current_target_locations}>) @@ -136,10 +138,11 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET) endif() endif() endforeach() + if(target_locations) + list(APPEND all_runtime_dependencies ${target_locations}) + endif() endif() - if(target_locations) - list(APPEND all_runtime_dependencies ${target_locations}) - endif() + endif() endif() From b5c7a3544205fb7e41a29da806308e42b03bcca0 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Thu, 10 Jun 2021 19:22:40 -0700 Subject: [PATCH 04/16] working with fixup bundle and incrementals of 1s --- cmake/CommandExecution.cmake | 5 -- .../Android/RuntimeDependencies_android.cmake | 15 +++++ .../Common/RuntimeDependencies_common.cmake | 19 +------ .../Linux/RuntimeDependencies_linux.cmake | 15 +++++ .../Mac/RuntimeDependencies_mac.cmake | 57 +++++++++++++++++++ .../Windows/RuntimeDependencies_windows.cmake | 15 +++++ 6 files changed, 105 insertions(+), 21 deletions(-) diff --git a/cmake/CommandExecution.cmake b/cmake/CommandExecution.cmake index a10e30eb26..3ed084bb42 100644 --- a/cmake/CommandExecution.cmake +++ b/cmake/CommandExecution.cmake @@ -88,8 +88,3 @@ if(LY_TIMESTAMP_REFERENCE) # Touch the timestamp file file(TOUCH ${LY_TIMESTAMP_FILE}) endif() - -if(LY_LOCK_FILE) - file(LOCK ${LY_LOCK_FILE} RELEASE) - file(REMOVE ${LY_LOCK_FILE}) -endif() \ No newline at end of file diff --git a/cmake/Platform/Android/RuntimeDependencies_android.cmake b/cmake/Platform/Android/RuntimeDependencies_android.cmake index 8b50ec465d..f90ff23b8d 100644 --- a/cmake/Platform/Android/RuntimeDependencies_android.cmake +++ b/cmake/Platform/Android/RuntimeDependencies_android.cmake @@ -9,4 +9,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(LY_RUNTIME_DEPENDENCIES_HEADER +"function(ly_copy source_file target_directory) + get_filename_component(target_filename \"\${source_file}\" NAME) + if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") + if(NOT EXISTS \"\${target_directory}\") + file(MAKE_DIRECTORY \"\${target_directory}\") + endif() + if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") + file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) + file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) + endif() + endif() +endfunction() +\n") + include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file diff --git a/cmake/Platform/Common/RuntimeDependencies_common.cmake b/cmake/Platform/Common/RuntimeDependencies_common.cmake index 10fcae6297..bab3f72265 100644 --- a/cmake/Platform/Common/RuntimeDependencies_common.cmake +++ b/cmake/Platform/Common/RuntimeDependencies_common.cmake @@ -247,22 +247,7 @@ function(ly_delayed_generate_runtime_dependencies) endif() unset(runtime_dependencies) - set(runtime_commands " -function(ly_copy source_file target_directory) - get_filename_component(target_filename \"\${source_file}\" NAME) - if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") - if(NOT EXISTS \"\${target_directory}\") - file(MAKE_DIRECTORY \"\${target_directory}\") - endif() - if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") - file(LOCK \"\${target_directory}/\${target_filename}.lock\" GUARD FUNCTION TIMEOUT 30) - file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) - file(LOCK \"\${target_directory}/\${target_filename}.lock\" RELEASE) - file(REMOVE \"\${target_directory}/\${target_filename}.lock\") - endif() - endif() -endfunction() - \n") + set(runtime_commands ${LY_RUNTIME_DEPENDENCIES_HEADER}) ly_get_runtime_dependencies(runtime_dependencies ${target}) foreach(runtime_dependency ${runtime_dependencies}) @@ -270,6 +255,8 @@ endfunction() ly_get_runtime_dependency_command(runtime_command ${runtime_dependency}) string(APPEND runtime_commands ${runtime_command}) endforeach() + + string(APPEND runtime_commands ${LY_RUNTIME_DEPENDENCIES_FOOTER}) # Generate the output file set(target_file_dir "$") diff --git a/cmake/Platform/Linux/RuntimeDependencies_linux.cmake b/cmake/Platform/Linux/RuntimeDependencies_linux.cmake index 8b50ec465d..6483250ab2 100644 --- a/cmake/Platform/Linux/RuntimeDependencies_linux.cmake +++ b/cmake/Platform/Linux/RuntimeDependencies_linux.cmake @@ -9,4 +9,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(LY_RUNTIME_DEPENDENCIES_HEADER +"function(ly_copy source_file target_directory) + get_filename_component(target_filename \"\${source_file}\" NAME) + if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") + if(NOT EXISTS \"\${target_directory}\") + file(MAKE_DIRECTORY \"\${target_directory}\") + endif() + if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") + file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) + file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS} FOLLOW_SYMLINK_CHAIN) + endif() + endif() +endfunction() +\n") + include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file diff --git a/cmake/Platform/Mac/RuntimeDependencies_mac.cmake b/cmake/Platform/Mac/RuntimeDependencies_mac.cmake index 8b50ec465d..169b6d2764 100644 --- a/cmake/Platform/Mac/RuntimeDependencies_mac.cmake +++ b/cmake/Platform/Mac/RuntimeDependencies_mac.cmake @@ -9,4 +9,61 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(LY_RUNTIME_DEPENDENCIES_HEADER +" +set(anything_new FALSE) + +function(ly_copy source_file target_directory) + # If source_file is a Framework and target_directory is a bundle + if(\"\${source_file}\" MATCHES \".[Ff]ramework\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") + return() # skip, it will be fixed with fixup_bundle + elseif(\"\${source_file}\" MATCHES \"qt/plugins\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") + # fixup the destination so it ends up in Contents/Plugins + string(REGEX REPLACE \"(.*.app/Contents)/MacOS(.*)\" \"\\\\1/plugins\\\\2\" target_directory \"\${target_directory}\") + elseif(\"\${source_file}\" MATCHES \"qt/translations\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") + return() # skip + endif() + get_filename_component(target_filename \"\${source_file}\" NAME) + if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") + if(NOT EXISTS \"\${target_directory}\") + file(MAKE_DIRECTORY \"\${target_directory}\") + endif() + if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") + file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) + file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS} FOLLOW_SYMLINK_CHAIN) + set(anything_new TRUE) + endif() + endif() +endfunction() +\n") + +set(LY_RUNTIME_DEPENDENCIES_FOOTER +" +if(@target_file_dir@ MATCHES \".app/Contents/MacOS\") + if(NOT anything_new) + string(REGEX REPLACE \"(.*.app)/Contents/MacOS.*\" \"\\\\1\" bundle_path \"@target_file_dir@\") + set(timestamp_file \"\${bundle_path}.fixup.stamp\") + if(NOT EXISTS \"\${timestamp_file}\") + set(anything_new TRUE) + else() + file(GLOB_RECURSE files_in_bundle FOLLOW_SYMLINKS \"\${bundle_path}\") + foreach(file \${files_in_bundle}) + if(\${file} IS_NEWER_THAN \"\${timestamp_file}\") + set(anything_new TRUE) + break() + endif() + endforeach() + endif() + endif() + if(anything_new) + include(BundleUtilities) + fixup_bundle(\"\${bundle_path}\" \"\" \"\") + file(TOUCH \"\${timestamp_file}\") + endif() +endif() +") + + + + include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file diff --git a/cmake/Platform/Windows/RuntimeDependencies_windows.cmake b/cmake/Platform/Windows/RuntimeDependencies_windows.cmake index 8b50ec465d..f90ff23b8d 100644 --- a/cmake/Platform/Windows/RuntimeDependencies_windows.cmake +++ b/cmake/Platform/Windows/RuntimeDependencies_windows.cmake @@ -9,4 +9,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(LY_RUNTIME_DEPENDENCIES_HEADER +"function(ly_copy source_file target_directory) + get_filename_component(target_filename \"\${source_file}\" NAME) + if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") + if(NOT EXISTS \"\${target_directory}\") + file(MAKE_DIRECTORY \"\${target_directory}\") + endif() + if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") + file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) + file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) + endif() + endif() +endfunction() +\n") + include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file From e7d86992935176c7c6eb3770dad142e8a5cb7035 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Thu, 10 Jun 2021 20:23:22 -0700 Subject: [PATCH 05/16] passing plugin dirs --- cmake/Platform/Mac/RuntimeDependencies_mac.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/Platform/Mac/RuntimeDependencies_mac.cmake b/cmake/Platform/Mac/RuntimeDependencies_mac.cmake index 169b6d2764..e89dedfc8b 100644 --- a/cmake/Platform/Mac/RuntimeDependencies_mac.cmake +++ b/cmake/Platform/Mac/RuntimeDependencies_mac.cmake @@ -12,18 +12,25 @@ set(LY_RUNTIME_DEPENDENCIES_HEADER " set(anything_new FALSE) +set(plugin_libs) +set(plugin_dirs) function(ly_copy source_file target_directory) + get_filename_component(target_filename \"\${source_file}\" NAME) + get_filename_component(source_file_dir \"\${source_file}\" DIRECTORY) # If source_file is a Framework and target_directory is a bundle if(\"\${source_file}\" MATCHES \".[Ff]ramework\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") + set(plugin_dirs \"\${plugin_dirs};\${source_file_dir}\" PARENT_SCOPE) return() # skip, it will be fixed with fixup_bundle elseif(\"\${source_file}\" MATCHES \"qt/plugins\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") # fixup the destination so it ends up in Contents/Plugins - string(REGEX REPLACE \"(.*.app/Contents)/MacOS(.*)\" \"\\\\1/plugins\\\\2\" target_directory \"\${target_directory}\") + set(plugin_dirs \"\${plugin_dirs};\${source_file_dir}\" PARENT_SCOPE) + set(plugin_libs \"\${plugin_libs};\${target_directory}/\${target_filename}\" PARENT_SCOPE) elseif(\"\${source_file}\" MATCHES \"qt/translations\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") return() # skip + elseif(\"\${source_file}\" MATCHES \".dylib\") + set(plugin_dirs \"\${plugin_dirs};\${source_file_dir}\" PARENT_SCOPE) endif() - get_filename_component(target_filename \"\${source_file}\" NAME) if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") if(NOT EXISTS \"\${target_directory}\") file(MAKE_DIRECTORY \"\${target_directory}\") @@ -57,7 +64,9 @@ if(@target_file_dir@ MATCHES \".app/Contents/MacOS\") endif() if(anything_new) include(BundleUtilities) - fixup_bundle(\"\${bundle_path}\" \"\" \"\") + list(REMOVE_DUPLICATES plugin_libs) + list(REMOVE_DUPLICATES plugin_dirs) + fixup_bundle(\"\${bundle_path}\" \"\${plugin_libs}\" \"\${plugin_dirs}\") file(TOUCH \"\${timestamp_file}\") endif() endif() From 4a53d791585aea868e5cecc0d0ecddf80bae7fe8 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Fri, 11 Jun 2021 18:08:55 -0700 Subject: [PATCH 06/16] Fixup editor bundle working --- .../Android/RuntimeDependencies_android.cmake | 16 +- .../Common/RuntimeDependencies_common.cmake | 12 +- .../runtime_dependencies_common.cmake.in | 25 ++++ .../Linux/RuntimeDependencies_linux.cmake | 16 +- .../Mac/RuntimeDependencies_mac.cmake | 67 +-------- .../Mac/runtime_dependencies_mac.cmake.in | 139 ++++++++++++++++++ .../Windows/RuntimeDependencies_windows.cmake | 16 +- 7 files changed, 175 insertions(+), 116 deletions(-) create mode 100644 cmake/Platform/Common/runtime_dependencies_common.cmake.in create mode 100644 cmake/Platform/Mac/runtime_dependencies_mac.cmake.in diff --git a/cmake/Platform/Android/RuntimeDependencies_android.cmake b/cmake/Platform/Android/RuntimeDependencies_android.cmake index f90ff23b8d..add036a8b8 100644 --- a/cmake/Platform/Android/RuntimeDependencies_android.cmake +++ b/cmake/Platform/Android/RuntimeDependencies_android.cmake @@ -9,19 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -set(LY_RUNTIME_DEPENDENCIES_HEADER -"function(ly_copy source_file target_directory) - get_filename_component(target_filename \"\${source_file}\" NAME) - if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") - if(NOT EXISTS \"\${target_directory}\") - file(MAKE_DIRECTORY \"\${target_directory}\") - endif() - if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") - file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) - file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) - endif() - endif() -endfunction() -\n") - +set(LY_RUNTIME_DEPENDENCIES_TEMPLATE ${LY_ROOT_FOLDER}/cmake/Platform/Common/runtime_dependencies_common.cmake.in) include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file diff --git a/cmake/Platform/Common/RuntimeDependencies_common.cmake b/cmake/Platform/Common/RuntimeDependencies_common.cmake index bab3f72265..d00dd71f1e 100644 --- a/cmake/Platform/Common/RuntimeDependencies_common.cmake +++ b/cmake/Platform/Common/RuntimeDependencies_common.cmake @@ -247,23 +247,23 @@ function(ly_delayed_generate_runtime_dependencies) endif() unset(runtime_dependencies) - set(runtime_commands ${LY_RUNTIME_DEPENDENCIES_HEADER}) + unset(LY_COPY_COMMANDS) ly_get_runtime_dependencies(runtime_dependencies ${target}) foreach(runtime_dependency ${runtime_dependencies}) unset(runtime_command) ly_get_runtime_dependency_command(runtime_command ${runtime_dependency}) - string(APPEND runtime_commands ${runtime_command}) + string(APPEND LY_COPY_COMMANDS ${runtime_command}) endforeach() - string(APPEND runtime_commands ${LY_RUNTIME_DEPENDENCIES_FOOTER}) - # Generate the output file set(target_file_dir "$") - string(CONFIGURE "${runtime_commands}" generated_commands @ONLY) + file(READ ${LY_RUNTIME_DEPENDENCIES_TEMPLATE} template_file) + string(CONFIGURE "${LY_COPY_COMMANDS}" LY_COPY_COMMANDS @ONLY) + string(CONFIGURE "${template_file}" configured_template_file @ONLY) file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/runtime_dependencies/$/${target}.cmake - CONTENT "${generated_commands}" + CONTENT "${configured_template_file}" ) endforeach() diff --git a/cmake/Platform/Common/runtime_dependencies_common.cmake.in b/cmake/Platform/Common/runtime_dependencies_common.cmake.in new file mode 100644 index 0000000000..b476b7d401 --- /dev/null +++ b/cmake/Platform/Common/runtime_dependencies_common.cmake.in @@ -0,0 +1,25 @@ +# +# 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. +# + +function(ly_copy source_file target_directory) + get_filename_component(target_filename "${source_file}" NAME) + if(NOT "${source_file}" STREQUAL "${target_directory}/${target_filename}") + if(NOT EXISTS "${target_directory}") + file(MAKE_DIRECTORY "${target_directory}") + endif() + if("${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") + file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" GUARD FUNCTION TIMEOUT 30) + file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + endif() + endif() +endfunction() + +@LY_COPY_COMMANDS@ diff --git a/cmake/Platform/Linux/RuntimeDependencies_linux.cmake b/cmake/Platform/Linux/RuntimeDependencies_linux.cmake index 6483250ab2..add036a8b8 100644 --- a/cmake/Platform/Linux/RuntimeDependencies_linux.cmake +++ b/cmake/Platform/Linux/RuntimeDependencies_linux.cmake @@ -9,19 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -set(LY_RUNTIME_DEPENDENCIES_HEADER -"function(ly_copy source_file target_directory) - get_filename_component(target_filename \"\${source_file}\" NAME) - if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") - if(NOT EXISTS \"\${target_directory}\") - file(MAKE_DIRECTORY \"\${target_directory}\") - endif() - if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") - file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) - file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS} FOLLOW_SYMLINK_CHAIN) - endif() - endif() -endfunction() -\n") - +set(LY_RUNTIME_DEPENDENCIES_TEMPLATE ${LY_ROOT_FOLDER}/cmake/Platform/Common/runtime_dependencies_common.cmake.in) include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file diff --git a/cmake/Platform/Mac/RuntimeDependencies_mac.cmake b/cmake/Platform/Mac/RuntimeDependencies_mac.cmake index e89dedfc8b..383a3d5985 100644 --- a/cmake/Platform/Mac/RuntimeDependencies_mac.cmake +++ b/cmake/Platform/Mac/RuntimeDependencies_mac.cmake @@ -9,70 +9,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -set(LY_RUNTIME_DEPENDENCIES_HEADER -" -set(anything_new FALSE) -set(plugin_libs) -set(plugin_dirs) - -function(ly_copy source_file target_directory) - get_filename_component(target_filename \"\${source_file}\" NAME) - get_filename_component(source_file_dir \"\${source_file}\" DIRECTORY) - # If source_file is a Framework and target_directory is a bundle - if(\"\${source_file}\" MATCHES \".[Ff]ramework\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") - set(plugin_dirs \"\${plugin_dirs};\${source_file_dir}\" PARENT_SCOPE) - return() # skip, it will be fixed with fixup_bundle - elseif(\"\${source_file}\" MATCHES \"qt/plugins\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") - # fixup the destination so it ends up in Contents/Plugins - set(plugin_dirs \"\${plugin_dirs};\${source_file_dir}\" PARENT_SCOPE) - set(plugin_libs \"\${plugin_libs};\${target_directory}/\${target_filename}\" PARENT_SCOPE) - elseif(\"\${source_file}\" MATCHES \"qt/translations\" AND \"\${target_directory}\" MATCHES \".app/Contents/MacOS\") - return() # skip - elseif(\"\${source_file}\" MATCHES \".dylib\") - set(plugin_dirs \"\${plugin_dirs};\${source_file_dir}\" PARENT_SCOPE) - endif() - if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") - if(NOT EXISTS \"\${target_directory}\") - file(MAKE_DIRECTORY \"\${target_directory}\") - endif() - if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") - file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) - file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS} FOLLOW_SYMLINK_CHAIN) - set(anything_new TRUE) - endif() - endif() -endfunction() -\n") - -set(LY_RUNTIME_DEPENDENCIES_FOOTER -" -if(@target_file_dir@ MATCHES \".app/Contents/MacOS\") - if(NOT anything_new) - string(REGEX REPLACE \"(.*.app)/Contents/MacOS.*\" \"\\\\1\" bundle_path \"@target_file_dir@\") - set(timestamp_file \"\${bundle_path}.fixup.stamp\") - if(NOT EXISTS \"\${timestamp_file}\") - set(anything_new TRUE) - else() - file(GLOB_RECURSE files_in_bundle FOLLOW_SYMLINKS \"\${bundle_path}\") - foreach(file \${files_in_bundle}) - if(\${file} IS_NEWER_THAN \"\${timestamp_file}\") - set(anything_new TRUE) - break() - endif() - endforeach() - endif() - endif() - if(anything_new) - include(BundleUtilities) - list(REMOVE_DUPLICATES plugin_libs) - list(REMOVE_DUPLICATES plugin_dirs) - fixup_bundle(\"\${bundle_path}\" \"\${plugin_libs}\" \"\${plugin_dirs}\") - file(TOUCH \"\${timestamp_file}\") - endif() -endif() -") - - - +set(LY_BUILD_FIXUP_BUNDLE TRUE CACHE BOOL "Fix bundles on build (deploys frameworks and calls fixup_bundle)") +set(LY_RUNTIME_DEPENDENCIES_TEMPLATE ${LY_ROOT_FOLDER}/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in) include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in new file mode 100644 index 0000000000..8a88df86cb --- /dev/null +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -0,0 +1,139 @@ +# +# 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(BundleUtilities) + +#set(BU_COPY_FULL_FRAMEWORK_CONTENTS ON) + +set(anything_new FALSE) +set(plugin_libs) +set(plugin_dirs) + +function(ly_copy source_file target_directory) + + get_filename_component(target_filename "${source_file}" NAME) + + # If source_file is a Framework and target_directory is a bundle + if("${source_file}" MATCHES "\\.[Ff]ramework[^\\.]" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS") + + if("@LY_BUILD_FIXUP_BUNDLE@" STREQUAL FALSE) + return() + endif() + + # fixup origin to copy the whole Framework folder and change destination to Contents/Frameworks + string(REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}") + string(REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/Frameworks" target_directory "${target_directory}") + + set(local_plugin_dirs ${plugin_dirs}) + list(APPEND local_plugin_dirs "${target_directory}") + set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE) + + elseif("${source_file}" MATCHES "qt/plugins" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS") + + if("@LY_BUILD_FIXUP_BUNDLE@" STREQUAL FALSE) + return() + endif() + + # fixup the destination so it ends up in Contents/Plugins + string(REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/plugins" target_directory "${target_directory}") + + set(local_plugin_dirs ${plugin_dirs}) + list(APPEND local_plugin_dirs "${target_directory}") + set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE) + set(local_plugin_libs ${plugin_libs}) + list(APPEND local_plugin_libs "${target_directory}/${target_filename}") + set(plugin_libs ${local_plugin_libs} PARENT_SCOPE) + + elseif("${source_file}" MATCHES "qt/translations" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS") + + return() # skip, is this used? + + elseif("${source_file}" MATCHES ".dylib") + + set(local_plugin_dirs ${plugin_dirs}) + list(APPEND local_plugin_dirs "${target_directory}") + set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE) + + endif() + + if(NOT "${source_file}" STREQUAL "${target_directory}/${target_filename}") + if(NOT EXISTS "${target_directory}") + file(MAKE_DIRECTORY "${target_directory}") + endif() + if(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") + file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" GUARD FUNCTION TIMEOUT 30) + message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") + file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + set(anything_new TRUE PARENT_SCOPE) + endif() + endif() +endfunction() + +@LY_COPY_COMMANDS@ + +if("@LY_BUILD_FIXUP_BUNDLE@" STREQUAL FALSE) + return() +endif() + +if(@target_file_dir@ MATCHES ".app/Contents/MacOS") + string(REGEX REPLACE "(.*\\.app)/Contents/MacOS.*" "\\1" bundle_path "@target_file_dir@") + if(NOT anything_new) + set(timestamp_file "${bundle_path}.fixup.stamp") + if(NOT EXISTS "${timestamp_file}") + set(anything_new TRUE) + else() + file(GLOB_RECURSE files_in_bundle FOLLOW_SYMLINKS "${bundle_path}") + foreach(file ${files_in_bundle}) + if(${file} IS_NEWER_THAN "${timestamp_file}") + set(anything_new TRUE) + break() + endif() + endforeach() + endif() + endif() + if(anything_new) + # LYN-4505: Patch dxc, is configured in the wrong folder in 3p + if(EXISTS ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7) + file(RENAME + ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/lib/libdxcompiler.3.7.dylib + ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/libdxcompiler.3.7.dylib + ) + endif() + if(EXISTS ${bundle_path}/Contents/Frameworks/Python.framework) + # LYN-4502: Patch python bundle, it contains some windows executables, some files that fixup_bundle doesnt like and has + # duplicated binaries between Versions/3.7 and Versions/Current. + file(GLOB exe_files + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/*.exe + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/distlib/*.exe + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/*.exe + ) + foreach(exe_file ${exe_files}) + file(REMOVE ${exe_file}) + endforeach() + file(REMOVE_RECURSE + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/test + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scipy/io/tests + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Resources + ${bundle_path}/Contents/Frameworks/Python.framework/Python + ${bundle_path}/Contents/Frameworks/Python.framework/Resources/Python.app + ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Python + ) + file(REMOVE_RECURSE ${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current) + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink 3.7 Current + WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework/Versions/ + ) + endif() + list(REMOVE_DUPLICATES plugin_libs) + list(REMOVE_DUPLICATES plugin_dirs) + fixup_bundle("${bundle_path}" "${plugin_libs}" "${plugin_dirs}") + file(TOUCH "${timestamp_file}") + endif() +endif() diff --git a/cmake/Platform/Windows/RuntimeDependencies_windows.cmake b/cmake/Platform/Windows/RuntimeDependencies_windows.cmake index f90ff23b8d..add036a8b8 100644 --- a/cmake/Platform/Windows/RuntimeDependencies_windows.cmake +++ b/cmake/Platform/Windows/RuntimeDependencies_windows.cmake @@ -9,19 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -set(LY_RUNTIME_DEPENDENCIES_HEADER -"function(ly_copy source_file target_directory) - get_filename_component(target_filename \"\${source_file}\" NAME) - if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\") - if(NOT EXISTS \"\${target_directory}\") - file(MAKE_DIRECTORY \"\${target_directory}\") - endif() - if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\") - file(LOCK \"\${CMAKE_BINARY_DIR}/runtimedependencies.lock\" GUARD FUNCTION TIMEOUT 30) - file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS}) - endif() - endif() -endfunction() -\n") - +set(LY_RUNTIME_DEPENDENCIES_TEMPLATE ${LY_ROOT_FOLDER}/cmake/Platform/Common/runtime_dependencies_common.cmake.in) include(cmake/Platform/Common/RuntimeDependencies_common.cmake) \ No newline at end of file From 6e2e187e31c0f91eeee6cce5da7a8310a1696dd2 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Fri, 11 Jun 2021 18:52:03 -0700 Subject: [PATCH 07/16] improve incremental --- .../Mac/runtime_dependencies_mac.cmake.in | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index 8a88df86cb..58bac188fd 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -72,6 +72,7 @@ function(ly_copy source_file target_directory) file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" GUARD FUNCTION TIMEOUT 30) message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + file(TOUCH ${target_directory}/${target_filename}) set(anything_new TRUE PARENT_SCOPE) endif() endif() @@ -85,26 +86,18 @@ endif() if(@target_file_dir@ MATCHES ".app/Contents/MacOS") string(REGEX REPLACE "(.*\\.app)/Contents/MacOS.*" "\\1" bundle_path "@target_file_dir@") + set(fixup_timestamp_file "${bundle_path}.fixup.stamp") if(NOT anything_new) - set(timestamp_file "${bundle_path}.fixup.stamp") - if(NOT EXISTS "${timestamp_file}") + if(NOT EXISTS "${fixup_timestamp_file}" OR "${bundle_path}" IS_NEWER_THAN "${fixup_timestamp_file}") set(anything_new TRUE) - else() - file(GLOB_RECURSE files_in_bundle FOLLOW_SYMLINKS "${bundle_path}") - foreach(file ${files_in_bundle}) - if(${file} IS_NEWER_THAN "${timestamp_file}") - set(anything_new TRUE) - break() - endif() - endforeach() endif() endif() if(anything_new) # LYN-4505: Patch dxc, is configured in the wrong folder in 3p if(EXISTS ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7) - file(RENAME - ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/lib/libdxcompiler.3.7.dylib - ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin/libdxcompiler.3.7.dylib + # we copy to not invalidate the copy check from above + file(COPY ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/lib/libdxcompiler.3.7.dylib + DESTINATION ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin ) endif() if(EXISTS ${bundle_path}/Contents/Frameworks/Python.framework) @@ -134,6 +127,7 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS") list(REMOVE_DUPLICATES plugin_libs) list(REMOVE_DUPLICATES plugin_dirs) fixup_bundle("${bundle_path}" "${plugin_libs}" "${plugin_dirs}") - file(TOUCH "${timestamp_file}") + file(TOUCH "${bundle_path}") + file(TOUCH "${fixup_timestamp_file}") endif() endif() From 02dd2138cb36a69689863346eb764030dc55ee62 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Mon, 14 Jun 2021 13:46:51 -0700 Subject: [PATCH 08/16] improving the check so it doesnt have to be "FALSE" (and can be 0/Off/etc) --- cmake/Platform/Mac/runtime_dependencies_mac.cmake.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index 58bac188fd..e67702e902 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -24,7 +24,7 @@ function(ly_copy source_file target_directory) # If source_file is a Framework and target_directory is a bundle if("${source_file}" MATCHES "\\.[Ff]ramework[^\\.]" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS") - if("@LY_BUILD_FIXUP_BUNDLE@" STREQUAL FALSE) + if(NOT @LY_BUILD_FIXUP_BUNDLE@) return() endif() @@ -38,7 +38,7 @@ function(ly_copy source_file target_directory) elseif("${source_file}" MATCHES "qt/plugins" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS") - if("@LY_BUILD_FIXUP_BUNDLE@" STREQUAL FALSE) + if(NOT @LY_BUILD_FIXUP_BUNDLE@) return() endif() @@ -68,8 +68,10 @@ function(ly_copy source_file target_directory) if(NOT EXISTS "${target_directory}") file(MAKE_DIRECTORY "${target_directory}") endif() - if(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") - file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" GUARD FUNCTION TIMEOUT 30) + if(IS_DIRECTORY ${source_file}) + message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") + file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) + elseif(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) file(TOUCH ${target_directory}/${target_filename}) @@ -80,7 +82,7 @@ endfunction() @LY_COPY_COMMANDS@ -if("@LY_BUILD_FIXUP_BUNDLE@" STREQUAL FALSE) +if(NOT @LY_BUILD_FIXUP_BUNDLE@) return() endif() From 310f1b79dd6f711eef67435ef6439e029e55373e Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Mon, 14 Jun 2021 15:45:40 -0700 Subject: [PATCH 09/16] plugins should be handled by fixup_bundle --- cmake/Platform/Mac/runtime_dependencies_mac.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index e67702e902..a0b418daff 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -35,6 +35,7 @@ function(ly_copy source_file target_directory) set(local_plugin_dirs ${plugin_dirs}) list(APPEND local_plugin_dirs "${target_directory}") set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE) + return() elseif("${source_file}" MATCHES "qt/plugins" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS") From 411bbc8e2fd1f35b074efae51e68abb06875c4c6 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Mon, 14 Jun 2021 17:03:09 -0700 Subject: [PATCH 10/16] removed the copy of bundles since fixup_bundle does a better job --- .../Mac/runtime_dependencies_mac.cmake.in | 62 +++++++++---------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index a0b418daff..a51260fd3f 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -11,8 +11,6 @@ include(BundleUtilities) -#set(BU_COPY_FULL_FRAMEWORK_CONTENTS ON) - set(anything_new FALSE) set(plugin_libs) set(plugin_dirs) @@ -30,10 +28,10 @@ function(ly_copy source_file target_directory) # fixup origin to copy the whole Framework folder and change destination to Contents/Frameworks string(REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}") - string(REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/Frameworks" target_directory "${target_directory}") - + get_filename_component(source_file_folder "${source_file}" DIRECTORY) + set(local_plugin_dirs ${plugin_dirs}) - list(APPEND local_plugin_dirs "${target_directory}") + list(APPEND local_plugin_dirs "${source_file_folder}") set(plugin_dirs ${local_plugin_dirs} PARENT_SCOPE) return() @@ -69,10 +67,7 @@ function(ly_copy source_file target_directory) if(NOT EXISTS "${target_directory}") file(MAKE_DIRECTORY "${target_directory}") endif() - if(IS_DIRECTORY ${source_file}) - message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") - file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) - elseif(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") + if(NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") message(STATUS "Copying \"${source_file}\" to \"${target_directory}\"...") file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) file(TOUCH ${target_directory}/${target_filename}) @@ -103,30 +98,31 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS") DESTINATION ${bundle_path}/Contents/MacOS/Builders/DirectXShaderCompiler/bin ) endif() - if(EXISTS ${bundle_path}/Contents/Frameworks/Python.framework) - # LYN-4502: Patch python bundle, it contains some windows executables, some files that fixup_bundle doesnt like and has - # duplicated binaries between Versions/3.7 and Versions/Current. - file(GLOB exe_files - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/*.exe - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/distlib/*.exe - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/*.exe - ) - foreach(exe_file ${exe_files}) - file(REMOVE ${exe_file}) - endforeach() - file(REMOVE_RECURSE - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/test - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scipy/io/tests - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Resources - ${bundle_path}/Contents/Frameworks/Python.framework/Python - ${bundle_path}/Contents/Frameworks/Python.framework/Resources/Python.app - ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Python - ) - file(REMOVE_RECURSE ${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink 3.7 Current - WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework/Versions/ - ) - endif() + # Python.framework being copied by fixup_bundle + #if(EXISTS ${bundle_path}/Contents/Frameworks/Python.framework) + # # LYN-4502: Patch python bundle, it contains some windows executables, some files that fixup_bundle doesnt like and has + # # duplicated binaries between Versions/3.7 and Versions/Current. + # file(GLOB exe_files + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/*.exe + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/distlib/*.exe + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/*.exe + # ) + # foreach(exe_file ${exe_files}) + # file(REMOVE ${exe_file}) + # endforeach() + # file(REMOVE_RECURSE + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/test + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scipy/io/tests + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Resources + # ${bundle_path}/Contents/Frameworks/Python.framework/Python + # ${bundle_path}/Contents/Frameworks/Python.framework/Resources/Python.app + # ${bundle_path}/Contents/Frameworks/Python.framework/Versions/3.7/Python + # ) + # file(REMOVE_RECURSE ${bundle_path}/Contents/Frameworks/Python.framework/Versions/Current) + # execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink 3.7 Current + # WORKING_DIRECTORY ${bundle_path}/Contents/Frameworks/Python.framework/Versions/ + # ) + #endif() list(REMOVE_DUPLICATES plugin_libs) list(REMOVE_DUPLICATES plugin_dirs) fixup_bundle("${bundle_path}" "${plugin_libs}" "${plugin_dirs}") From 6ea80176464db9a2c9bdcf6c799454da25e8fd80 Mon Sep 17 00:00:00 2001 From: pappeste Date: Tue, 15 Jun 2021 17:09:49 -0700 Subject: [PATCH 11/16] Update qt versions and add missing dependency --- Code/Framework/AzToolsFramework/CMakeLists.txt | 2 ++ cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake | 2 +- cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake | 2 +- cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzToolsFramework/CMakeLists.txt b/Code/Framework/AzToolsFramework/CMakeLists.txt index 53dba8eb48..661cb43302 100644 --- a/Code/Framework/AzToolsFramework/CMakeLists.txt +++ b/Code/Framework/AzToolsFramework/CMakeLists.txt @@ -85,6 +85,8 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) AZ::AzManipulatorTestFramework.Static AZ::AzTest AZ::AzQtComponents + RUNTIME_DEPENDENCIES + 3rdParty::Qt::Test ) ly_add_googletest( NAME AZ::AzToolsFramework.Tests diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index 3220271b42..fcc2ef4fe6 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -44,7 +44,7 @@ ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-linux ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-linux TARGETS googletest PACKAGE_HASH 7b7ad330f369450c316a4c4592d17fbb4c14c731c95bd8f37757203e8c2bbc1b) ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-linux TARGETS GoogleBenchmark PACKAGE_HASH 4038878f337fc7e0274f0230f71851b385b2e0327c495fc3dd3d1c18a807928d) ly_associate_package(PACKAGE_NAME unwind-1.2.1-linux TARGETS unwind PACKAGE_HASH 3453265fb056e25432f611a61546a25f60388e315515ad39007b5925dd054a77) -ly_associate_package(PACKAGE_NAME qt-5.15.2-rev3-linux TARGETS Qt PACKAGE_HASH b7d9932647f4b138b3f0b124d70debd250d2a8a6dca52b04dcbe82c6369d48ca) +ly_associate_package(PACKAGE_NAME qt-5.15.2-rev4-linux TARGETS Qt PACKAGE_HASH 1122e0ec19b01cb02a11fcf34dbf884bc9049ba5ff04fb692bfb09d4e5ee1e6b) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-linux TARGETS libsamplerate PACKAGE_HASH 41643c31bc6b7d037f895f89d8d8d6369e906b92eff42b0fe05ee6a100f06261) ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev2-linux TARGETS OpenSSL PACKAGE_HASH b779426d1e9c5ddf71160d5ae2e639c3b956e0fb5e9fcaf9ce97c4526024e3bc) ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-1.6.2104-o3de-rev2-linux TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 235606f98512c076a1ba84a8402ad24ac21945998abcea264e8e204678efc0ba) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index 3908d21ecf..b97209e8f7 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -46,5 +46,5 @@ ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-mac ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-mac TARGETS googletest PACKAGE_HASH cbf020d5ef976c5db8b6e894c6c63151ade85ed98e7c502729dd20172acae5a8) ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-mac TARGETS GoogleBenchmark PACKAGE_HASH ad25de0146769c91e179953d845de2bec8ed4a691f973f47e3eb37639381f665) ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-mac TARGETS OpenSSL PACKAGE_HASH 28adc1c0616ac0482b2a9d7b4a3a3635a1020e87b163f8aba687c501cf35f96c) -ly_associate_package(PACKAGE_NAME qt-5.15.2-rev3-mac TARGETS Qt PACKAGE_HASH 4723ac43b19d4633c3fa4b9642f27c992d30cdc689f769f82869786f1c22a728) +ly_associate_package(PACKAGE_NAME qt-5.15.2-rev4-mac TARGETS Qt PACKAGE_HASH 08790d03a0e6ad808ad64cf25c3d75abd69a343f3d224fc39927e5c6e8738b98) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-mac TARGETS libsamplerate PACKAGE_HASH b912af40c0ac197af9c43d85004395ba92a6a859a24b7eacd920fed5854a97fe) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index 19e71f726c..eb1047c20a 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -50,7 +50,7 @@ ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-windows ly_associate_package(PACKAGE_NAME d3dx12-headers-rev1-windows TARGETS d3dx12 PACKAGE_HASH 088c637159fba4a3e4c0cf08fb4921906fd4cca498939bd239db7c54b5b2f804) ly_associate_package(PACKAGE_NAME pyside2-qt-5.15.1-rev2-windows TARGETS pyside2 PACKAGE_HASH c90f3efcc7c10e79b22a33467855ad861f9dbd2e909df27a5cba9db9fa3edd0f) ly_associate_package(PACKAGE_NAME openimageio-2.1.16.0-rev2-windows TARGETS OpenImageIO PACKAGE_HASH 85a2a6cf35cbc4c967c56ca8074babf0955c5b490c90c6e6fd23c78db99fc282) -ly_associate_package(PACKAGE_NAME qt-5.15.2-rev2-windows TARGETS Qt PACKAGE_HASH 29966f22ec253dc9904e88ad48fe6b6a669302b2dc7049f2e2bbd4949e79e595) +ly_associate_package(PACKAGE_NAME qt-5.15.2-rev4-windows TARGETS Qt PACKAGE_HASH a4634caaf48192cad5c5f408504746e53d338856148285057274f6a0ccdc071d) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-windows TARGETS libsamplerate PACKAGE_HASH dcf3c11a96f212a52e2c9241abde5c364ee90b0f32fe6eeb6dcdca01d491829f) ly_associate_package(PACKAGE_NAME OpenMesh-8.1-rev1-windows TARGETS OpenMesh PACKAGE_HASH 1c1df639358526c368e790dfce40c45cbdfcfb1c9a041b9d7054a8949d88ee77) ly_associate_package(PACKAGE_NAME civetweb-1.8-rev1-windows TARGETS civetweb PACKAGE_HASH 36d0e58a59bcdb4dd70493fb1b177aa0354c945b06c30416348fd326cf323dd4) From 3c10db99e0e10d6a53f9fd5cf8fa7c3a4f68acac Mon Sep 17 00:00:00 2001 From: pappeste Date: Tue, 15 Jun 2021 17:45:29 -0700 Subject: [PATCH 12/16] Review cleanup --- .../Code/Platform/Windows/lrelease_windows.cmake | 16 ++++++++++++++++ cmake/Platform/iOS/PAL_ios.cmake | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake b/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake index 4d5680a30d..73e1fb82c1 100644 --- a/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake +++ b/Gems/LmbrCentral/Code/Platform/Windows/lrelease_windows.cmake @@ -8,3 +8,19 @@ # 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. # + +add_custom_command(TARGET LmbrCentral.Editor POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -DLY_TIMESTAMP_REFERENCE=$/lrelease.exe + -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 + $/lrelease.exe + COMMENT "Patching lrelease..." + VERBATIM +) diff --git a/cmake/Platform/iOS/PAL_ios.cmake b/cmake/Platform/iOS/PAL_ios.cmake index e9e38ac494..981bb9cab1 100644 --- a/cmake/Platform/iOS/PAL_ios.cmake +++ b/cmake/Platform/iOS/PAL_ios.cmake @@ -12,7 +12,6 @@ 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) From 1121299efca512aab3c8499590e884baf085d78b Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Tue, 15 Jun 2021 18:58:23 -0700 Subject: [PATCH 13/16] Set policy to avoid warnings on runtime dependencies --- cmake/Platform/Mac/runtime_dependencies_mac.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index a51260fd3f..f7e267eb2f 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -11,6 +11,8 @@ include(BundleUtilities) +cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of the LY_BUILD_FIXUP_BUNDLE expansion + set(anything_new FALSE) set(plugin_libs) set(plugin_dirs) From daacd25fc9a8a225176475a9074f7a8d9c2ef05b Mon Sep 17 00:00:00 2001 From: pappeste Date: Tue, 15 Jun 2021 19:24:13 -0700 Subject: [PATCH 14/16] change STREQUAL to cmake_path(COMPARE --- cmake/Platform/Common/runtime_dependencies_common.cmake.in | 5 ++++- cmake/Platform/Mac/runtime_dependencies_mac.cmake.in | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/Platform/Common/runtime_dependencies_common.cmake.in b/cmake/Platform/Common/runtime_dependencies_common.cmake.in index b476b7d401..032a6726bd 100644 --- a/cmake/Platform/Common/runtime_dependencies_common.cmake.in +++ b/cmake/Platform/Common/runtime_dependencies_common.cmake.in @@ -9,9 +9,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of "if(NOT ${same_location})" + function(ly_copy source_file target_directory) get_filename_component(target_filename "${source_file}" NAME) - if(NOT "${source_file}" STREQUAL "${target_directory}/${target_filename}") + cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location) + if(NOT ${same_location}) if(NOT EXISTS "${target_directory}") file(MAKE_DIRECTORY "${target_directory}") endif() diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index f7e267eb2f..0a5ab59823 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -65,7 +65,8 @@ function(ly_copy source_file target_directory) endif() - if(NOT "${source_file}" STREQUAL "${target_directory}/${target_filename}") + cmake_path(COMPARE "${source_file}" EQUAL "${target_directory}/${target_filename}" same_location) + if(NOT ${same_location}) if(NOT EXISTS "${target_directory}") file(MAKE_DIRECTORY "${target_directory}") endif() From 5e64586030ce17956921c3557492b8c67a52fb73 Mon Sep 17 00:00:00 2001 From: Esteban Papp Date: Wed, 16 Jun 2021 13:39:31 -0700 Subject: [PATCH 15/16] Handle a bug where gp_resolve_item picks up a header file instead of the binary for qt frameworks --- cmake/Platform/Mac/runtime_dependencies_mac.cmake.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in index 0a5ab59823..6ad428c08d 100644 --- a/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in +++ b/cmake/Platform/Mac/runtime_dependencies_mac.cmake.in @@ -9,6 +9,17 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +function(gp_resolve_item_override context item exepath dirs resolved_item_var resolved_var) + # Qt frameworks could resolve the binary to eg qt/lib/QtCore.framework/Headers/QtCore instead of qt/lib/QtCore.framework/Versions/5/QtCore + # This is because GetPrerequisites.cmake gp_resolve_item function searches for the first file that matches the "frameworks name" + if(${${resolved_var}} AND ${item} MATCHES "/(Qt[^\\.]+\\.framework)/(.*)") + set(qt_framework ${CMAKE_MATCH_1}) + set(qt_framework_subpath ${CMAKE_MATCH_2}) + string(REGEX REPLACE "(.*)/(Qt[^\\.]+\\.framework)/(.*)" "\\1/\\2/${qt_framework_subpath}" new_resolved_item "${${resolved_item_var}}") + set(${resolved_item_var} ${new_resolved_item} PARENT_SCOPE) + endif() +endfunction() + include(BundleUtilities) cmake_policy(SET CMP0012 NEW) # new policy for the if that evaluates a boolean out of the LY_BUILD_FIXUP_BUNDLE expansion From 808d31ea3288ce42d9150a92fba3c4baa98b24df Mon Sep 17 00:00:00 2001 From: pappeste Date: Thu, 17 Jun 2021 12:44:49 -0700 Subject: [PATCH 16/16] change the lock to avoid the "IS_NEWER_THAN" check from failing in race conditions --- cmake/Platform/Common/runtime_dependencies_common.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Platform/Common/runtime_dependencies_common.cmake.in b/cmake/Platform/Common/runtime_dependencies_common.cmake.in index 032a6726bd..c245d185d7 100644 --- a/cmake/Platform/Common/runtime_dependencies_common.cmake.in +++ b/cmake/Platform/Common/runtime_dependencies_common.cmake.in @@ -19,10 +19,10 @@ function(ly_copy source_file target_directory) file(MAKE_DIRECTORY "${target_directory}") endif() if("${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}") - file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" GUARD FUNCTION TIMEOUT 30) file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN) endif() endif() endfunction() +file(LOCK "${CMAKE_BINARY_DIR}/runtimedependencies.lock" TIMEOUT 300) @LY_COPY_COMMANDS@