Files
o3de/CMakeLists.txt
T
Esteban Papp 5d13ad963a SPEC-6437 Dlls should go to bin instead of profile (#287)
* renaming and organizing files

* removed unused files

* Removing unnecessary file

* moved file

* reverting movement of 3rdparty associations from gems to global

* removing unnecessary calls to ly_add_external_target_path

* fixing install prefix of ci_build

* Fixes to get 3rdparties declared in gems to be installed

* Allowing to install just one configuration

* Adding empty line at the end

* removing commented code

* setting IMPORETD_LOCATION_<CONFIG> and defaulting IMPORTED_LOCATION to the profile config in case other configs are not installed

* putting dlls/exe in the right place, with the right output subdirectory

* setting runtime dependencies for the dlls that we link against

* singular target location

* code review comments/fixes

* Fixing identation
2021-04-23 14:41:18 -07:00

130 lines
5.6 KiB
CMake

#
# 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.
#
# Cmake version 3.17 is the minimum version needed for all of Open 3D Engine's supported platforms
cmake_minimum_required(VERSION 3.19)
# CMP0111 introduced in 3.19 has a bug that produces the policy to warn every time there is an
# INTERFACE IMPORTED library. We use this type of libraries for handling 3rdParty. The rest of
# the documentation states that INTERFACE IMPORTED libraries do not require to set locations, but
# the policy still warns about it. Issue: https://gitlab.kitware.com/cmake/cmake/-/issues/21470
# The issue was fixed in 3.19.1 so we just disable the policy for 3.19
if(CMAKE_VERSION VERSION_EQUAL 3.19)
cmake_policy(SET CMP0111 OLD)
endif()
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()
include(cmake/GeneralSettings.cmake)
include(cmake/FileUtil.cmake)
include(cmake/PAL.cmake)
include(cmake/PALTools.cmake)
include(cmake/Install.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/LYWrappers.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)
################################################################################
# Subdirectory processing
################################################################################
# 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(Code)
add_subdirectory(Gems)
else()
ly_find_o3de_packages()
endif()
set(enabled_platforms
${PAL_PLATFORM_NAME}
${LY_PAL_TOOLS_ENABLED})
foreach(restricted_platform ${PAL_RESTRICTED_PLATFORMS})
if(restricted_platform IN_LIST enabled_platforms)
add_subdirectory(restricted/${restricted_platform})
endif()
endforeach()
add_subdirectory(scripts)
# SPEC-1417 will investigate and fix this
if(NOT PAL_PLATFORM_NAME STREQUAL "Mac")
add_subdirectory(Tools/LyTestTools/tests/)
add_subdirectory(Tools/RemoteConsole/ly_remote_console/tests/)
endif()
################################################################################
# Post-processing
################################################################################
# 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}/${directory_name}-${full_directory_hash})
endforeach()
# The following steps have to be done after all targets are registered:
# 1. 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_DEPENDENCIE 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()
# 2. 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()
# 3. 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()
# 4. inject runtime dependencies to the targets. We need to do this after (1) since we are going to walk through
# the dependencies
include(cmake/RuntimeDependencies.cmake)
# 5. Perform test impact framework post steps once all of the targets have been enumerated
ly_test_impact_post_step()
# 6. Generate the O3DE find file and setup install locations for scripts, tools, assets etc., required by the engine
if(NOT INSTALLED_ENGINE)
ly_setup_o3de_install()
# IMPORTANT: must be included last
include(cmake/CPack.cmake)
endif()