From 11b6874d92a4e555097fe12f83f2f841918d6a02 Mon Sep 17 00:00:00 2001 From: scottr Date: Wed, 14 Apr 2021 15:39:22 -0700 Subject: [PATCH 01/15] [cpack_installer] initial support for installable components --- cmake/Platform/Common/Install_common.cmake | 48 +++++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 9164105f3a..25f2bd6e69 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(_default_component "com.o3de.default") #! ly_install_target: registers the target to be installed by cmake install. # @@ -22,6 +23,12 @@ # \arg:COMPILE_DEFINITIONS list of compilation definitions this target will use to compile function(ly_install_target ly_install_target_NAME) + set(options) + set(oneValueArgs NAMESPACE COMPONENT) + set(multiValueArgs INCLUDE_DIRECTORIES BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES COMPILE_DEFINITIONS) + + cmake_parse_arguments(ly_install_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + # All include directories marked PUBLIC or INTERFACE will be installed set(include_location "include") get_target_property(include_directories ${ly_install_target_NAME} INTERFACE_INCLUDE_DIRECTORIES) @@ -43,14 +50,23 @@ 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} + LIBRARY + DESTINATION lib/$ + COMPONENT ${ly_install_target_COMPONENT} + ARCHIVE + DESTINATION lib/$ + COMPONENT ${ly_install_target_COMPONENT} + RUNTIME + DESTINATION bin/$ + COMPONENT ${ly_install_target_COMPONENT} + PUBLIC_HEADER + DESTINATION ${include_location} + COMPONENT ${ly_install_target_COMPONENT} ) - + install(EXPORT ${ly_install_target_NAME}Targets DESTINATION cmake_autogen/${ly_install_target_NAME} + COMPONENT ${ly_install_target_COMPONENT} ) # Header only targets(i.e., INTERFACE) don't have outputs @@ -60,11 +76,13 @@ function(ly_install_target ly_install_target_NAME) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ly_install_target_NAME}_$.cmake" DESTINATION cmake_autogen/${ly_install_target_NAME} + COMPONENT ${ly_install_target_COMPONENT} ) endif() install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Find${ly_install_target_NAME}.cmake" - DESTINATION cmake + DESTINATION . + COMPONENT ${ly_install_target_COMPONENT} ) endfunction() @@ -81,7 +99,7 @@ endfunction() # \arg:RUNTIME_DEPENDENCIES list of dependencies this target depends on at runtime # \arg:COMPILE_DEFINITIONS list of compilation definitions this target will use to compile function(ly_generate_target_find_file) - + set(options) set(oneValueArgs NAME NAMESPACE) set(multiValueArgs COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES INCLUDE_DIRECTORIES) @@ -154,7 +172,7 @@ endfunction() # These per config files will be included by the target's find file to set the location of the binary/ # \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 "") @@ -205,7 +223,7 @@ endfunction() #! ly_setup_o3de_install: generates the Findo3de.cmake file and setup install locations for scripts, tools, assets etc., function(ly_setup_o3de_install) - + get_property(all_targets GLOBAL PROPERTY LY_ALL_TARGETS) unset(find_package_list) foreach(target IN LISTS all_targets) @@ -222,10 +240,12 @@ function(ly_setup_o3de_install) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Findo3de.cmake" DESTINATION cmake + COMPONENT ${_default_component} ) install(FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt" DESTINATION . + COMPONENT ${_default_component} ) endfunction() @@ -237,14 +257,15 @@ function(ly_install_o3de_directories) # List of directories we want to install relative to engine root set(DIRECTORIES_TO_INSTALL Tools/LyTestTools Tools/RemoteConsole ctest_scripts scripts) foreach(dir ${DIRECTORIES_TO_INSTALL}) - + get_filename_component(install_path ${dir} DIRECTORY) if (NOT install_path) set(install_path .) endif() - + install(DIRECTORY "${CMAKE_SOURCE_DIR}/${dir}" DESTINATION ${install_path} + COMPONENT ${_default_component} ) endforeach() @@ -252,11 +273,13 @@ function(ly_install_o3de_directories) # Directories which have excludes install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . + COMPONENT ${_default_component} REGEX "Findo3de.cmake" EXCLUDE ) install(DIRECTORY "${CMAKE_SOURCE_DIR}/python" DESTINATION . + COMPONENT ${_default_component} REGEX "downloaded_packages" EXCLUDE REGEX "runtime" EXCLUDE ) @@ -273,12 +296,15 @@ function(ly_install_launcher_target_generator) ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/LauncherProject.cpp ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/StaticModules.in DESTINATION LauncherGenerator + COMPONENT ${_default_component} ) install(DIRECTORY ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/Platform DESTINATION LauncherGenerator + COMPONENT ${_default_component} ) install(FILES ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/FindLauncherGenerator.cmake DESTINATION cmake + COMPONENT ${_default_component} ) endfunction() \ No newline at end of file From 62f67b16da0a5e0b3ba41ca9b46e73690a0cfbf5 Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 15 Apr 2021 16:12:12 -0700 Subject: [PATCH 02/15] [cpack_installer] wrapped stray PrefabBuilder.Tests around PAL_TRAIT_BUILD_TESTS_SUPPORTED --- Gems/Prefab/PrefabBuilder/CMakeLists.txt | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Gems/Prefab/PrefabBuilder/CMakeLists.txt b/Gems/Prefab/PrefabBuilder/CMakeLists.txt index 5ab614eecb..22b89287ca 100644 --- a/Gems/Prefab/PrefabBuilder/CMakeLists.txt +++ b/Gems/Prefab/PrefabBuilder/CMakeLists.txt @@ -38,23 +38,6 @@ ly_add_target( Gem::PrefabBuilder.Static ) -ly_add_target( - NAME PrefabBuilder.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE Gem - FILES_CMAKE - prefabbuilder_tests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - . - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTest - Gem::PrefabBuilder.Static -) -ly_add_googletest( - NAME Gem::PrefabBuilder.Tests -) - ly_add_target_dependencies( TARGETS AssetBuilder @@ -63,3 +46,22 @@ ly_add_target_dependencies( DEPENDENT_TARGETS Gem::PrefabBuilder ) + +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) + ly_add_target( + NAME PrefabBuilder.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE Gem + FILES_CMAKE + prefabbuilder_tests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + . + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + Gem::PrefabBuilder.Static + ) + ly_add_googletest( + NAME Gem::PrefabBuilder.Tests + ) +endif() From 23c9f7ab78fd4e075d0b1772f02d81c370da0274 Mon Sep 17 00:00:00 2001 From: scottr Date: Fri, 16 Apr 2021 10:18:36 -0700 Subject: [PATCH 03/15] [cpack_installer] initial CPack IFW support --- CMakeLists.txt | 7 +++++-- cmake/CPack.cmake | 33 +++++++++++++++++++++++++++++++++ cmake/cmake_files.cmake | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 cmake/CPack.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c09cfc9588..2e0af34c08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,10 @@ endif() 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 +# 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() -endif() \ No newline at end of file +endif() + +# IMPORTANT: must be included last +include(cmake/CPack.cmake) \ No newline at end of file diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake new file mode 100644 index 0000000000..46cd044ced --- /dev/null +++ b/cmake/CPack.cmake @@ -0,0 +1,33 @@ +# +# 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(CPACK_GENERATOR "IFW") + +set(CPACK_PACKAGE_VENDOR "O3DE") +set(CPACK_PACKAGE_VERSION "1.0.0") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool") + +set(CPACK_PACKAGE_FILE_NAME "o3de_installer") + +set(DEFAULT_LICENSE_NAME "Apache 2.0") +set(DEFAULT_LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt) + +set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE}) + +set(CPACK_IFW_PACKAGE_TITLE "O3DE Installer") +set(CPACK_IFW_PACKAGE_PUBLISHER "O3DE") + +set(CPACK_IFW_TARGET_DIRECTORY "@ApplicationsDir@/O3DE/${LY_VERSION_STRING}") +set(CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "O3DE") + +# IMPORTANT: required to be included AFTER setting all property overrides +include(CPack REQUIRED) +include(CPackIFW REQUIRED) \ No newline at end of file diff --git a/cmake/cmake_files.cmake b/cmake/cmake_files.cmake index 2b0f65ca99..18efa314d5 100644 --- a/cmake/cmake_files.cmake +++ b/cmake/cmake_files.cmake @@ -14,6 +14,7 @@ set(FILES 3rdPartyPackages.cmake CommandExecution.cmake Configurations.cmake + CPack.cmake Dependencies.cmake Deployment.cmake EngineFinder.cmake From 40aef17b5545b7dc5a223b3e2d263ae5e8f8152d Mon Sep 17 00:00:00 2001 From: scottr Date: Fri, 16 Apr 2021 10:22:39 -0700 Subject: [PATCH 04/15] [cpack_installer] added option to override the inclusion of test targets in build --- cmake/PAL.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/PAL.cmake b/cmake/PAL.cmake index 734baad8a3..5131005c72 100644 --- a/cmake/PAL.cmake +++ b/cmake/PAL.cmake @@ -85,3 +85,9 @@ ly_include_cmake_file_list(${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_fi include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) include(${pal_dir}/Toolchain_${PAL_PLATFORM_NAME_LOWERCASE}.cmake OPTIONAL) + +set(LY_DISABLE_TEST_MODULES FALSE CACHE BOOL "Option to forcibly disable the inclusion of test targets in the build") + +if(LY_DISABLE_TEST_MODULES) + ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED FALSE) +endif() From 4638a831bcf918c78252cc9d0412454bf650d5ac Mon Sep 17 00:00:00 2001 From: scottr Date: Tue, 20 Apr 2021 14:09:29 -0700 Subject: [PATCH 05/15] [cpack_installer] updates to default install component and target registration --- cmake/3rdParty.cmake | 26 ++++++---- cmake/CPack.cmake | 52 +++++++++++++++++++- cmake/LYWrappers.cmake | 57 ++++++++++++---------- cmake/Platform/Common/Install_common.cmake | 18 +++---- 4 files changed, 107 insertions(+), 46 deletions(-) diff --git a/cmake/3rdParty.cmake b/cmake/3rdParty.cmake index 4cd3ab2917..c1bde9854e 100644 --- a/cmake/3rdParty.cmake +++ b/cmake/3rdParty.cmake @@ -10,7 +10,7 @@ # # Do not overcomplicate searching for the 3rdParty path, if it is not easy to find, -# the user should define it. +# the user should define it. set(LY_3RDPARTY_PATH "" CACHE PATH "Path to the 3rdParty folder") @@ -42,7 +42,7 @@ endfunction() # \arg:PACKAGE if defined, defines the name of the external library "package". This is used when a package exposes multiple interfaces # if not defined, NAME is used # \arg:COMPILE_DEFINITIONS compile definitions to be added to the interface -# \arg:BUILD_DEPENDENCIES list of interfaces this target depends on (could be a compilation dependency if the dependency is only +# \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) # \arg:RUNTIME_DEPENDENCIES list of files this target depends on (could be a dynamic libraries, text files, executables, # applications, other 3rdParty targets, etc) @@ -133,7 +133,7 @@ function(ly_add_external_target) INTERFACE ${ly_add_external_target_INCLUDE_DIRECTORIES} ) endif() - + # Check if there is a pal file ly_get_absolute_pal_filename(pal_file ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}/${ly_add_external_target_PACKAGE}_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) if(NOT EXISTS ${pal_file}) @@ -142,7 +142,7 @@ function(ly_add_external_target) if(EXISTS ${pal_file}) include(${pal_file}) endif() - + if(${PACKAGE_AND_NAME}_INCLUDE_DIRECTORIES) list(TRANSFORM ${PACKAGE_AND_NAME}_INCLUDE_DIRECTORIES PREPEND ${BASE_PATH}/) foreach(include_path ${${PACKAGE_AND_NAME}_INCLUDE_DIRECTORIES}) @@ -263,7 +263,7 @@ function(ly_add_external_target) list(APPEND ly_add_external_target_BUILD_DEPENDENCIES "${${PACKAGE_AND_NAME}_BUILD_DEPENDENCIES}") list(REMOVE_DUPLICATES ly_add_external_target_BUILD_DEPENDENCIES) endif() - + # Interface dependencies may require to find_packages. So far, we are just using packages for 3rdParty, so we will # search for those and automatically bring those packages. The naming convention used is 3rdParty::PackageName::OptionalInterface foreach(dependency ${ly_add_external_target_BUILD_DEPENDENCIES}) @@ -278,7 +278,7 @@ function(ly_add_external_target) if(ly_add_external_target_BUILD_DEPENDENCIES) target_link_libraries(3rdParty::${NAME_WITH_NAMESPACE} - INTERFACE + INTERFACE ${ly_add_external_target_BUILD_DEPENDENCIES} ) endif() @@ -291,9 +291,12 @@ endfunction() # # \arg:3RDPARTY_ROOT_DIRECTORY custom 3rd party directory which needs to be installed function(ly_install_external_target 3RDPARTY_ROOT_DIRECTORY) - - # Install the Find file to our /cmake directory - install(FILES ${CMAKE_CURRENT_LIST_FILE} DESTINATION cmake) + + # Install the Find file to our /cmake directory + install(FILES ${CMAKE_CURRENT_LIST_FILE} + DESTINATION cmake + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} + ) # We only want to install external targets that are part of our source tree # Checking for relative path beginning with "../" also works when the path @@ -301,7 +304,10 @@ function(ly_install_external_target 3RDPARTY_ROOT_DIRECTORY) file(RELATIVE_PATH rel_path ${CMAKE_SOURCE_DIR} ${3RDPARTY_ROOT_DIRECTORY}) if (NOT ${rel_path} MATCHES "^../") get_filename_component(rel_path ${rel_path} DIRECTORY) - install(DIRECTORY ${3RDPARTY_ROOT_DIRECTORY} DESTINATION ${rel_path}) + install(DIRECTORY ${3RDPARTY_ROOT_DIRECTORY} + DESTINATION ${rel_path} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} + ) endif() endfunction() diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake index 46cd044ced..ac991af3fb 100644 --- a/cmake/CPack.cmake +++ b/cmake/CPack.cmake @@ -18,7 +18,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool") set(CPACK_PACKAGE_FILE_NAME "o3de_installer") set(DEFAULT_LICENSE_NAME "Apache 2.0") -set(DEFAULT_LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt) +set(DEFAULT_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE}) @@ -30,4 +30,52 @@ set(CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "O3DE") # IMPORTANT: required to be included AFTER setting all property overrides include(CPack REQUIRED) -include(CPackIFW REQUIRED) \ No newline at end of file +include(CPackIFW REQUIRED) + +function(ly_configure_cpack_component ly_configure_cpack_component_NAME) + + set(options REQUIRED) + set(oneValueArgs DISPLAY_NAME DESCRIPTION LICENSE_NAME LICENSE_FILE) + set(multiValueArgs) + + cmake_parse_arguments(ly_configure_cpack_component "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # default to optional + set(component_type DISABLED) + set(ifw_component_type) + + if(ly_configure_cpack_component_REQUIRED) + set(component_type REQUIRED) + set(ifw_component_type FORCED_INSTALLATION) + endif() + + set(license_name ${DEFAULT_LICENSE_NAME}) + set(license_file ${DEFAULT_LICENSE_FILE}) + + if(ly_configure_cpack_component_LICENSE_NAME AND ly_configure_cpack_component_LICENSE_FILE) + set(license_name ${ly_configure_cpack_component_LICENSE_NAME}) + set(license_file ${ly_configure_cpack_component_LICENSE_FILE}) + elseif(ly_configure_cpack_component_LICENSE_NAME OR ly_configure_cpack_component_LICENSE_FILE) + message(WARNING "Invalid argument configuration. Both LICENSE_NAME and LICENSE_FILE must be set for ly_configure_cpack_component") + endif() + + cpack_add_component( + ${ly_configure_cpack_component_NAME} ${component_type} + DISPLAY_NAME ${ly_configure_cpack_component_DISPLAY_NAME} + DESCRIPTION ${ly_configure_cpack_component_DESCRIPTION} + ) + + cpack_ifw_configure_component( + ${ly_configure_cpack_component_NAME} ${ifw_component_type} + LICENSES + ${license_name} + ${license_file} + ) +endfunction() + +# configure ALL components here +ly_configure_cpack_component( + ${LY_DEFAULT_INSTALL_COMPONENT} REQUIRED + DISPLAY_NAME "O3DE Core" + DESCRIPTION "O3DE Headers and Libraries" +) \ No newline at end of file diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index bd904adaa3..04d2d397ce 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -37,7 +37,7 @@ define_property(TARGET PROPERTY GEM_MODULE # # Adds a target (static/dynamic library, executable) and convenient wrappers around most # common parameters that need to be set. -# This function also creates an interface to use for dependencies. The interface will be +# This function also creates an interface to use for dependencies. The interface will be # named as "NAMESPACE::NAME" # Some examples: # ly_add_target(NAME mystaticlib STATIC FILES_CMAKE somestatic_files.cmake) @@ -77,11 +77,11 @@ define_property(TARGET PROPERTY GEM_MODULE function(ly_add_target) set(options STATIC SHARED MODULE GEM_MODULE HEADERONLY EXECUTABLE APPLICATION UNKNOWN IMPORTED AUTOMOC AUTOUIC AUTORCC NO_UNITY) - set(oneValueArgs NAME NAMESPACE OUTPUT_SUBDIRECTORY OUTPUT_NAME) + set(oneValueArgs NAME NAMESPACE OUTPUT_SUBDIRECTORY OUTPUT_NAME INSTALL_COMPONENT) set(multiValueArgs FILES_CMAKE GENERATED_FILES INCLUDE_DIRECTORIES COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES PLATFORM_INCLUDE_FILES TARGET_PROPERTIES AUTOGEN_RULES) cmake_parse_arguments(ly_add_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - + # Validate input arguments if(NOT ly_add_target_NAME) message(FATAL_ERROR "You must provide a name for the target") @@ -189,7 +189,7 @@ function(ly_add_target) endif() if(ly_add_target_OUTPUT_NAME) - set_target_properties(${ly_add_target_NAME} PROPERTIES + set_target_properties(${ly_add_target_NAME} PROPERTIES OUTPUT_NAME ${ly_add_target_OUTPUT_NAME} ) endif() @@ -214,7 +214,7 @@ function(ly_add_target) ) endif() - # Parse the 3rdParty library dependencies + # Parse the 3rdParty library dependencies ly_parse_third_party_dependencies("${ly_add_target_BUILD_DEPENDENCIES}") ly_target_link_libraries(${ly_add_target_NAME} ${ly_add_target_BUILD_DEPENDENCIES} @@ -252,7 +252,7 @@ function(ly_add_target) ) endif() endif() - + # IDE organization ly_source_groups_from_folders("${ALLFILES}") source_group("Generated Files" REGULAR_EXPRESSION "(${CMAKE_BINARY_DIR})") # Any file coming from the output folder @@ -276,8 +276,8 @@ function(ly_add_target) # Handle Qt MOC, RCC, UIC # https://gitlab.kitware.com/cmake/cmake/issues/18749 - # AUTOMOC is supposed to always rebuild because it checks files that are not listed in the sources (like extra - # "_p.h" headers) and which may change outside the visibility of the generator. + # AUTOMOC is supposed to always rebuild because it checks files that are not listed in the sources (like extra + # "_p.h" headers) and which may change outside the visibility of the generator. # We are not using AUTOUIC because of: # https://gitlab.kitware.com/cmake/cmake/-/issues/18741 # To overcome this problem, we manually wrap all the ui files listed in the target with qt5_wrap_ui @@ -332,12 +332,18 @@ function(ly_add_target) ly_add_autogen( NAME ${ly_add_target_NAME} INCLUDE_DIRECTORIES ${ly_add_target_INCLUDE_DIRECTORIES} - AUTOGEN_RULES ${ly_add_target_AUTOGEN_RULES} + AUTOGEN_RULES ${ly_add_target_AUTOGEN_RULES} ALLFILES ${ALLFILES} ) endif() if(NOT ly_add_target_IMPORTED) + if(NOT ly_add_target_INSTALL_COMPONENT) + set(_component_id ${LY_DEFAULT_INSTALL_COMPONENT}) + else() + set(_component_id ${ly_add_target_INSTALL_COMPONENT}) + endif() + ly_install_target( ${ly_add_target_NAME} NAMESPACE ${ly_add_target_NAMESPACE} @@ -345,15 +351,16 @@ function(ly_add_target) BUILD_DEPENDENCIES ${ly_add_target_BUILD_DEPENDENCIES} RUNTIME_DEPENDENCIES ${ly_add_target_RUNTIME_DEPENDENCIES} COMPILE_DEFINITIONS ${ly_add_target_COMPILE_DEFINITIONS} + COMPONENT ${_component_id} ) endif() endfunction() #! ly_target_link_libraries: wraps target_link_libraries handling also MODULE linkage. -# MODULE libraries cannot be passed to target_link_libraries. MODULE libraries are shared libraries that we +# MODULE libraries cannot be passed to target_link_libraries. MODULE libraries are shared libraries that we # dont want to link against because they will be loaded dynamically. However, we want to include their public headers -# and transition their public dependencies. +# and transition their public dependencies. # To achieve this, we delay the target_link_libraries call to after all targets are declared (see ly_delayed_target_link_libraries) # # Signature is the same as target_link_libraries: @@ -364,26 +371,26 @@ function(ly_target_link_libraries TARGET) if(NOT TARGET) message(FATAL_ERROR "You must provide a target") endif() - + set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LINK_${TARGET} ${ARGN}) set_property(GLOBAL APPEND PROPERTY LY_DELAYED_LINK_TARGETS ${TARGET}) # to walk them at the end endfunction() #! ly_delayed_target_link_libraries: internal function called by the root CMakeLists.txt after all targets -# have been declared to determine if they are regularly +# have been declared to determine if they are regularly # 1) If a MODULE is passed in the list of items, it will add the INTERFACE_INCLUDE_DIRECTORIES as include # directories of TARGET. It will also add the "INTERFACE_LINK_LIBRARIES" to TARGET. MODULEs cannot be # directly linked, but we can include the public headers and link against the things the MODULE expose # to link. # 2) If a target that has not yet been declared is passed, then it will defer it to after all targets are -# declared. This way we can do a check again. We could delay the link to when +# declared. This way we can do a check again. We could delay the link to when # target is declared. This is needed for (1) since we dont know the type of target. This also addresses # another issue with target_link_libraries where it will only validate that a MODULE is not being passed # if the target is already declared, if not, it will fail later at linking time. function(ly_delayed_target_link_libraries) - + set(visibilities PRIVATE PUBLIC INTERFACE) get_property(additional_module_paths GLOBAL PROPERTY LY_ADDITIONAL_MODULE_PATH) @@ -391,15 +398,15 @@ function(ly_delayed_target_link_libraries) get_property(delayed_targets GLOBAL PROPERTY LY_DELAYED_LINK_TARGETS) foreach(target ${delayed_targets}) - + get_property(delayed_link GLOBAL PROPERTY LY_DELAYED_LINK_${target}) if(delayed_link) - + cmake_parse_arguments(ly_delayed_target_link_libraries "" "" "${visibilities}" ${delayed_link}) foreach(visibility ${visibilities}) foreach(item ${ly_delayed_target_link_libraries_${visibility}}) - + if(TARGET ${item}) get_target_property(item_type ${item} TYPE) else() @@ -412,7 +419,7 @@ function(ly_delayed_target_link_libraries) target_compile_definitions(${target} ${visibility} $) target_compile_options(${target} ${visibility} $) # Add it also as a manual dependency so runtime_dependencies walks it through - ly_add_dependencies(${target} ${item}) + ly_add_dependencies(${target} ${item}) else() ly_parse_third_party_dependencies(${item}) target_link_libraries(${target} ${visibility} ${item}) @@ -484,7 +491,7 @@ function(detect_qt_dependency TARGET_NAME OUTPUT_VARIABLE) 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. # function(ly_parse_third_party_dependencies ly_THIRD_PARTY_LIBRARIES) @@ -518,7 +525,7 @@ endfunction() # macro(ly_configure_target_platform_properties) foreach(platform_include_file ${ly_add_target_PLATFORM_INCLUDE_FILES}) - + set(LY_FILES_CMAKE) set(LY_FILES) set(LY_INCLUDE_DIRECTORIES) @@ -528,7 +535,7 @@ macro(ly_configure_target_platform_properties) set(LY_BUILD_DEPENDENCIES) set(LY_RUNTIME_DEPENDENCIES) set(LY_TARGET_PROPERTIES) - + include(${platform_include_file} RESULT_VARIABLE ly_platform_cmake_file) if(NOT ly_platform_cmake_file) message(FATAL_ERROR "The supplied PLATFORM_INCLUDE_FILE(${platform_include_file}) cannot be included.\ @@ -578,7 +585,7 @@ endmacro() # # \arg:TARGETS name of the targets that depends on this file # \arg:FILES files to copy -# \arg:OUTPUT_SUBDIRECTORY (OPTIONAL) where to place the files relative to TARGET_NAME's output dir. +# \arg:OUTPUT_SUBDIRECTORY (OPTIONAL) where to place the files relative to TARGET_NAME's output dir. # If not specified, they are located in the same folder as TARGET_NAME # function(ly_add_target_files) @@ -596,9 +603,9 @@ function(ly_add_target_files) if(NOT ly_add_target_files_FILES) message(FATAL_ERROR "You must provide at least a file to copy") endif() - + foreach(target ${ly_add_target_files_TARGETS}) - + foreach(file ${ly_add_target_files_FILES}) set_property(TARGET ${target} APPEND PROPERTY INTERFACE_LY_TARGET_FILES "${file}\n${ly_add_target_files_OUTPUT_SUBDIRECTORY}") endforeach() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 25f2bd6e69..5a9a35048e 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -9,7 +9,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -set(_default_component "com.o3de.default") +ly_set(LY_DEFAULT_INSTALL_COMPONENT "Core") #! ly_install_target: registers the target to be installed by cmake install. # @@ -240,12 +240,12 @@ function(ly_setup_o3de_install) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Findo3de.cmake" DESTINATION cmake - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt" DESTINATION . - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endfunction() @@ -265,7 +265,7 @@ function(ly_install_o3de_directories) install(DIRECTORY "${CMAKE_SOURCE_DIR}/${dir}" DESTINATION ${install_path} - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endforeach() @@ -273,13 +273,13 @@ function(ly_install_o3de_directories) # Directories which have excludes install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} REGEX "Findo3de.cmake" EXCLUDE ) install(DIRECTORY "${CMAKE_SOURCE_DIR}/python" DESTINATION . - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} REGEX "downloaded_packages" EXCLUDE REGEX "runtime" EXCLUDE ) @@ -296,15 +296,15 @@ function(ly_install_launcher_target_generator) ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/LauncherProject.cpp ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/StaticModules.in DESTINATION LauncherGenerator - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(DIRECTORY ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/Platform DESTINATION LauncherGenerator - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(FILES ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/FindLauncherGenerator.cmake DESTINATION cmake - COMPONENT ${_default_component} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endfunction() \ No newline at end of file From e9d7f335af3a2a0fe45b2dbde39985f62e9762b3 Mon Sep 17 00:00:00 2001 From: scottr Date: Wed, 21 Apr 2021 11:10:14 -0700 Subject: [PATCH 06/15] [cpack_installer] added Qt IFW loose path validation so cmake does not hard fail when it is missing --- cmake/CPack.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake index ac991af3fb..2ea3c3682a 100644 --- a/cmake/CPack.cmake +++ b/cmake/CPack.cmake @@ -9,6 +9,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(LY_QTIFW_PATH "" CACHE PATH "Path to the Qt Installer Framework install path") + +if(LY_QTIFW_PATH) + file(TO_CMAKE_PATH ${LY_QTIFW_PATH} CPACK_IFW_ROOT) +elseif(DEFINED ENV{QTIFWDIR}) + file(TO_CMAKE_PATH $ENV{QTIFWDIR} CPACK_IFW_ROOT) +endif() +if(NOT EXISTS ${CPACK_IFW_ROOT}) + message(STATUS "WARN: A valid LY_QTIFW_PATH argument or QTIFWDIR environment variable is required to enable cpack support") + return() +endif() + set(CPACK_GENERATOR "IFW") set(CPACK_PACKAGE_VENDOR "O3DE") From ca47e6dbbb11b75a8c26b3edaa65e92b21be8ef8 Mon Sep 17 00:00:00 2001 From: scottr Date: Wed, 21 Apr 2021 13:53:00 -0700 Subject: [PATCH 07/15] [cpack_installer] added PAL trait to define if CPack is supported for a platform --- cmake/CPack.cmake | 4 ++++ cmake/Platform/Android/PAL_android.cmake | 1 + cmake/Platform/Linux/PAL_linux.cmake | 1 + cmake/Platform/Mac/PAL_mac.cmake | 1 + cmake/Platform/Windows/PAL_windows.cmake | 1 + cmake/Platform/iOS/PAL_ios.cmake | 1 + 6 files changed, 9 insertions(+) diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake index 2ea3c3682a..a593382367 100644 --- a/cmake/CPack.cmake +++ b/cmake/CPack.cmake @@ -9,6 +9,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +if(NOT PAL_TRAIT_BUILD_CPACK_SUPPORTED) + return() +endif() + set(LY_QTIFW_PATH "" CACHE PATH "Path to the Qt Installer Framework install path") if(LY_QTIFW_PATH) diff --git a/cmake/Platform/Android/PAL_android.cmake b/cmake/Platform/Android/PAL_android.cmake index 80739d4208..bd76076467 100644 --- a/cmake/Platform/Android/PAL_android.cmake +++ b/cmake/Platform/Android/PAL_android.cmake @@ -19,6 +19,7 @@ ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS) ly_set(PAL_TRAIT_BUILD_EXCLUDE_ALL_TEST_RUNS_FROM_IDE TRUE) +ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED FALSE) # Test library support ly_set(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED FALSE) diff --git a/cmake/Platform/Linux/PAL_linux.cmake b/cmake/Platform/Linux/PAL_linux.cmake index ba2296bfb9..1d9f02a461 100644 --- a/cmake/Platform/Linux/PAL_linux.cmake +++ b/cmake/Platform/Linux/PAL_linux.cmake @@ -19,6 +19,7 @@ ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS) ly_set(PAL_TRAIT_BUILD_EXCLUDE_ALL_TEST_RUNS_FROM_IDE FALSE) +ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED FALSE) # Test library support ly_set(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED TRUE) diff --git a/cmake/Platform/Mac/PAL_mac.cmake b/cmake/Platform/Mac/PAL_mac.cmake index daf3331795..10df4849dd 100644 --- a/cmake/Platform/Mac/PAL_mac.cmake +++ b/cmake/Platform/Mac/PAL_mac.cmake @@ -19,6 +19,7 @@ ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS ".mm") ly_set(PAL_TRAIT_BUILD_EXCLUDE_ALL_TEST_RUNS_FROM_IDE FALSE) +ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED FALSE) # Test library support ly_set(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED TRUE) diff --git a/cmake/Platform/Windows/PAL_windows.cmake b/cmake/Platform/Windows/PAL_windows.cmake index 780f3354f7..7493a95bd6 100644 --- a/cmake/Platform/Windows/PAL_windows.cmake +++ b/cmake/Platform/Windows/PAL_windows.cmake @@ -19,6 +19,7 @@ ly_set(PAL_TRAIT_BUILD_SERVER_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS) ly_set(PAL_TRAIT_BUILD_EXCLUDE_ALL_TEST_RUNS_FROM_IDE FALSE) +ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED TRUE) # Test library support ly_set(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED TRUE) diff --git a/cmake/Platform/iOS/PAL_ios.cmake b/cmake/Platform/iOS/PAL_ios.cmake index b084a1aac3..a910f6c1be 100644 --- a/cmake/Platform/iOS/PAL_ios.cmake +++ b/cmake/Platform/iOS/PAL_ios.cmake @@ -19,6 +19,7 @@ ly_set(PAL_TRAIT_BUILD_TESTS_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_SUPPORTED TRUE) ly_set(PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS ".mm") ly_set(PAL_TRAIT_BUILD_EXCLUDE_ALL_TEST_RUNS_FROM_IDE TRUE) +ly_set(PAL_TRAIT_BUILD_CPACK_SUPPORTED FALSE) # Test library support ly_set(PAL_TRAIT_TEST_GOOGLE_TEST_SUPPORTED FALSE) From 56dfaca6cfdf5e3ee0dcf1d491caf93cadffe4b4 Mon Sep 17 00:00:00 2001 From: scottr Date: Wed, 21 Apr 2021 14:41:18 -0700 Subject: [PATCH 08/15] [cpack_installer] re-applying install component support after merge. added some missing doc comments. --- cmake/LYWrappers.cmake | 2 + cmake/Platform/Common/Install_common.cmake | 62 ++++++++++++++++------ 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 04d2d397ce..87aa37abfa 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -74,6 +74,8 @@ define_property(TARGET PROPERTY GEM_MODULE # for the list of variables that will be used by the target # \arg:TARGET_PROPERTIES additional properties to set to the target # \arg:AUTOGEN_RULES a set of AutoGeneration rules to be passed to the AzAutoGen expansion system +# \arg:INSTALL_COMPONENT (optional) the grouping string of the target used for splitting up the install into smaller +# packages. If none is specified, LY_DEFAULT_INSTALL_COMPONENT will be used function(ly_add_target) set(options STATIC SHARED MODULE GEM_MODULE HEADERONLY EXECUTABLE APPLICATION UNKNOWN IMPORTED AUTOMOC AUTOUIC AUTORCC NO_UNITY) diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 286f449acd..e94d8c1560 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -11,11 +11,21 @@ set(CMAKE_INSTALL_MESSAGE NEVER) # Simplify messages to reduce output noise +ly_set(LY_DEFAULT_INSTALL_COMPONENT "Core") + #! ly_install_target: registers the target to be installed by cmake install. # # \arg:NAME name of the target +# \arg:COMPONENT the grouping string of the target used for splitting up the install +# into smaller packages. function(ly_install_target ly_install_target_NAME) + set(options) + set(oneValueArgs NAMESPACE COMPONENT) + set(multiValueArgs INCLUDE_DIRECTORIES BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES COMPILE_DEFINITIONS) + + cmake_parse_arguments(ly_install_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + # All include directories marked PUBLIC or INTERFACE will be installed set(include_location "include") get_target_property(include_directories ${ly_install_target_NAME} INTERFACE_INCLUDE_DIRECTORIES) @@ -36,18 +46,28 @@ function(ly_install_target ly_install_target_NAME) install( TARGETS ${ly_install_target_NAME} - LIBRARY DESTINATION lib/$ - ARCHIVE DESTINATION lib/$ - RUNTIME DESTINATION bin/$ - PUBLIC_HEADER DESTINATION ${include_location} + LIBRARY + DESTINATION lib/$ + COMPONENT ${ly_install_target_COMPONENT} + ARCHIVE + DESTINATION lib/$ + COMPONENT ${ly_install_target_COMPONENT} + RUNTIME + DESTINATION bin/$ + COMPONENT ${ly_install_target_COMPONENT} + PUBLIC_HEADER + DESTINATION ${include_location} + COMPONENT ${ly_install_target_COMPONENT} ) - + 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} + COMPONENT ${ly_install_target_COMPONENT} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Find${ly_install_target_NAME}.cmake" DESTINATION cmake + COMPONENT ${ly_install_target_COMPONENT} ) endfunction() @@ -64,7 +84,7 @@ endfunction() # \arg:RUNTIME_DEPENDENCIES list of dependencies this target depends on at runtime # \arg:COMPILE_DEFINITIONS list of compilation definitions this target will use to compile function(ly_generate_target_find_file) - + set(options) set(oneValueArgs NAME NAMESPACE) set(multiValueArgs INCLUDE_DIRECTORIES COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES) @@ -81,7 +101,7 @@ function(ly_generate_target_find_file) # 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}) + 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}") @@ -111,9 +131,9 @@ endfunction() # These per config files will be included by the target's find file to set the location of the binary/ # \arg:NAME name of the target function(ly_generate_target_config_file NAME) - + get_target_property(target_type ${NAME} TYPE) - + unset(target_file_contents) if(NOT target_type STREQUAL INTERFACE_LIBRARY) @@ -127,11 +147,11 @@ function(ly_generate_target_config_file NAME) set(out_dir lib) endif() - string(APPEND target_file_contents + string(APPEND target_file_contents "# Generated by O3DE install set(target_location \"\${LY_ROOT_FOLDER}/${out_dir}/$/$<${out_file_generator}:${NAME}>\") -set_target_properties(${NAME} +set_target_properties(${NAME} PROPERTIES $<$:IMPORTED_LOCATION \"\${target_location}>\" IMPORTED_LOCATION_$> \"\${target_location}\" @@ -172,7 +192,7 @@ endfunction() #! 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) - + ly_setup_cmake_install() ly_setup_target_generator() ly_setup_others() @@ -184,14 +204,16 @@ function(ly_setup_cmake_install) install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} REGEX "Findo3de.cmake" EXCLUDE REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE ) install( - FILES + FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt" "${CMAKE_SOURCE_DIR}/engine.json" DESTINATION . + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) # Collect all Find files that were added with ly_add_external_target_path @@ -204,6 +226,7 @@ function(ly_setup_cmake_install) endforeach() install(FILES ${additional_find_files} DESTINATION cmake/3rdParty + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) # Findo3de.cmake file: we generate a different Findo3de.camke file than the one we have in cmake. This one is going to expose all @@ -218,8 +241,9 @@ function(ly_setup_cmake_install) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/Findo3de.cmake" DESTINATION cmake + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) - + # 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 @@ -237,6 +261,7 @@ function(ly_setup_cmake_install) ) install(FILES "${pal_builtin_file}" DESTINATION cmake/3rdParty/Platform/${PAL_PLATFORM_NAME} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endfunction() @@ -247,20 +272,22 @@ 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) foreach(dir ${DIRECTORIES_TO_INSTALL}) - + get_filename_component(install_path ${dir} DIRECTORY) if (NOT install_path) set(install_path .) endif() - + install(DIRECTORY "${CMAKE_SOURCE_DIR}/${dir}" DESTINATION ${install_path} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endforeach() install(DIRECTORY "${CMAKE_SOURCE_DIR}/python" DESTINATION . + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} REGEX "downloaded_packages" EXCLUDE REGEX "runtime" EXCLUDE ) @@ -277,12 +304,15 @@ function(ly_setup_target_generator) ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/LauncherProject.cpp ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/StaticModules.in DESTINATION LauncherGenerator + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(DIRECTORY ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/Platform DESTINATION LauncherGenerator + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(FILES ${CMAKE_SOURCE_DIR}/Code/LauncherUnified/FindLauncherGenerator.cmake DESTINATION cmake + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endfunction() \ No newline at end of file From 11b2141a37431a82944fa13c929d9d759a3a9d9f Mon Sep 17 00:00:00 2001 From: scottr Date: Wed, 21 Apr 2021 16:36:22 -0700 Subject: [PATCH 09/15] [cpack_installer] added missing trailing newline to select modified files --- CMakeLists.txt | 2 +- cmake/CPack.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a164451466..ee63b27902 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,4 +128,4 @@ if(NOT INSTALLED_ENGINE) endif() # IMPORTANT: must be included last -include(cmake/CPack.cmake) \ No newline at end of file +include(cmake/CPack.cmake) diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake index a593382367..1145bb1987 100644 --- a/cmake/CPack.cmake +++ b/cmake/CPack.cmake @@ -94,4 +94,4 @@ ly_configure_cpack_component( ${LY_DEFAULT_INSTALL_COMPONENT} REQUIRED DISPLAY_NAME "O3DE Core" DESCRIPTION "O3DE Headers and Libraries" -) \ No newline at end of file +) From 6c1e617d49ddcb9ac4d082a6987cbcd132480e6d Mon Sep 17 00:00:00 2001 From: scottr Date: Wed, 21 Apr 2021 16:39:54 -0700 Subject: [PATCH 10/15] [cpack_installer] added another missing trailing newline to a modified file --- cmake/Platform/Common/Install_common.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index e94d8c1560..f1eb2e092c 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -315,4 +315,4 @@ function(ly_setup_target_generator) COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) -endfunction() \ No newline at end of file +endfunction() From 8c76e193e953318efc02a77e0b5e51193ed4aa85 Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 22 Apr 2021 08:22:29 -0700 Subject: [PATCH 11/15] [cpack_installer] removed INSTALL_COMPONENT as public argument from ly_add_target and cleaned up internal usage --- cmake/LYWrappers.cmake | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 87aa37abfa..a860bcfd20 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -74,12 +74,10 @@ define_property(TARGET PROPERTY GEM_MODULE # for the list of variables that will be used by the target # \arg:TARGET_PROPERTIES additional properties to set to the target # \arg:AUTOGEN_RULES a set of AutoGeneration rules to be passed to the AzAutoGen expansion system -# \arg:INSTALL_COMPONENT (optional) the grouping string of the target used for splitting up the install into smaller -# packages. If none is specified, LY_DEFAULT_INSTALL_COMPONENT will be used function(ly_add_target) set(options STATIC SHARED MODULE GEM_MODULE HEADERONLY EXECUTABLE APPLICATION UNKNOWN IMPORTED AUTOMOC AUTOUIC AUTORCC NO_UNITY) - set(oneValueArgs NAME NAMESPACE OUTPUT_SUBDIRECTORY OUTPUT_NAME INSTALL_COMPONENT) + set(oneValueArgs NAME NAMESPACE OUTPUT_SUBDIRECTORY OUTPUT_NAME) set(multiValueArgs FILES_CMAKE GENERATED_FILES INCLUDE_DIRECTORIES COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES PLATFORM_INCLUDE_FILES TARGET_PROPERTIES AUTOGEN_RULES) cmake_parse_arguments(ly_add_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -341,9 +339,7 @@ function(ly_add_target) if(NOT ly_add_target_IMPORTED) if(NOT ly_add_target_INSTALL_COMPONENT) - set(_component_id ${LY_DEFAULT_INSTALL_COMPONENT}) - else() - set(_component_id ${ly_add_target_INSTALL_COMPONENT}) + set(ly_add_target_INSTALL_COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT}) endif() ly_install_target( @@ -353,7 +349,7 @@ function(ly_add_target) BUILD_DEPENDENCIES ${ly_add_target_BUILD_DEPENDENCIES} RUNTIME_DEPENDENCIES ${ly_add_target_RUNTIME_DEPENDENCIES} COMPILE_DEFINITIONS ${ly_add_target_COMPILE_DEFINITIONS} - COMPONENT ${_component_id} + COMPONENT ${ly_add_target_INSTALL_COMPONENT} ) endif() From db7689bf49d8bad37f6ec34778f49b545b2c1d6e Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 22 Apr 2021 12:23:33 -0700 Subject: [PATCH 12/15] [cpack_installer] addressed feedback regarding install error checking and default property values for cpack --- cmake/CPack.cmake | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake index 1145bb1987..e16a0059ba 100644 --- a/cmake/CPack.cmake +++ b/cmake/CPack.cmake @@ -20,29 +20,35 @@ if(LY_QTIFW_PATH) elseif(DEFINED ENV{QTIFWDIR}) file(TO_CMAKE_PATH $ENV{QTIFWDIR} CPACK_IFW_ROOT) endif() -if(NOT EXISTS ${CPACK_IFW_ROOT}) - message(STATUS "WARN: A valid LY_QTIFW_PATH argument or QTIFWDIR environment variable is required to enable cpack support") + +if(CPACK_IFW_ROOT) + if(NOT EXISTS ${CPACK_IFW_ROOT}) + message(FATAL_ERROR "Invalid path supplied for LY_QTIFW_PATH argument or QTIFWDIR environment variable") + return() + endif() +else() return() endif() set(CPACK_GENERATOR "IFW") -set(CPACK_PACKAGE_VENDOR "O3DE") -set(CPACK_PACKAGE_VERSION "1.0.0") +set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}") +set(CPACK_PACKAGE_VERSION "${LY_VERSION_STRING}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool") -set(CPACK_PACKAGE_FILE_NAME "o3de_installer") +string(TOLOWER ${PROJECT_NAME} _project_name_lower) +set(CPACK_PACKAGE_FILE_NAME "${_project_name_lower}_installer") set(DEFAULT_LICENSE_NAME "Apache 2.0") set(DEFAULT_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE}) -set(CPACK_IFW_PACKAGE_TITLE "O3DE Installer") -set(CPACK_IFW_PACKAGE_PUBLISHER "O3DE") +set(CPACK_IFW_PACKAGE_TITLE "${PROJECT_NAME} Installer") +set(CPACK_IFW_PACKAGE_PUBLISHER "${PROJECT_NAME}") -set(CPACK_IFW_TARGET_DIRECTORY "@ApplicationsDir@/O3DE/${LY_VERSION_STRING}") -set(CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "O3DE") +set(CPACK_IFW_TARGET_DIRECTORY "@ApplicationsDir@/${PROJECT_NAME}/${LY_VERSION_STRING}") +set(CPACK_IFW_PACKAGE_START_MENU_DIRECTORY "${PROJECT_NAME}") # IMPORTANT: required to be included AFTER setting all property overrides include(CPack REQUIRED) @@ -72,7 +78,7 @@ function(ly_configure_cpack_component ly_configure_cpack_component_NAME) set(license_name ${ly_configure_cpack_component_LICENSE_NAME}) set(license_file ${ly_configure_cpack_component_LICENSE_FILE}) elseif(ly_configure_cpack_component_LICENSE_NAME OR ly_configure_cpack_component_LICENSE_FILE) - message(WARNING "Invalid argument configuration. Both LICENSE_NAME and LICENSE_FILE must be set for ly_configure_cpack_component") + message(FATAL_ERROR "Invalid argument configuration. Both LICENSE_NAME and LICENSE_FILE must be set for ly_configure_cpack_component") endif() cpack_add_component( @@ -92,6 +98,6 @@ endfunction() # configure ALL components here ly_configure_cpack_component( ${LY_DEFAULT_INSTALL_COMPONENT} REQUIRED - DISPLAY_NAME "O3DE Core" - DESCRIPTION "O3DE Headers and Libraries" + DISPLAY_NAME "${PROJECT_NAME} Core" + DESCRIPTION "${PROJECT_NAME} Headers, Libraries and Tools" ) From 5c354868ec485bacfe1606490f074c6580b3595a Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 22 Apr 2021 13:56:39 -0700 Subject: [PATCH 13/15] [cpack_installer] moved inclusion of CPack.cmake to be for engine local builds only --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee63b27902..3ddf32cb08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,7 @@ 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() -endif() -# IMPORTANT: must be included last -include(cmake/CPack.cmake) + # IMPORTANT: must be included last + include(cmake/CPack.cmake) +endif() From bb1a7580f5bfbffb94b8d6ab59075039cfea2cd0 Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 22 Apr 2021 16:37:15 -0700 Subject: [PATCH 14/15] [cpack_installer] missed some new install() entries after a merge that need component tagging --- cmake/Platform/Common/Install_common.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 2d4917c61e..3daddabaa6 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -296,15 +296,18 @@ function(ly_setup_others) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/$/Registry DESTINATION ./bin/$ + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(DIRECTORY # This one will change soon, Engine/Registry files will be relocated to Registry ${CMAKE_SOURCE_DIR}/Engine/Registry DESTINATION ./Engine + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) install(FILES ${CMAKE_SOURCE_DIR}/AssetProcessorPlatformConfig.setreg DESTINATION ./Registry + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) # Qt Binaries @@ -313,6 +316,7 @@ function(ly_setup_others) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/$/${qt_dir} DESTINATION ./bin/$ + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endforeach() @@ -320,6 +324,7 @@ function(ly_setup_others) install(DIRECTORY ${CMAKE_SOURCE_DIR}/Templates DESTINATION . + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) # Misc @@ -328,6 +333,7 @@ function(ly_setup_others) ${CMAKE_SOURCE_DIR}/LICENSE.txt ${CMAKE_SOURCE_DIR}/README.md DESTINATION . + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endfunction() From df251de400bf3d55c4a954cc96695716150bd023 Mon Sep 17 00:00:00 2001 From: scottr Date: Thu, 22 Apr 2021 17:51:41 -0700 Subject: [PATCH 15/15] [cpack_installer] few small fixes based on feedback --- cmake/CPack.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CPack.cmake b/cmake/CPack.cmake index e16a0059ba..687021587b 100644 --- a/cmake/CPack.cmake +++ b/cmake/CPack.cmake @@ -24,9 +24,9 @@ endif() if(CPACK_IFW_ROOT) if(NOT EXISTS ${CPACK_IFW_ROOT}) message(FATAL_ERROR "Invalid path supplied for LY_QTIFW_PATH argument or QTIFWDIR environment variable") - return() endif() else() + # early out as no path to QtIFW has been supplied effectively disabling support return() endif() @@ -39,7 +39,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool") string(TOLOWER ${PROJECT_NAME} _project_name_lower) set(CPACK_PACKAGE_FILE_NAME "${_project_name_lower}_installer") -set(DEFAULT_LICENSE_NAME "Apache 2.0") +set(DEFAULT_LICENSE_NAME "Apache-2.0") set(DEFAULT_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE})