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