Files
o3de/CMakeLists.txt
T
SJ 1f542838bb [Mac] Generate O3DE SDK app bundle that can be notarized and distributed (#4150)
* [Mac] Initial support for building with hardened runtime enabled and code signing the binaries and bundles generated by the CMake install process.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Move call to ly_post_install_step
2. Entitlements should only be added for executables
3. Change use of CMake exec_program to newer execute_process
4. Remove broken symlinks from embedded Python frameworks
5. Run post install code signing only if hardened runtime is enabled

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Remove unnecessary flag

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Remove unnecessary additional call to condesign python inside a bundle

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Move commonly used install functions for codesigning, copying files, and fixing frameworks to a utility script
2. Remove unnecessary wait in the Editor/AP launchers I added earlier.
3. Codesign 3rd party libraries for distribution.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Codesigning on 3rd party libs should only happen when hardened runtime is enabled.
2. Change the order of the if blocks in Editor's main_dummy.cpp. This was causing strange notarization issues because it wass too similar to AP's main executable.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add new line to end of file

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Move architecture specification to PAL_mac cmake file. 2. Codesign failure should be fatal.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Address some PR feedback

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Remove unnecessary comment. Change if to use IN_LIST.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* HOME may not always be defined. Adding alternate POSIX way of determining HOME.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Checking in partial work to get O3DE SDK built as an app bundle. Has a bunch of debug code that needs to be cleaned up.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Remove this and add it back later with fixed casing.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Adding file back with fixed case

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Add entitlements sparingly(only when necessary)
2. Convert entitlements to plist files which we can directly pass to codesign
3. Install python site-packages in the o3de_sdk launcher and then launch the project manger.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Move hardened runtime check to codesigning functions only. This way, non-hardened runtime install is identical to the former except for codesign. Makes it easy for QA to test internally.
2. Move cmake min version for install to the pre-install steps.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Remove the dummy launchers for AssetProcessor and Editor
2. Add loader_path to the rpaths of binaries outside an app bundle so that the dynamic loader can load their dependencies if any.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Remove file named main_dummy.cpp

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add O3DE SDK launcher

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add missing runtime dependencies to gems

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Update the path to binaries when codesigning to the correct one.
2. Remove some debug messages.
3. Move installed binary path setreg generation to the target install function. This way, we get the correct path to the bundle accounting for different configs and subdirectories.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add explanatory comments.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. ly_install_add_install_path_setreg cannot be called during install target because the runtime dependencies are already processed by then.
2. The SDK launcher now uses the ProjectManager's bundle setreg to find the path to the installed binaries

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update path to install relative binaries after merge from dev

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Only one config of the SDK launcher needs to be installed. Preinstall steps should not be run per config, but only once.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Install python dependencies using the get_python.sh script.
2. Replace any reference to hard-coded package name/version numbers with variables.
3. Add one more missing runtime dependency.
4. Misc. PR feedback.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Remove the need for setreg files in all tool bundle. Project binary path can be used instead.
2. Move O3DE_SDK_Launcher to Code/Tools/BundleLauncher
3. Add ly_install_run_script() function for install(SCRIPT) functionality.
4. Address some other PR feedback.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add source permission when installing O3DE_SDK executable.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Rename setreg file to add specialization tag.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Remove LY_BUILD_PERMUTATION that's not needed

Signed-off-by: amzn-sj <srikkant@amazon.com>

* 1. Add BinariesInstallPath.setreg to all our bundles like before. This is now only added during the install process though.
2. Fix path in Install_common.cmake

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Fix comment

Signed-off-by: amzn-sj <srikkant@amazon.com>
2021-09-20 11:13:47 -05:00

141 lines
6.0 KiB
CMake

#
# 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
#
#
# Cmake version 3.20 is the minimum version needed for all of Open 3D Engine's supported platforms
cmake_minimum_required(VERSION 3.20)
include(cmake/LySet.cmake)
include(cmake/Version.cmake)
include(cmake/OutputDirectory.cmake)
if(NOT PROJECT_NAME)
project(O3DE
LANGUAGES C CXX
VERSION ${LY_VERSION_STRING}
)
endif()
################################################################################
# Initialize
################################################################################
include(cmake/GeneralSettings.cmake)
include(cmake/FileUtil.cmake)
include(cmake/PAL.cmake)
include(cmake/PALTools.cmake)
include(cmake/RuntimeDependencies.cmake)
include(cmake/Configurations.cmake) # Requires to be after PAL so we get platform variable definitions
include(cmake/Dependencies.cmake)
include(cmake/Deployment.cmake)
include(cmake/3rdParty.cmake)
include(cmake/LYPython.cmake)
include(cmake/Install.cmake)
include(cmake/LYWrappers.cmake)
include(cmake/Gems.cmake)
include(cmake/UnitTest.cmake)
include(cmake/LYTestWrappers.cmake)
include(cmake/Monolithic.cmake)
include(cmake/SettingsRegistry.cmake)
include(cmake/TestImpactFramework/LYTestImpactFramework.cmake)
include(cmake/CMakeFiles.cmake)
include(cmake/O3DEJson.cmake)
################################################################################
# Subdirectory processing
################################################################################
function(add_engine_json_external_subdirectories)
read_json_external_subdirs(external_subdis ${LY_ROOT_FOLDER}/engine.json)
foreach(external_subdir ${external_subdis})
file(REAL_PATH ${external_subdir} real_external_subdir BASE_DIRECTORY ${LY_ROOT_FOLDER})
list(APPEND engine_external_subdirs ${real_external_subdir})
endforeach()
set_property(GLOBAL APPEND PROPERTY LY_EXTERNAL_SUBDIRS ${engine_external_subdirs})
endfunction()
# Add the projects first so the Launcher can find them
include(cmake/Projects.cmake)
if(NOT INSTALLED_ENGINE)
# Add the rest of the targets
add_subdirectory(Assets)
add_subdirectory(Code)
add_subdirectory(python)
add_subdirectory(Registry)
add_subdirectory(scripts)
add_subdirectory(Templates)
add_subdirectory(Tools)
# Add external subdirectories listed in the engine.json. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
# external subdirectories
add_engine_json_external_subdirectories()
else()
ly_find_o3de_packages()
endif()
get_property(external_subdirs GLOBAL PROPERTY LY_EXTERNAL_SUBDIRS)
list(APPEND LY_EXTERNAL_SUBDIRS ${external_subdirs})
# Loop over the additional external subdirectories and invoke add_subdirectory on them
foreach(external_directory ${LY_EXTERNAL_SUBDIRS})
# Hash the extenal_directory name and append it to the Binary Directory section of add_subdirectory
# This is to deal with potential situations where multiple external directories has the same last directory name
# For example if D:/Company1/RayTracingGem and F:/Company2/Path/RayTracingGem were both added as a subdirectory
file(REAL_PATH ${external_directory} full_directory_path)
string(SHA256 full_directory_hash ${full_directory_path})
# Truncate the full_directory_hash down to 8 characters to avoid hitting the Windows 260 character path limit
# when the external subdirectory contains relative paths of significant length
string(SUBSTRING ${full_directory_hash} 0 8 full_directory_hash)
# Use the last directory as the suffix path to use for the Binary Directory
get_filename_component(directory_name ${external_directory} NAME)
add_subdirectory(${external_directory} ${CMAKE_BINARY_DIR}/External/${directory_name}-${full_directory_hash})
endforeach()
################################################################################
# Post-processing
################################################################################
# The following steps have to be done after all targets are registered:
# 1. Add any dependencies registered via ly_enable_gems
ly_enable_gems_delayed()
# 2. Defer generation of the StaticModules.inl file which is needed to create the AZ::Module derived class in monolithic
# builds until after all the targets are known and all the gems are enabled
ly_delayed_generate_static_modules_inl()
# 3. generate a settings registry .setreg file for all ly_add_project_dependencies() and ly_add_target_dependencies() calls
# to provide applications with the filenames of gem modules to load
# This must be done before ly_delayed_target_link_libraries() as that inserts BUILD_DEPENDENCIES as MANUALLY_ADDED_DEPENDENCIES
# if the build dependency is a MODULE_LIBRARY. That would cause a false load dependency to be generated
ly_delayed_generate_settings_registry()
# 4. link targets where the dependency was yet not declared, we need to have the declaration so we do different
# linking logic depending on the type of target
ly_delayed_target_link_libraries()
# 5. generate a registry file for unit testing for platforms that support unit testing
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_delayed_generate_unit_test_module_registry()
endif()
# 5. inject runtime dependencies to the targets. We need to do this after (1) since we are going to walk through
# the dependencies
ly_delayed_generate_runtime_dependencies()
# 6. Perform test impact framework post steps once all of the targets have been enumerated
ly_test_impact_post_step()
# 7. Generate the O3DE find file and setup install locations for scripts, tools, assets etc., required by the engine
if(LY_INSTALL_ENABLED)
# 8. Generate the O3DE find file and setup install locations for scripts, tools, assets etc., required by the engine
ly_setup_o3de_install()
# 9. CPack information (to be included after install)
include(cmake/Packaging.cmake)
endif()