diff --git a/CMakeLists.txt b/CMakeLists.txt index 6da92f9c2d..18fb86ff09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ if(CMAKE_VERSION VERSION_EQUAL 3.19) endif() include(cmake/Version.cmake) +include(cmake/OutputDirectory.cmake) if(NOT PROJECT_NAME) project(O3DE @@ -30,7 +31,7 @@ if(NOT PROJECT_NAME) ) endif() -include(cmake/Initialize.cmake) +include(cmake/GeneralSettings.cmake) include(cmake/FileUtil.cmake) include(cmake/PAL.cmake) include(cmake/PALTools.cmake) diff --git a/Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt b/Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt index ac8af3fdaa..ddbabe604d 100644 --- a/Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt +++ b/Code/Tools/SceneAPI/FbxSDKWrapper/CMakeLists.txt @@ -9,13 +9,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -set(sdkwrapper_dir ${CMAKE_CURRENT_LIST_DIR}/../SDKWrapper) - if (NOT PAL_TRAIT_BUILD_HOST_TOOLS) return() endif() -ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) +set(sdkwrapper_dir ${CMAKE_CURRENT_LIST_DIR}/../SDKWrapper) ly_add_target( NAME FbxSDKWrapper STATIC diff --git a/Gems/Atom/Asset/ImageProcessingAtom/3rdParty/cubemapgen.json b/Gems/Atom/Asset/ImageProcessingAtom/3rdParty/cubemapgen.json deleted file mode 100644 index c5dc8a7486..0000000000 --- a/Gems/Atom/Asset/ImageProcessingAtom/3rdParty/cubemapgen.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "cubemapgen", - "source": "@GEM@/External/CubeMapGen", - "description": "CubeMapGen", - "defines": [], - "lib_required": "False", - "includes": [""] -} - diff --git a/Gems/Atom/Asset/ImageProcessingAtom/CMakeLists.txt b/Gems/Atom/Asset/ImageProcessingAtom/CMakeLists.txt index 7f322b615a..1126af2afa 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/CMakeLists.txt +++ b/Gems/Atom/Asset/ImageProcessingAtom/CMakeLists.txt @@ -10,6 +10,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty) - add_subdirectory(Code) diff --git a/Gems/Atom/Feature/Common/CMakeLists.txt b/Gems/Atom/Feature/Common/CMakeLists.txt index d96d812af0..20a680bce9 100644 --- a/Gems/Atom/Feature/Common/CMakeLists.txt +++ b/Gems/Atom/Feature/Common/CMakeLists.txt @@ -9,6 +9,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty) - add_subdirectory(Code) diff --git a/Gems/Atom/Utils/CMakeLists.txt b/Gems/Atom/Utils/CMakeLists.txt index d96d812af0..20a680bce9 100644 --- a/Gems/Atom/Utils/CMakeLists.txt +++ b/Gems/Atom/Utils/CMakeLists.txt @@ -9,6 +9,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty) - add_subdirectory(Code) diff --git a/Gems/EMotionFX/CMakeLists.txt b/Gems/EMotionFX/CMakeLists.txt index d96d812af0..20a680bce9 100644 --- a/Gems/EMotionFX/CMakeLists.txt +++ b/Gems/EMotionFX/CMakeLists.txt @@ -9,6 +9,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty) - add_subdirectory(Code) diff --git a/Gems/NvCloth/Code/Platform/Windows/PAL_windows.cmake b/Gems/NvCloth/Code/Platform/Windows/PAL_windows.cmake index e6c7c23614..5a4d953220 100644 --- a/Gems/NvCloth/Code/Platform/Windows/PAL_windows.cmake +++ b/Gems/NvCloth/Code/Platform/Windows/PAL_windows.cmake @@ -10,3 +10,5 @@ # set(PAL_TRAIT_NVCLOTH_USE_STUB FALSE) + +ly_associate_package(PACKAGE_NAME NvCloth-1.1.6-rev1-multiplatform TARGETS NvCloth PACKAGE_HASH 05fc62634ca28644e7659a89e97f4520d791e6ddf4b66f010ac669e4e2ed4454) diff --git a/Gems/PhysX/CMakeLists.txt b/Gems/PhysX/CMakeLists.txt index d96d812af0..20a680bce9 100644 --- a/Gems/PhysX/CMakeLists.txt +++ b/Gems/PhysX/CMakeLists.txt @@ -9,6 +9,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty) - add_subdirectory(Code) diff --git a/Gems/PhysX/Code/CMakeLists.txt b/Gems/PhysX/Code/CMakeLists.txt index ac5fd902c2..e6f8fc7188 100644 --- a/Gems/PhysX/Code/CMakeLists.txt +++ b/Gems/PhysX/Code/CMakeLists.txt @@ -71,6 +71,9 @@ ly_add_target( if(PAL_TRAIT_BUILD_HOST_TOOLS) + ly_associate_package(PACKAGE_NAME poly2tri-0.3.3-rev2-multiplatform TARGETS poly2tri PACKAGE_HASH 04092d06716f59b936b61906eaf3647db23b685d81d8b66131eb53e0aeaa1a38) + ly_associate_package(PACKAGE_NAME v-hacd-2.0-rev1-multiplatform TARGETS v-hacd PACKAGE_HASH 5c71aef19cc9787d018d64eec076e9f51ea5a3e0dc6b6e22e57c898f6cc4afe3) + ly_add_target( NAME PhysX.Editor.Static STATIC NAMESPACE Gem diff --git a/Gems/PythonAssetBuilder/CMakeLists.txt b/Gems/PythonAssetBuilder/CMakeLists.txt index d577738051..20a680bce9 100644 --- a/Gems/PythonAssetBuilder/CMakeLists.txt +++ b/Gems/PythonAssetBuilder/CMakeLists.txt @@ -9,5 +9,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -ly_add_external_target_path(${CMAKE_CURRENT_LIST_DIR}/3rdParty) add_subdirectory(Code) diff --git a/Gems/PythonAssetBuilder/3rdParty/readme.md b/Gems/PythonAssetBuilder/readme.md similarity index 100% rename from Gems/PythonAssetBuilder/3rdParty/readme.md rename to Gems/PythonAssetBuilder/readme.md diff --git a/Gems/WhiteBox/Code/Source/Platform/Windows/platform_windows_tools.cmake b/Gems/WhiteBox/Code/Source/Platform/Windows/platform_windows_tools.cmake index 561ab67600..ef25fb2f63 100644 --- a/Gems/WhiteBox/Code/Source/Platform/Windows/platform_windows_tools.cmake +++ b/Gems/WhiteBox/Code/Source/Platform/Windows/platform_windows_tools.cmake @@ -10,6 +10,9 @@ # if(PAL_TRAIT_BUILD_HOST_TOOLS) + + ly_associate_package(PACKAGE_NAME OpenMesh-8.1-rev1-windows TARGETS OpenMesh PACKAGE_HASH 1c1df639358526c368e790dfce40c45cbdfcfb1c9a041b9d7054a8949d88ee77) + set(LY_BUILD_DEPENDENCIES PRIVATE 3rdParty::OpenMesh) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index e42e8e40ea..890f4bcc3f 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -31,8 +31,6 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARG ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5) ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARGETS PVRTexTool PACKAGE_HASH d0d6da61c7557de0d2c71fc35ba56c3be49555b703f0e853d4c58225537acf1e) -ly_associate_package(PACKAGE_NAME poly2tri-0.3.3-rev2-multiplatform TARGETS poly2tri PACKAGE_HASH 04092d06716f59b936b61906eaf3647db23b685d81d8b66131eb53e0aeaa1a38) -ly_associate_package(PACKAGE_NAME v-hacd-2.0-rev1-multiplatform TARGETS v-hacd PACKAGE_HASH 5c71aef19cc9787d018d64eec076e9f51ea5a3e0dc6b6e22e57c898f6cc4afe3) # platform-specific: ly_associate_package(PACKAGE_NAME freetype-2.10.4.14-linux TARGETS freetype PACKAGE_HASH 9ad246873067717962c6b780d28a5ce3cef3321b73c9aea746a039c798f52e93) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index d6d017d1d1..ff6227f88c 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -36,8 +36,6 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5) ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARGETS PVRTexTool PACKAGE_HASH d0d6da61c7557de0d2c71fc35ba56c3be49555b703f0e853d4c58225537acf1e) -ly_associate_package(PACKAGE_NAME poly2tri-0.3.3-rev2-multiplatform TARGETS poly2tri PACKAGE_HASH 04092d06716f59b936b61906eaf3647db23b685d81d8b66131eb53e0aeaa1a38) -ly_associate_package(PACKAGE_NAME v-hacd-2.0-rev1-multiplatform TARGETS v-hacd PACKAGE_HASH 5c71aef19cc9787d018d64eec076e9f51ea5a3e0dc6b6e22e57c898f6cc4afe3) # platform-specific: ly_associate_package(PACKAGE_NAME freetype-2.10.4.14-mac-ios TARGETS freetype PACKAGE_HASH 67b4f57aed92082d3fd7c16aa244a7d908d90122c296b0a63f73e0a0b8761977) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index ac2cb1d418..e79d6d9af1 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -37,9 +37,6 @@ ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e) ly_associate_package(PACKAGE_NAME Blast-1.1.7-rev1-multiplatform TARGETS Blast PACKAGE_HASH 36b8f393bcd25d0f85cfc7a831ebbdac881e6054c4f0735649966aa6aa86e6f0) ly_associate_package(PACKAGE_NAME PVRTexTool-4.24.0-rev4-multiplatform TARGETS PVRTexTool PACKAGE_HASH d0d6da61c7557de0d2c71fc35ba56c3be49555b703f0e853d4c58225537acf1e) -ly_associate_package(PACKAGE_NAME NvCloth-1.1.6-rev1-multiplatform TARGETS NvCloth PACKAGE_HASH 05fc62634ca28644e7659a89e97f4520d791e6ddf4b66f010ac669e4e2ed4454) -ly_associate_package(PACKAGE_NAME poly2tri-0.3.3-rev2-multiplatform TARGETS poly2tri PACKAGE_HASH 04092d06716f59b936b61906eaf3647db23b685d81d8b66131eb53e0aeaa1a38) -ly_associate_package(PACKAGE_NAME v-hacd-2.0-rev1-multiplatform TARGETS v-hacd PACKAGE_HASH 5c71aef19cc9787d018d64eec076e9f51ea5a3e0dc6b6e22e57c898f6cc4afe3) # platform-specific: ly_associate_package(PACKAGE_NAME freetype-2.10.4.14-windows TARGETS freetype PACKAGE_HASH 88dedc86ccb8c92f14c2c033e51ee7d828fa08eafd6475c6aa963938a99f4bf3) diff --git a/cmake/3rdPartyPackages.cmake b/cmake/3rdPartyPackages.cmake index 3984111996..b3545fd415 100644 --- a/cmake/3rdPartyPackages.cmake +++ b/cmake/3rdPartyPackages.cmake @@ -621,7 +621,6 @@ endfunction() # - this waill cause it to automatically download and activate this package if it finds a target that # depends on '3rdParty::zlib' in its runtime or its build time dependency list. # - note that '3rdParty' is implied, do not specify it in the TARGETS list. - function(ly_associate_package) set(_oneValueArgs PACKAGE_NAME PACKAGE_HASH) set(_multiValueArgs TARGETS) @@ -643,6 +642,9 @@ function(ly_associate_package) set_property(GLOBAL PROPERTY LY_PACKAGE_ASSOCIATION_${find_package_name} ${ly_associate_package_PACKAGE_NAME}) set_property(GLOBAL PROPERTY LY_PACKAGE_HASH_${ly_associate_package_PACKAGE_NAME} ${ly_associate_package_PACKAGE_HASH}) endforeach() + + set_property(GLOBAL APPEND PROPERTY LY_PACKAGE_NAMES ${ly_associate_package_PACKAGE_NAME}) + set_property(GLOBAL PROPERTY LY_PACKAGE_TARGETS_${ly_associate_package_PACKAGE_NAME} ${ly_associate_package_TARGETS}) endfunction() #! Given a package find_package name (eg, 'zlib' not the actual package name) diff --git a/cmake/FindTarget.cmake.in b/cmake/FindTarget.cmake.in index 7d0129d05a..8ad9822dae 100644 --- a/cmake/FindTarget.cmake.in +++ b/cmake/FindTarget.cmake.in @@ -14,32 +14,21 @@ include(FindPackageHandleStandardArgs) ly_add_target( - -NAME @NAME_PLACEHOLDER@ UNKNOWN IMPORTED - -@NAMESPACE_PLACEHOLDER@ - + NAME @NAME_PLACEHOLDER@ UNKNOWN IMPORTED + @NAMESPACE_PLACEHOLDER@ + COMPILE_DEFINITIONS + INTERFACE +@COMPILE_DEFINITIONS_PLACEHOLDER@ + INCLUDE_DIRECTORIES + INTERFACE @INCLUDE_DIRECTORIES_PLACEHOLDER@ - + BUILD_DEPENDENCIES + INTERFACE @BUILD_DEPENDENCIES_PLACEHOLDER@ - + RUNTIME_DEPENDENCIES @RUNTIME_DEPENDENCIES_PLACEHOLDER@ - -@COMPILE_DEFINITIONS_PLACEHOLDER@ ) -# The below if was generated from if (NOT HEADER_ONLY_PLACEHOLDER) -# HEADER_ONLY_PLACEHOLDER evaluates to TRUE or FALSE -if (NOT @HEADER_ONLY_PLACEHOLDER@) - # Load information for each installed configuration. - foreach(config @ALL_CONFIGS@) - set(@NAME_PLACEHOLDER@_${config}_FOUND FALSE) - include("${LY_ROOT_FOLDER}/cmake_autogen/@NAME_PLACEHOLDER@/@NAME_PLACEHOLDER@_${config}.cmake") - endforeach() - - find_package_handle_standard_args(@NAME_PLACEHOLDER@ - "Could not find package @NAME_PLACEHOLDER@" - @TARGET_CONFIG_FOUND_VARS_PLACEHOLDER@) -else() - set(@NAME_PLACEHOLDER@_FOUND TRUE) -endif() \ No newline at end of file +foreach(config @CMAKE_CONFIGURATION_TYPES@) + include("${LY_ROOT_FOLDER}/cmake_autogen/@NAME_PLACEHOLDER@/@NAME_PLACEHOLDER@_${config}.cmake" OPTIONAL) +endforeach() diff --git a/cmake/FindTargetTemplate.cmake b/cmake/FindTargetTemplate.cmake deleted file mode 100644 index 7d0129d05a..0000000000 --- a/cmake/FindTargetTemplate.cmake +++ /dev/null @@ -1,45 +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. -# - -# Generated by O3DE - -include(FindPackageHandleStandardArgs) - -ly_add_target( - -NAME @NAME_PLACEHOLDER@ UNKNOWN IMPORTED - -@NAMESPACE_PLACEHOLDER@ - -@INCLUDE_DIRECTORIES_PLACEHOLDER@ - -@BUILD_DEPENDENCIES_PLACEHOLDER@ - -@RUNTIME_DEPENDENCIES_PLACEHOLDER@ - -@COMPILE_DEFINITIONS_PLACEHOLDER@ -) - -# The below if was generated from if (NOT HEADER_ONLY_PLACEHOLDER) -# HEADER_ONLY_PLACEHOLDER evaluates to TRUE or FALSE -if (NOT @HEADER_ONLY_PLACEHOLDER@) - # Load information for each installed configuration. - foreach(config @ALL_CONFIGS@) - set(@NAME_PLACEHOLDER@_${config}_FOUND FALSE) - include("${LY_ROOT_FOLDER}/cmake_autogen/@NAME_PLACEHOLDER@/@NAME_PLACEHOLDER@_${config}.cmake") - endforeach() - - find_package_handle_standard_args(@NAME_PLACEHOLDER@ - "Could not find package @NAME_PLACEHOLDER@" - @TARGET_CONFIG_FOUND_VARS_PLACEHOLDER@) -else() - set(@NAME_PLACEHOLDER@_FOUND TRUE) -endif() \ No newline at end of file diff --git a/cmake/Findo3de.cmake.in b/cmake/Findo3de.cmake.in index 7ecb73e874..5a56de0851 100644 --- a/cmake/Findo3de.cmake.in +++ b/cmake/Findo3de.cmake.in @@ -15,7 +15,7 @@ include(FindPackageHandleStandardArgs) # This will be called from within the installed engine's CMakeLists.txt macro(ly_find_o3de_packages) - @FIND_PACKAGES_PLACEHOLDER@ +@FIND_PACKAGES_PLACEHOLDER@ find_package(LauncherGenerator) endmacro() diff --git a/cmake/Findo3deTemplate.cmake b/cmake/Findo3deTemplate.cmake deleted file mode 100644 index 0e904fd95d..0000000000 --- a/cmake/Findo3deTemplate.cmake +++ /dev/null @@ -1,35 +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. -# - -# Generated by O3DE - -include(FindPackageHandleStandardArgs) - -# This will be called from within the installed engine's CMakeLists.txt -macro(ly_find_o3de_packages) - @FIND_PACKAGES_PLACEHOLDER@ - find_package(LauncherGenerator) -endmacro() - - -function(o3de_current_file_path path) - set(${path} ${CMAKE_CURRENT_FUNCTION_LIST_DIR} PARENT_SCOPE) -endfunction() - - -# We are using the engine's CMakeLists.txt to handle initialization/importing targets -# Since this is external to the project's source, we need to specify an output directory -# even though we don't build -macro(o3de_initialize) - set(LY_PROJECTS ${CMAKE_SOURCE_DIR}) - o3de_current_file_path(current_path) - add_subdirectory(${current_path}/.. o3de) -endmacro() \ No newline at end of file diff --git a/cmake/Initialize.cmake b/cmake/GeneralSettings.cmake similarity index 69% rename from cmake/Initialize.cmake rename to cmake/GeneralSettings.cmake index 474ea39dd6..2083981291 100644 --- a/cmake/Initialize.cmake +++ b/cmake/GeneralSettings.cmake @@ -17,12 +17,6 @@ include(cmake/LySet.cmake) set_property(GLOBAL PROPERTY USE_FOLDERS ON) ly_set(CMAKE_WARN_DEPRECATED ON) -# Set output directories -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Build directory for static libraries and import libraries") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for shared libraries") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for executables") -set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation prefix") - set(LY_EXTERNAL_SUBDIRS "" CACHE STRING "Additional list of subdirectory to recurse into via the cmake `add_subdirectory()` command. \ The subdirectories are included after the restricted platform folders have been visited by a call to `add_subdirectory(restricted/\${restricted_platform})`") diff --git a/cmake/OutputDirectory.cmake b/cmake/OutputDirectory.cmake new file mode 100644 index 0000000000..9055802d39 --- /dev/null +++ b/cmake/OutputDirectory.cmake @@ -0,0 +1,16 @@ +# +# 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. +# + +# Set output directories +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Build directory for static libraries and import libraries") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for shared libraries") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for executables") +set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation prefix") diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 7ac9a3afa8..286f449acd 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -9,6 +9,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(CMAKE_INSTALL_MESSAGE NEVER) # Simplify messages to reduce output noise #! ly_install_target: registers the target to be installed by cmake install. # @@ -35,27 +36,16 @@ function(ly_install_target ly_install_target_NAME) install( TARGETS ${ly_install_target_NAME} - EXPORT ${ly_install_target_NAME}Targets LIBRARY DESTINATION lib/$ ARCHIVE DESTINATION lib/$ RUNTIME DESTINATION bin/$ PUBLIC_HEADER DESTINATION ${include_location} ) - - install(EXPORT ${ly_install_target_NAME}Targets + + ly_generate_target_config_file(${ly_install_target_NAME}) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ly_install_target_NAME}_$.cmake" DESTINATION cmake_autogen/${ly_install_target_NAME} ) - - # Header only targets(i.e., INTERFACE) don't have outputs - get_target_property(target_type ${ly_install_target_NAME} TYPE) - if(NOT ${target_type} STREQUAL "INTERFACE_LIBRARY") - ly_generate_target_config_file(${ly_install_target_NAME}) - - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ly_install_target_NAME}_$.cmake" - DESTINATION cmake_autogen/${ly_install_target_NAME} - ) - endif() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Find${ly_install_target_NAME}.cmake" DESTINATION cmake ) @@ -66,8 +56,8 @@ endfunction() #! ly_generate_target_find_file: generates the Find${target}.cmake file which is used when importing installed packages. # # \arg:NAME name of the target -# \arg:INCLUDE_DIRECTORIES paths to the include directories # \arg:NAMESPACE namespace declaration for this target. It will be used for IDE and dependencies +# \arg:INCLUDE_DIRECTORIES paths to the include directories # \arg:BUILD_DEPENDENCIES list of interfaces this target depends on (could be a compilation dependency # if the dependency is only exposing an include path, or could be a linking # dependency is exposing a lib) @@ -77,64 +67,38 @@ function(ly_generate_target_find_file) set(options) set(oneValueArgs NAME NAMESPACE) - set(multiValueArgs COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES INCLUDE_DIRECTORIES) + set(multiValueArgs INCLUDE_DIRECTORIES COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES) cmake_parse_arguments(ly_generate_target_find_file "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - # These targets will be imported. So we strip PRIVATE properties. - # We can only set INTERFACE properties on imported targets - unset(build_dependencies_interface_props) - unset(compile_definitions_interface_props) - unset(include_directories_interface_props) - unset(installed_include_directories_interface_props) - ly_strip_non_interface_properties(build_dependencies_interface_props ${ly_generate_target_find_file_BUILD_DEPENDENCIES}) - ly_strip_non_interface_properties(compile_definitions_interface_props ${ly_generate_target_find_file_COMPILE_DEFINITIONS}) - ly_strip_non_interface_properties(include_directories_interface_props ${ly_generate_target_find_file_INCLUDE_DIRECTORIES}) - set(NAME_PLACEHOLDER ${ly_generate_target_find_file_NAME}) + unset(NAMESPACE_PLACEHOLDER) + unset(COMPILE_DEFINITIONS_PLACEHOLDER) + unset(include_directories_interface_props) + unset(INCLUDE_DIRECTORIES_PLACEHOLDER) + set(RUNTIME_DEPENDENCIES_PLACEHOLDER ${ly_generate_target_find_file_RUNTIME_DEPENDENCIES}) - # Includes need additional processing to add the install root - foreach(include ${include_directories_interface_props}) - set(installed_include_prefix "\${LY_ROOT_FOLDER}/include/") - file(RELATIVE_PATH relative_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${include}) - string(APPEND installed_include_prefix ${relative_path}) - list(APPEND installed_include_directories_interface_props ${installed_include_prefix}) - endforeach() + # These targets will be imported. We will expose PUBLIC and INTERFACE properties as INTERFACE properties since + # only INTERFACE properties can be exposed on imported targets + ly_strip_private_properties(COMPILE_DEFINITIONS_PLACEHOLDER ${ly_generate_target_find_file_COMPILE_DEFINITIONS}) + ly_strip_private_properties(include_directories_interface_props ${ly_generate_target_find_file_INCLUDE_DIRECTORIES}) + ly_strip_private_properties(BUILD_DEPENDENCIES_PLACEHOLDER ${ly_generate_target_find_file_BUILD_DEPENDENCIES}) if(ly_generate_target_find_file_NAMESPACE) set(NAMESPACE_PLACEHOLDER "NAMESPACE ${ly_generate_target_find_file_NAMESPACE}") endif() - if(installed_include_directories_interface_props) - string(REPLACE ";" "\n" include_dirs "${installed_include_directories_interface_props}") - set(INCLUDE_DIRECTORIES_PLACEHOLDER "INCLUDE_DIRECTORIES\nINTERFACE\n${include_dirs}") - endif() - if(build_dependencies_interface_props) - string(REPLACE ";" "\n" build_deps "${build_dependencies_interface_props}") - set(BUILD_DEPENDENCIES_PLACEHOLDER "BUILD_DEPENDENCIES\nINTERFACE\n${build_deps}") - endif() - if(ly_generate_target_find_file_RUNTIME_DEPENDENCIES) - string(REPLACE ";" "\n" runtime_deps "${ly_generate_target_find_file_RUNTIME_DEPENDENCIES}") - set(RUNTIME_DEPENDENCIES_PLACEHOLDER "RUNTIME_DEPENDENCIES\n${runtime_deps}") - endif() - if(compile_definitions_interface_props) - string(REPLACE ";" "\n" compile_defs "${compile_definitions_interface_props}") - set(COMPILE_DEFINITIONS_PLACEHOLDER "COMPILE_DEFINITIONS\nINTERFACE\n${compile_defs}") - endif() - string(REPLACE ";" " " ALL_CONFIGS "${CMAKE_CONFIGURATION_TYPES}") + string(REPLACE ";" "\n" COMPILE_DEFINITIONS_PLACEHOLDER "${COMPILE_DEFINITIONS_PLACEHOLDER}") - set(target_config_found_vars "") - foreach(config ${CMAKE_CONFIGURATION_TYPES}) - string(APPEND target_config_found_vars "\n${ly_generate_target_find_file_NAME}_${config}_FOUND") + # Includes need additional processing to add the install root + foreach(include ${include_directories_interface_props}) + set(installed_include_prefix "\${LY_ROOT_FOLDER}/include/") + file(RELATIVE_PATH relative_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${include}) + list(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "include/${relative_path}") endforeach() - set(TARGET_CONFIG_FOUND_VARS_PLACEHOLDER "${target_config_found_vars}") - - # Interface libs aren't built so they don't generate a library. These are our HEADER_ONLY targets. - get_target_property(target_type ${ly_generate_target_find_file_NAME} TYPE) - if(NOT ${target_type} STREQUAL "INTERFACE_LIBRARY") - set(HEADER_ONLY_PLACEHOLDER FALSE) - else() - set(HEADER_ONLY_PLACEHOLDER TRUE) - endif() + string(REPLACE ";" "\n" INCLUDE_DIRECTORIES_PLACEHOLDER "${INCLUDE_DIRECTORIES_PLACEHOLDER}") + + string(REPLACE ";" "\n" BUILD_DEPENDENCIES_PLACEHOLDER "${BUILD_DEPENDENCIES_PLACEHOLDER}") + string(REPLACE ";" "\n" RUNTIME_DEPENDENCIES_PLACEHOLDER "${RUNTIME_DEPENDENCIES_PLACEHOLDER}") configure_file(${LY_ROOT_FOLDER}/cmake/FindTarget.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Find${ly_generate_target_find_file_NAME}.cmake @ONLY) @@ -148,37 +112,47 @@ endfunction() # \arg:NAME name of the target function(ly_generate_target_config_file NAME) - # SHARED_LIBRARY is omitted from this list because we link to the implib on Windows - set(BINARY_DIR_OUTPUTS EXECUTABLE APPLICATION) - set(target_file_contents "") - if(${target_type} IN_LIST BINARY_DIR_OUTPUTS) - set(out_file_generator TARGET_FILE_NAME) - set(out_dir bin) - else() - set(out_file_generator TARGET_LINKER_FILE_NAME) - set(out_dir lib) - endif() - - string(APPEND target_file_contents " -# Generated by O3DE + get_target_property(target_type ${NAME} TYPE) + + unset(target_file_contents) + if(NOT target_type STREQUAL INTERFACE_LIBRARY) + + set(BINARY_DIR_OUTPUTS EXECUTABLE APPLICATION) + set(target_file_contents "") + if(${target_type} IN_LIST BINARY_DIR_OUTPUTS) + set(out_file_generator TARGET_FILE_NAME) + set(out_dir bin) + else() + set(out_file_generator TARGET_LINKER_FILE_NAME) + set(out_dir lib) + endif() -set_target_properties(${NAME} PROPERTIES IMPORTED_LOCATION \"\${LY_ROOT_FOLDER}/${out_dir}/$/$<${out_file_generator}:${NAME}>\") + string(APPEND target_file_contents +"# Generated by O3DE install -if(EXISTS \"\${LY_ROOT_FOLDER}/${out_dir}/$/$<${out_file_generator}:${NAME}>\") +set(target_location \"\${LY_ROOT_FOLDER}/${out_dir}/$/$<${out_file_generator}:${NAME}>\") +set_target_properties(${NAME} + PROPERTIES + $<$:IMPORTED_LOCATION \"\${target_location}>\" + IMPORTED_LOCATION_$> \"\${target_location}\" +) +if(EXISTS \"\${target_location}\") set(${NAME}_$_FOUND TRUE) else() set(${NAME}_$_FOUND FALSE) -endif()") +endif() +") + endif() - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_$.cmake" CONTENT ${target_file_contents}) + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_$.cmake" CONTENT "${target_file_contents}") endfunction() -#! ly_strip_non_interface_properties: strips private properties since we're exporting an interface target +#! ly_strip_private_properties: strips private properties since we're exporting an interface target # # \arg:INTERFACE_PROPERTIES list of interface properties to be returned -function(ly_strip_non_interface_properties INTERFACE_PROPERTIES) +function(ly_strip_private_properties INTERFACE_PROPERTIES) set(reserved_keywords PRIVATE PUBLIC INTERFACE) unset(last_keyword) unset(stripped_props) @@ -196,36 +170,79 @@ function(ly_strip_non_interface_properties INTERFACE_PROPERTIES) endfunction() -#! ly_setup_o3de_install: generates the Findo3de.cmake file and setup install locations for scripts, tools, assets etc., +#! ly_setup_o3de_install: orchestrates the installation of the different parts. This is the entry point from the root CMakeLists.txt function(ly_setup_o3de_install) - get_property(all_targets GLOBAL PROPERTY LY_ALL_TARGETS) - unset(find_package_list) - foreach(target IN LISTS all_targets) - list(APPEND find_package_list "find_package(${target})") - endforeach() + ly_setup_cmake_install() + ly_setup_target_generator() + ly_setup_others() + +endfunction() + +#! ly_setup_cmake_install: install the "cmake" folder +function(ly_setup_cmake_install) - string(REPLACE ";" "\n" FIND_PACKAGES_PLACEHOLDER "${find_package_list}") + install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" + DESTINATION . + REGEX "Findo3de.cmake" EXCLUDE + REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE + ) + install( + FILES + "${CMAKE_SOURCE_DIR}/CMakeLists.txt" + "${CMAKE_SOURCE_DIR}/engine.json" + DESTINATION . + ) - configure_file(${LY_ROOT_FOLDER}/cmake/Findo3de.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Findo3de.cmake @ONLY) + # Collect all Find files that were added with ly_add_external_target_path + unset(additional_find_files) + get_property(additional_module_paths GLOBAL PROPERTY LY_ADDITIONAL_MODULE_PATH) + foreach(additional_module_path ${additional_module_paths}) + unset(find_files) + file(GLOB find_files "${additional_module_path}/Find*.cmake") + list(APPEND additional_find_files "${find_files}") + endforeach() + install(FILES ${additional_find_files} + DESTINATION cmake/3rdParty + ) - ly_install_launcher_target_generator() + # Findo3de.cmake file: we generate a different Findo3de.camke file than the one we have in cmake. This one is going to expose all + # targets that are pre-built + get_property(all_targets GLOBAL PROPERTY LY_ALL_TARGETS) + unset(FIND_PACKAGES_PLACEHOLDER) + foreach(target IN LISTS all_targets) + string(APPEND FIND_PACKAGES_PLACEHOLDER " find_package(${target})\n") + endforeach() - ly_install_o3de_directories() + configure_file(${LY_ROOT_FOLDER}/cmake/Findo3de.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/Findo3de.cmake @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Findo3de.cmake" + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/Findo3de.cmake" DESTINATION cmake ) + + # BuiltInPackage_.cmake: since associations could happen in any cmake file across the engine. We collect + # all the associations in ly_associate_package and then generate them into BuiltInPackages_.cmake. This + # will consolidate all associations in one file + get_property(all_package_names GLOBAL PROPERTY LY_PACKAGE_NAMES) + set(builtinpackages "# Generated by O3DE install\n\n") + foreach(package_name IN LISTS all_package_names) + get_property(package_hash GLOBAL PROPERTY LY_PACKAGE_HASH_${package_name}) + get_property(targets GLOBAL PROPERTY LY_PACKAGE_TARGETS_${package_name}) + string(APPEND builtinpackages "ly_associate_package(PACKAGE_NAME ${package_name} TARGETS ${targets} PACKAGE_HASH ${package_hash})\n") + endforeach() - install(FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt" - DESTINATION . + ly_get_absolute_pal_filename(pal_builtin_file ${CMAKE_CURRENT_BINARY_DIR}/cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/BuiltInPackages_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) + file(GENERATE OUTPUT ${pal_builtin_file} + CONTENT ${builtinpackages} + ) + install(FILES "${pal_builtin_file}" + DESTINATION cmake/3rdParty/Platform/${PAL_PLATFORM_NAME} ) endfunction() - -#! ly_install_o3de_directories: install directories required by the engine -function(ly_install_o3de_directories) +#! ly_setup_others: install directories required by the engine +function(ly_setup_others) # List of directories we want to install relative to engine root set(DIRECTORIES_TO_INSTALL Tools/LyTestTools Tools/RemoteConsole ctest_scripts scripts) @@ -242,12 +259,6 @@ function(ly_install_o3de_directories) endforeach() - # Directories which have excludes - install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" - DESTINATION . - REGEX "Findo3de.cmake" EXCLUDE - ) - install(DIRECTORY "${CMAKE_SOURCE_DIR}/python" DESTINATION . REGEX "downloaded_packages" EXCLUDE @@ -257,8 +268,8 @@ function(ly_install_o3de_directories) endfunction() -#! ly_install_launcher_target_generator: install source files needed for project launcher generation -function(ly_install_launcher_target_generator) +#! ly_setup_target_generator: install source files needed for project launcher generation +function(ly_setup_target_generator) install(FILES ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/launcher_generator.cmake diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index 4dd99686c5..a4a5a52c4d 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -290,7 +290,7 @@ "PARAMETERS": { "CONFIGURATION": "profile", "OUTPUT_DIRECTORY": "build\\windows_vs2019", - "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DLY_DISABLE_TEST_MODULES=TRUE -DCMAKE_INSTALL_PREFIX=build\\install", + "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DLY_DISABLE_TEST_MODULES=TRUE -DCMAKE_INSTALL_PREFIX=install", "CMAKE_LY_PROJECTS": "", "CMAKE_TARGET": "INSTALL", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo"