Przeglądaj źródła

Merge pull request #58 from aws-lumberyard-dev/cgalvan/ConvertQt

Converted Qt build to 3p package source.
Chris Galvan 3 lat temu
rodzic
commit
2f98cb43fb

+ 293 - 0
package-system/Qt/FindQt.cmake

@@ -0,0 +1,293 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+if(TARGET 3rdParty::Qt::Core) # Check we are not called multiple times
+    return()
+endif()
+
+set(QT_PACKAGE_NAME qt)
+
+set(QT_PATH "${CMAKE_CURRENT_LIST_DIR}/qt" CACHE STRING "The root path to Qt" FORCE)
+mark_as_advanced(QT_PATH)
+if(NOT EXISTS ${QT_PATH})
+    message(FATAL_ERROR "Cannot find 3rdParty library ${QT_PACKAGE_NAME} on path ${QT_PATH}")
+endif()
+
+# Force-set QtCore's version here to ensure CMake detects Qt's existence and allows AUTOMOC to work
+set(Qt5Core_VERSION_MAJOR "5" CACHE STRING "Qt's major version" FORCE)
+set(Qt5Core_VERSION_MINOR "15" CACHE STRING "Qt's minor version" FORCE)
+set(Qt5Core_VERSION_PATCH "2" CACHE STRING "Qt's patch version" FORCE)
+mark_as_advanced(Qt5Core_VERSION_MAJOR)
+mark_as_advanced(Qt5Core_VERSION_MINOR)
+mark_as_advanced(Qt5Core_VERSION_PATCH)
+
+set(QT5_COMPONENTS
+    Core
+    Concurrent
+    Gui
+    LinguistTools
+    Network
+    OpenGL
+    Svg
+    Test
+    WebEngineWidgets
+    Widgets
+    Xml
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}/Qt_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
+
+list(APPEND CMAKE_PREFIX_PATH ${QT_LIB_PATH}/cmake/Qt5)
+
+# Clear the cache for found DIRs
+unset(Qt5_DIR CACHE)
+foreach(component ${QT5_COMPONENTS})
+    unset(Qt5${component}_DIR CACHE)
+endforeach()
+unset(Qt5Positioning_DIR CACHE)
+unset(Qt5PrintSupport_DIR CACHE)
+unset(Qt5WebChannel_DIR CACHE)
+unset(Qt5WebEngineCore_DIR CACHE)
+unset(Qt5Qml_DIR CACHE)
+unset(Qt5QmlModels_DIR CACHE)
+unset(Qt5Quick_DIR CACHE)
+
+# Populate the Qt5 configurations
+find_package(Qt5
+    COMPONENTS ${QT5_COMPONENTS}
+    REQUIRED
+    NO_CMAKE_PACKAGE_REGISTRY 
+)
+
+# Now create libraries that wrap the dependency so we can refer to them in our format
+foreach(component ${QT5_COMPONENTS})
+    if(TARGET Qt5::${component})
+
+        # Convert the includes to system includes
+        get_target_property(system_includes Qt5::${component} INTERFACE_INCLUDE_DIRECTORIES)
+        set_target_properties(Qt5::${component} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "") # Clear it in case someone refers to it
+        ly_target_include_system_directories(TARGET Qt5::${component}
+            INTERFACE ${system_includes}
+        )
+
+        # Alias the target with our prefix
+        add_library(3rdParty::Qt::${component} ALIAS Qt5::${component})
+        mark_as_advanced(Qt5${component}_DIR) # Hiding from GUI
+
+        # Qt only has debug and release, we map the configurations we use in o3de. We map all the configurations 
+        # except debug to release
+        foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES)
+            string(TOUPPER ${conf} UCONF)
+            ly_qt_configuration_mapping(${UCONF} MAPPED_CONF)
+            set_target_properties(Qt5::${component} PROPERTIES
+                MAP_IMPORTED_CONFIG_${UCONF} ${MAPPED_CONF}
+            )
+        endforeach()
+
+    endif()
+endforeach()
+
+# Some extra DIR variables we want to hide from GUI
+mark_as_advanced(Qt5_DIR) # Hiding from GUI
+mark_as_advanced(Qt5LinguistTools_DIR) # Hiding from GUI, this variable comes from the LinguistTools module
+mark_as_advanced(Qt5Positioning_DIR)
+mark_as_advanced(Qt5PrintSupport_DIR)
+mark_as_advanced(Qt5WebChannel_DIR)
+mark_as_advanced(Qt5WebEngineCore_DIR)
+mark_as_advanced(Qt5Qml_DIR)
+mark_as_advanced(Qt5QmlModels_DIR)
+mark_as_advanced(Qt5Quick_DIR)
+
+# Special case for Qt::Gui, we are using the private headers...
+ly_target_include_system_directories(TARGET Qt5::Gui
+   INTERFACE "${Qt5Gui_PRIVATE_INCLUDE_DIRS}"
+)
+
+# Another special case: Qt:Widgets, we are also using private headers
+ly_target_include_system_directories(TARGET Qt5::Widgets
+    INTERFACE "${Qt5Widgets_PRIVATE_INCLUDE_DIRS}"
+)
+
+# Qt plugins/translations/aux files. 
+# We create libraries that wraps them so they get deployed properly.
+# This used to be deployed through winqtdeploy/macqtdeploy, however, those tools
+# are old and unmaintaned, macqtdeploy takes long times to run
+add_library(3rdParty::Qt::Core::Translations INTERFACE IMPORTED GLOBAL)
+file(GLOB tranlation_files ${QT_PATH}/translations/qt_*.qm)
+if(tranlation_files)
+    ly_add_target_files(TARGETS 3rdParty::Qt::Core::Translations
+        FILES ${tranlation_files}
+        OUTPUT_SUBDIRECTORY translations
+    )
+endif()
+ly_add_dependencies(Qt5::Core 3rdParty::Qt::Core::Translations)
+
+# plugins, each platform will define the files it has and the OUTPUT_SUBDIRECTORY
+set(QT_PLUGINS
+    Network
+    Gui
+    Widgets
+)
+foreach(plugin ${QT_PLUGINS})
+    add_library(3rdParty::Qt::${plugin}::Plugins INTERFACE IMPORTED GLOBAL)
+    ly_add_dependencies(Qt5::${plugin} 3rdParty::Qt::${plugin}::Plugins)
+endforeach()
+include(${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}/QtPlugin_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
+
+# 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 
+"<RCC>
+    <qresource prefix=\"/${ly_add_translations_PREFIX}\">
+")
+    foreach(file ${TRANSLATED_FILES})
+        get_filename_component(filename ${file} NAME)
+        string(APPEND qrc_file_contents "        <file>${filename}</file>
+")
+    endforeach()
+    string(APPEND qrc_file_contents "    </qresource>
+</RCC>
+")
+    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()

+ 58 - 0
package-system/Qt/Platform/Linux/QtPlugin_linux.cmake

@@ -0,0 +1,58 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+# Not plugins per-se but extra files associated to each component
+foreach(component ${QT5_COMPONENTS})
+    if(TARGET Qt5::${component})
+
+        # add the IMPORTED_SONAME files as files to copy
+        unset(extra_target_files)
+        get_target_property(imported_soname Qt5::${component} IMPORTED_SONAME_RELEASE)
+        if(imported_soname)
+            list(APPEND extra_target_files ${QT_LIB_PATH}/${imported_soname})
+        endif()
+        if(extra_target_files)
+            ly_add_target_files(TARGETS Qt5::${component} FILES ${extra_target_files})
+        endif()
+
+    endif()
+endforeach()
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Network::Plugins
+    FILES ${QT_PATH}/plugins/bearer/libqgenericbearer.so
+    OUTPUT_SUBDIRECTORY bearer
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES ${QT_PATH}/plugins/iconengines/libqsvgicon.so
+    OUTPUT_SUBDIRECTORY iconengines
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES 
+        ${QT_PATH}/plugins/imageformats/libqgif.so
+        ${QT_PATH}/plugins/imageformats/libqicns.so
+        ${QT_PATH}/plugins/imageformats/libqico.so
+        ${QT_PATH}/plugins/imageformats/libqjpeg.so
+        ${QT_PATH}/plugins/imageformats/libqsvg.so
+        ${QT_PATH}/plugins/imageformats/libqtga.so
+        ${QT_PATH}/plugins/imageformats/libqtiff.so
+        ${QT_PATH}/plugins/imageformats/libqwbmp.so
+        ${QT_PATH}/plugins/imageformats/libqwebp.so
+    OUTPUT_SUBDIRECTORY imageformats
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES
+        ${QT_PATH}/plugins/platforms/libqminimal.so
+        ${QT_PATH}/plugins/platforms/libqxcb.so
+    OUTPUT_SUBDIRECTORY platforms
+)
+
+ly_add_dependencies(3rdParty::Qt::Widgets::Plugins Qt5::DBus)
+ly_add_dependencies(3rdParty::Qt::Widgets::Plugins Qt5::XcbQpa)

+ 18 - 0
package-system/Qt/Platform/Linux/Qt_linux.cmake

@@ -0,0 +1,18 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+set(QT_LIB_PATH ${QT_PATH}/lib)
+
+list(APPEND QT5_COMPONENTS
+    DBus
+    XcbQpa
+)
+
+function(ly_qt_configuration_mapping in_config out_config)
+    set(${out_config} RELEASE PARENT_SCOPE)
+endfunction()

+ 46 - 0
package-system/Qt/Platform/Mac/QtPlugin_mac.cmake

@@ -0,0 +1,46 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Network::Plugins
+    FILES ${QT_PATH}/plugins/bearer/libqgenericbearer.dylib
+    OUTPUT_SUBDIRECTORY bearer
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES ${QT_PATH}/plugins/iconengines/libqsvgicon.dylib
+    OUTPUT_SUBDIRECTORY iconengines
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES 
+        ${QT_PATH}/plugins/imageformats/libqgif.dylib
+        ${QT_PATH}/plugins/imageformats/libqicns.dylib
+        ${QT_PATH}/plugins/imageformats/libqico.dylib
+        ${QT_PATH}/plugins/imageformats/libqjpeg.dylib
+        ${QT_PATH}/plugins/imageformats/libqsvg.dylib
+        ${QT_PATH}/plugins/imageformats/libqtga.dylib
+        ${QT_PATH}/plugins/imageformats/libqtiff.dylib
+        ${QT_PATH}/plugins/imageformats/libqwbmp.dylib
+        ${QT_PATH}/plugins/imageformats/libqwebp.dylib
+    OUTPUT_SUBDIRECTORY imageformats
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES 
+        ${QT_PATH}/plugins/platforms/libqminimal.dylib
+        ${QT_PATH}/plugins/platforms/libqcocoa.dylib
+    OUTPUT_SUBDIRECTORY platforms
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Widgets::Plugins
+    FILES ${QT_PATH}/plugins/styles/libqmacstyle.dylib
+    OUTPUT_SUBDIRECTORY styles
+)
+
+add_dependencies(Qt5::MacExtras Qt5::PrintSupport)
+add_dependencies(Qt5::MacExtras Qt5::DBus)

+ 19 - 0
package-system/Qt/Platform/Mac/Qt_mac.cmake

@@ -0,0 +1,19 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+set(QT_LIB_PATH ${QT_PATH}/lib)
+
+list(APPEND QT5_COMPONENTS 
+    DBus
+    MacExtras
+    PrintSupport
+)
+
+function(ly_qt_configuration_mapping in_config out_config)
+    set(${out_config} RELEASE PARENT_SCOPE)
+endfunction()

+ 44 - 0
package-system/Qt/Platform/Windows/QtPlugin_windows.cmake

@@ -0,0 +1,44 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Network::Plugins
+    FILES ${QT_PATH}/plugins/bearer/qgenericbearer$<$<CONFIG:debug>:d>.dll
+    OUTPUT_SUBDIRECTORY bearer
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES ${QT_PATH}/plugins/iconengines/qsvgicon$<$<CONFIG:debug>:d>.dll
+    OUTPUT_SUBDIRECTORY iconengines
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES 
+        ${QT_PATH}/plugins/imageformats/qgif$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qicns$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qico$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qjpeg$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qsvg$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qtga$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qtiff$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qwbmp$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/imageformats/qwebp$<$<CONFIG:debug>:d>.dll
+    OUTPUT_SUBDIRECTORY imageformats
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Gui::Plugins
+    FILES
+        ${QT_PATH}/plugins/platforms/qminimal$<$<CONFIG:debug>:d>.dll
+        ${QT_PATH}/plugins/platforms/qwindows$<$<CONFIG:debug>:d>.dll
+    OUTPUT_SUBDIRECTORY platforms
+)
+
+ly_add_target_files(TARGETS 3rdParty::Qt::Widgets::Plugins
+    FILES ${QT_PATH}/plugins/styles/qwindowsvistastyle$<$<CONFIG:debug>:d>.dll
+    OUTPUT_SUBDIRECTORY styles
+)
+

+ 18 - 0
package-system/Qt/Platform/Windows/Qt_windows.cmake

@@ -0,0 +1,18 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+set(QT_LIB_PATH ${QT_PATH}/lib)
+
+function(ly_qt_configuration_mapping in_config out_config)
+    string(TOUPPER ${in_config} in_config_upper)
+    if(in_config_upper STREQUAL DEBUG)
+        set(${out_config} DEBUG PARENT_SCOPE)
+    else()
+        set(${out_config} RELEASE PARENT_SCOPE)
+    endif()
+endfunction()

+ 90 - 0
package-system/Qt/build.bat

@@ -0,0 +1,90 @@
+@echo off
+setlocal enabledelayedexpansion
+
+REM 
+REM Copyright (c) Contributors to the Open 3D Engine Project.
+REM For complete copyright and license terms please see the LICENSE at the root of this distribution.
+REM 
+REM SPDX-License-Identifier: Apache-2.0 OR MIT
+REM 
+
+REM Set these before running the script
+if not defined VCVARS_PATH set VCVARS_PATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
+if not defined QTARRAY set QTARRAY=(qtbase,qtgraphicaleffects,qtimageformats,qtsvg,qttools,qtwebengine)
+
+REM TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script
+set CHECKS_FAILED=0
+for %%P IN (VCVARS_PATH,TEMP_FOLDER,TARGET_INSTALL_ROOT) do (
+    if not exist !%%P! (
+        echo %%P not found at !%%P!
+        set CHECKS_FAILED=1
+    )
+)
+
+if %CHECKS_FAILED%==1 goto FAILURE
+
+echo Setting up VS2019
+call %VCVARS_PATH% amd64
+
+REM We need jom and ICU to build on Windows
+set JOM_PATH=%TEMP_FOLDER%\jom
+set ICU_PATH=%TEMP_FOLDER%\icu\bin64
+
+REM We use Miniconda to get a Python 2.7 executable, which is needed for WebEngine to build
+set MINICONDA_PATH=%TEMP_FOLDER%\miniconda
+
+set PATH=%MINICONDA_PATH%;%PATH%;%JOM_PATH%;%ICU_PATH%
+
+REM Replace PYTHONPATH with our Miniconda Python paths so that only the Python 2.7 from Miniconda
+REM will be found. Otherwise, there will be an invalid syntax error in site.py because the build
+REM machine will likely have a different version of Python (most likely Python 3) on the PATH,
+REM and since the build_package script will be launched from the Python 3 that is pulled down
+REM for O3DE, its paths will be in the PATH as well.
+set PYTHONPATH=%MINICONDA_PATH%;%MINICONDA_PATH%\Lib
+
+REM The Qt source directory will get cloned into a local temp\src folder
+set BUILD_ROOT=%TEMP_FOLDER%\src
+set BUILD_PATH=%BUILD_ROOT%\qtbase
+
+REM For OpenSSL support
+set OPENSSL_ROOT=%TEMP_FOLDER%\OpenSSL-1.1.1b-rev2-windows\OpenSSL
+set OPENSSL_INCLUDE=%OPENSSL_ROOT%\include
+set OPENSSL_LIB_DEBUG=%OPENSSL_ROOT%\debug\lib
+set OPENSSL_LIB_RELEASE=%OPENSSL_ROOT%\lib
+set INCLUDE=%OPENSSL_INCLUDE%;%INCLUDE%
+set LIB=%OPENSSL_LIB_DEBUG%;%OPENSSL_LIB_RELEASE%;%LIB%
+
+cd %BUILD_PATH%
+
+set _OPTS=-v^
+    -prefix %TARGET_INSTALL_ROOT% ^
+    -debug-and-release ^
+    -force-debug-info ^
+    -opensource ^
+    -confirm-license ^
+    -nomake examples ^
+    -nomake tests ^
+    -shared ^
+    -opengl dynamic ^
+    -openssl-linked
+
+cmd /c ""%BUILD_ROOT%\configure.bat" %_OPTS%" || goto FAILURE
+
+for %%M IN %QTARRAY% do (
+    echo Building %%M...
+    jom module-%%M || goto FAILURE
+    echo Built %%M.
+)
+
+for %%M IN %QTARRAY% do (
+    echo Installing %%M...
+    jom module-%%M-install_subtargets || goto FAILURE
+    echo %%M installed.
+)
+
+:FINISH
+exit
+
+:FAILURE
+echo Build failed, see errors above.
+exit 1

+ 95 - 0
package-system/Qt/build.sh

@@ -0,0 +1,95 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+
+set -euo pipefail
+
+# Limit Ninja jobs lower to avoid out of memory issues build qtwebengine
+export NINJAJOBS=-j12
+MAKE_FLAGS=-j32
+
+# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script
+# We use Miniconda to get a Python 2.7 executable, which is needed for WebEngine to build
+MINICONDA_PATH=$TEMP_FOLDER/miniconda
+
+export PATH=$MINICONDA_PATH:$PATH
+
+# Replace PYTHONPATH with our Miniconda Python paths so that only the Python 2.7 from Miniconda
+# will be found. Otherwise, there will be an invalid syntax error in site.py because the build
+# machine will likely have a different version of Python (most likely Python 3) on the PATH,
+# and since the build_package script will be launched from the Python 3 that is pulled down
+# for O3DE, its paths will be in the PATH as well.
+export PYTHONPATH=$MINICONDA_PATH:$MINICONDA_PATH/lib
+
+BUILD_PATH=$TEMP_FOLDER/build
+if [[ "$OSTYPE" == "darwin"* ]]; then
+    EXTRA_CONFIG_OPTIONS=""
+else
+    EXTRA_CONFIG_OPTIONS="-c++std c++1z \
+    -openssl \
+    -reduce-relocations \
+    -fontconfig"
+fi
+
+[[ -d $BUILD_PATH ]] || mkdir $BUILD_PATH
+cd $BUILD_PATH
+
+echo Configuring Qt...
+../src/configure \
+-prefix ${TARGET_INSTALL_ROOT} \
+-opensource \
+-nomake examples \
+-nomake tests \
+-confirm-license \
+-no-icu \
+-dbus \
+-no-separate-debug-info \
+-release \
+-force-debug-info \
+-qt-libpng \
+-qt-libjpeg \
+-no-feature-vnc \
+-no-feature-linuxfb \
+-qt-zlib \
+-v \
+-no-cups \
+-no-glib \
+-no-feature-renameat2 \
+-no-feature-getentropy \
+-no-feature-statx \
+-no-egl \
+$EXTRA_CONFIG_OPTIONS
+
+echo Qt configured, building modules...
+qtarray=(qtbase qtgraphicaleffects qtimageformats qtsvg qttools qtwebengine)
+if [[ "$OSTYPE" == "darwin"* ]]; then
+    qtarray+=(qtmacextras qttranslations)
+fi
+
+for qtlib in "${qtarray[@]}"; do
+    echo Building $qtlib...
+    make module-$qtlib $MAKE_FLAGS
+    echo Built $qtlib.
+done
+
+echo Finished building modules, installing...
+for qtlib in "${qtarray[@]}"; do
+    echo Installing $qtlib...
+    make module-$qtlib-install_subtargets
+    echo $qtlib installed.
+done
+echo Qt installed successfully!
+
+if [[ "$OSTYPE" != "darwin"* ]]; then
+    VERSION=$($TARGET_INSTALL_ROOT/bin/qmake -query QT_VERSION)
+    # Strip libQt5Core for WSL compatibility
+    strip --remove-section=.note.ABI-tag $TARGET_INSTALL_ROOT/lib/libQt5Core.so.$VERSION
+    # Remove symlinks from the build dir, we regenerate them
+    find $TARGET_INSTALL_ROOT/lib -type l | xargs rm
+    echo Qt install post-processing complete!
+fi

+ 51 - 0
package-system/Qt/build_config.json

@@ -0,0 +1,51 @@
+{
+    "git_url": "https://github.com/o3de/qt5.git",
+    "git_tag": "5.15.1-o3de",
+    "git_commit": "b3a1a6947422928e8aecb14ad607199e9720d266",
+    "package_name": "qt",
+    "package_version": "5.15.2-rev4",
+    "package_url": "https://www.qt.io/",
+    "package_license": "LGPL-3.0",
+    "package_license_file": "qt/LICENSE.LGPLv3",
+    "cmake_find_source": "FindQt.cmake",
+    "cmake_find_target": "FindQt.cmake",
+    "Platforms": {
+        "Windows": {
+            "Windows": {
+                "depends_on_packages": [
+                    ["OpenSSL-1.1.1b-rev2-windows", "9af1c50343f89146b4053101a7aeb20513319a3fe2f007e356d7ce25f9241040", ""]
+                ],
+                "custom_build_cmd": [
+                    "install_miniconda.py",
+                    "install_windows_extras.py",
+                    "build.bat"
+                ],
+                "custom_install_cmd": [
+                    "copy_platform_cmakes.py"
+                ]
+            }
+        },
+        "Darwin": {
+            "Mac": {
+                "package_version": "5.15.2-rev5",
+                "custom_build_cmd": [
+                    "./build.sh"
+                ],
+                "custom_install_cmd": [
+                    "{python} copy_platform_cmakes.py"
+                ]
+            }
+        },
+        "Linux": {
+            "Linux": {
+                "package_version": "5.15.2-rev5",
+                "custom_build_cmd": [
+                    "./build.sh"
+                ],
+                "custom_install_cmd": [
+                    "{python} copy_platform_cmakes.py"
+                ]
+            }
+        }
+    }
+}

+ 39 - 0
package-system/Qt/copy_platform_cmakes.py

@@ -0,0 +1,39 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+import glob
+import os
+import pathlib
+import platform
+import shutil
+import sys
+
+
+# There are some additional cmake files we need to copy per-platform to the install directory
+platform_system = platform.system().lower()
+platform_to_pal = {
+    "windows": "Windows",
+    "linux": "Linux",
+    "darwin": "Mac"
+}
+
+if platform_system not in platform_to_pal:
+    print(f"Unknown platform: {platform_system}") 
+    sys.exit(1)
+
+platform_folder = pathlib.Path("Platform") / platform_to_pal[platform_system]
+package_root = os.environ['PACKAGE_ROOT']
+platform_install_folder = pathlib.Path(package_root) / platform_folder
+
+# Make sure the install folder for the platform exists
+platform_install_folder.mkdir(parents=True, exist_ok=True)
+
+files = glob.iglob(os.path.join(platform_folder, "*.cmake"))
+for file in files:
+    print(f"Copying {file} => {platform_install_folder}")
+    shutil.copy2(file, platform_install_folder)

+ 1 - 0
package-system/Qt/docker/build-linux-docker.bat

@@ -0,0 +1 @@
+docker build -f %~dp0\linux-build.Dockerfile -t lyeditor/qt-linux-build:5.15 %~dp0

+ 22 - 0
package-system/Qt/docker/linux-build.Dockerfile

@@ -0,0 +1,22 @@
+FROM ubuntu:bionic
+
+RUN apt-get update
+
+# Qt5 build dependencies
+RUN apt-get -y install git python make g++ clang gperf bison flex libnss3-dev libxrandr-dev libdbus-1-dev libxi-dev libxtst-dev libxcomposite-dev libxcursor-dev libc++-dev libc++abi-dev libssl-dev libfontconfig1-dev libxcb1-dev libglu1-mesa-dev mesa-common-dev libxkbcommon-x11-dev libxkbcommon-dev libx11-xcb-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-render-util0-dev libxcb-xinerama0-dev libxcb-xinput-dev libwebp-dev libopus-dev --fix-missing
+
+# Developer Tools
+RUN apt-get -y install vim
+
+# O3DE build dependencies
+RUN apt-get -y install build-essential
+RUN apt-get -y install libgl-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev libsdl2-2.0-0 libsdl2-dev
+RUN apt-get -y install clang-12 libc++-dev libc++abi-dev uuid-dev libz-dev libncurses5-dev libcurl4-openssl-dev libjpeg-dev libjbig-dev libpython3.7
+ 
+RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
+RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
+
+RUN apt-get -y install wget
+RUN apt-get update
+
+VOLUME /data

+ 81 - 0
package-system/Qt/install_miniconda.py

@@ -0,0 +1,81 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+import os
+import platform
+import shutil
+import subprocess
+import sys
+import urllib.request
+
+
+# To build WebEngine for Qt, we need Python 2.7, so we need to do a temporary, local
+# installation of miniconda (https://conda.io/projects/conda/en/latest/index.html) which
+# will provide us a python 2.7 executable just for the Qt build process
+miniconda_installer_links = {
+    "windows": "https://repo.anaconda.com/miniconda/Miniconda2-py27_4.8.3-Windows-x86_64.exe",
+    "linux": "https://repo.anaconda.com/miniconda/Miniconda2-py27_4.8.3-Linux-x86_64.sh",
+    "darwin": "https://repo.anaconda.com/miniconda/Miniconda2-py27_4.8.3-MacOSX-x86_64.sh"
+}
+
+platform_system = platform.system().lower()
+
+print("Attempting to install Miniconda (for Python 2.7)")
+
+if not platform_system in miniconda_installer_links:
+    print(f"Unknown platform: {platform_system}") 
+    sys.exit(1)
+
+installer_link = miniconda_installer_links[platform_system]
+installer_file_name = os.path.basename(installer_link)
+
+# Download the installer (if we haven't already, so that this script can be run iteratively)
+if not os.path.exists(installer_file_name):
+    print(f"Downloading Miniconda from {installer_link}")
+
+    urllib.request.urlretrieve(installer_link, installer_file_name)
+
+    print(f"Download of Miniconda complete => {os.path.abspath(installer_file_name)}")
+
+# We will install miniconda into the local temp directory for our package
+miniconda_install_dir = os.path.abspath(os.path.join('temp', 'miniconda'))
+print(f"Installing Miniconda to {miniconda_install_dir}")
+
+# Execute the installer in silent mode so it doesn't require any user
+# interaction, and so that it doesn't modify any system PATH
+exe_suffix = ""
+if platform_system == "windows":
+    exe_suffix = ".exe"
+    result = subprocess.run(
+        ["start",
+         "/wait",
+         installer_file_name,
+         "/InstallationType=JustMe",
+         "/RegisterPython=0",
+         "/S",
+         "/D=" + miniconda_install_dir
+    ], shell=True)
+else:
+    result = subprocess.run(
+        ["bash",
+         installer_file_name,
+         "-b",
+         "-p",
+         miniconda_install_dir
+    ])
+
+# Copy the python binary (python.exe/python) to python2 so that the Qt configure for WebEngine
+# can find it easier
+python_binary = os.path.join(miniconda_install_dir, 'python' + exe_suffix)
+shutil.copyfile(python_binary, os.path.join(miniconda_install_dir, 'python2' + exe_suffix))
+
+if result.returncode == 0:
+    print("Miniconda successfully installed!")
+else:
+    print("Error installing Miniconda")
+sys.exit(result.returncode)

+ 42 - 0
package-system/Qt/install_windows_extras.py

@@ -0,0 +1,42 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+import os
+import urllib.request
+import zipfile
+
+
+# On Windows, we also need to install jom and ICU, so we will download them
+# and install them locally just for this build
+dependencies = {
+    "jom": "http://download.qt.io/official_releases/jom/jom.zip",
+    "icu": "https://github.com/unicode-org/icu/releases/download/release-65-1/icu4c-65_1-Win64-MSVC2017.zip"
+}
+
+for name in dependencies:
+    print(f"Attempting to install {name}")
+
+    installer_link = dependencies[name]
+    file_name = os.path.basename(installer_link)
+
+    # Download the zip (if we haven't already, so that this script can be run iteratively)
+    if not os.path.exists(file_name):
+        print(f"Downloading {name} from {installer_link}")
+
+        urllib.request.urlretrieve(installer_link, file_name)
+
+        print(f"Download of {name} complete => {os.path.abspath(file_name)}")
+
+    # We will unzip the package into the local temp directory
+    install_dir = os.path.abspath(os.path.join('temp', name))
+    print(f"Installing {name} to {install_dir}")
+
+    with zipfile.ZipFile(file_name, 'r') as dep_zip:
+        dep_zip.extractall(install_dir)
+
+    print(f"Successfully installed {name}") 

+ 1 - 0
package_build_list_host_darwin.json

@@ -39,6 +39,7 @@
         "mcpp-2.7.2_az.2-rev1-mac": "package-system/mcpp/get_and_build_mcpp.py mcpp-2.7.2_az.2-rev1",
         "mikkelsen-1.0.0.4-mac": "package-system/mikkelsen/build_package_image.py --platform mac",
         "mikkelsen-1.0.0.4-ios": "package-system/mikkelsen/build_package_image.py --platform ios",
+        "qt-5.15.2-rev5-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Mac --package-root ../../package-system --clean",
         "zlib-1.2.11-rev5-mac": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Mac --package-root ../../package-system --clean",
         "zlib-1.2.11-rev5-ios": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name iOS --package-root ../../package-system --clean",
         "lz4-1.9.3-vcpkg-rev4-mac": "package-system/lz4/build_package_image.py --platform-name mac",

+ 1 - 0
package_build_list_host_linux.json

@@ -29,6 +29,7 @@
         "tiff-4.2.0.15-rev3-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/tiff --platform-name Linux --package-root ../../package-system --clean",
         "python-3.7.10-rev2-linux": "package-system/python/build_package_image.py",
         "mikkelsen-1.0.0.4-linux": "package-system/mikkelsen/build_package_image.py",
+        "qt-5.15.2-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Linux --package-root ../../package-system --clean",
         "zlib-1.2.11-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Linux --package-root ../../package-system --clean",
         "lz4-1.9.3-vcpkg-rev4-linux": "package-system/lz4/build_package_image.py --platform-name linux"
     },

+ 1 - 0
package_build_list_host_windows.json

@@ -43,6 +43,7 @@
         "python-3.7.10-rev2-windows": "package-system/python/build_package_image.py",
         "mikkelsen-1.0.0.4-windows": "package-system/mikkelsen/build_package_image.py",
         "mikkelsen-1.0.0.4-android": "package-system/mikkelsen/build_package_image.py --platform android",
+        "qt-5.15.2-rev4-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Windows --package-root ../../package-system --clean",
         "zlib-1.2.11-rev1-windows": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Windows --package-root ../../package-system --clean",
         "zlib-1.2.11-rev1-android": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Android --package-root ../../package-system --clean"
       },