diff --git a/cmake/ConfigurationTypes.cmake b/cmake/ConfigurationTypes.cmake new file mode 100644 index 0000000000..fe9c2daa51 --- /dev/null +++ b/cmake/ConfigurationTypes.cmake @@ -0,0 +1,14 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +include_guard(GLOBAL) + +# By default, CMAKE_CONFIGURATION_TYPES = LY_CONFIGURATION_TYPES, but in installed SDKs, this +# file will be replaced with cmake/install/ConfigurationTypes.cmake and discover configurations +# that are available from the SDK +set(CMAKE_CONFIGURATION_TYPES ${LY_CONFIGURATION_TYPES} CACHE STRING "" FORCE) diff --git a/cmake/Configurations.cmake b/cmake/Configurations.cmake index 693cc23c7d..51dee2f07b 100644 --- a/cmake/Configurations.cmake +++ b/cmake/Configurations.cmake @@ -8,6 +8,17 @@ include_guard(GLOBAL) +# LY_CONFIGURATION_TYPES defines all the configuration types that O3DE supports +# We dont set CMAKE_CONFIGURATION_TYPES directly because we want to be able to configure which +# configuration types are supported in an SDK installation. SDK installations will fill a +# CMAKE_CONFIGURATION_TYPES based on the configurations that were generated during the install process. +# ly_append_configurations_options depends on LY_CONFIGURATION_TYPES being +# set in order to successfully parse the arguments. Even for non-multi-config +# generators, it needs to be set. +set(LY_CONFIGURATION_TYPES "debug;profile;release" CACHE STRING "" FORCE) + +include(cmake/ConfigurationTypes.cmake) + #! ly_append_configurations_options: adds options to the different configurations (debug, profile, release, etc) # # \arg:DEFINES @@ -43,7 +54,9 @@ function(ly_append_configurations_options) ) foreach(arg IN LISTS multiArgs) list(APPEND multiValueArgs ${arg}) - foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + # we parse the parameters based on all configuration types so unknown configurations + # are not passed as values to other parameters + foreach(conf IN LISTS LY_CONFIGURATION_TYPES) string(TOUPPER ${conf} UCONF) list(APPEND multiValueArgs ${arg}_${UCONF}) endforeach() @@ -96,6 +109,7 @@ function(ly_append_configurations_options) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINK_STR}" PARENT_SCOPE) endif() + # We only iterate for the actual configuration types foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER ${conf} UCONF) @@ -143,11 +157,6 @@ endfunction() set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ Standard to target") ly_set(CMAKE_CXX_STANDARD_REQUIRED ON) -# ly_append_configurations_options depends on CMAKE_CONFIGURATION_TYPES being -# set in order to successfully parse the arguments. Even for non-multi-config -# generators, it needs to be set. -set(CMAKE_CONFIGURATION_TYPES "debug;profile;release" CACHE STRING "" FORCE) - get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(NOT _isMultiConfig) # No reason set CMAKE_BUILD_TYPE if it's a multiconfig generator. diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 9a0fbbd872..86f46a6e0b 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -350,8 +350,26 @@ function(ly_setup_cmake_install) DESTINATION . COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} PATTERN "__pycache__" EXCLUDE - REGEX "Findo3de.cmake" EXCLUDE - REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE + PATTERN "Findo3de.cmake" EXCLUDE + PATTERN "ConfigurationTypes.cmake" EXCLUDE + REGEX "3rdParty/Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE + ) + # Connect configuration types + install(FILES "${LY_ROOT_FOLDER}/cmake/install/ConfigurationTypes.cmake" + DESTINATION cmake + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} + ) + # Inject code that will generate each ConfigurationType_.cmake file + set(install_configuration_type_template [=[ + configure_file(@LY_ROOT_FOLDER@/cmake/install/ConfigurationType_config.cmake.in + ${CMAKE_INSTALL_PREFIX}/cmake/ConfigurationTypes_${CMAKE_INSTALL_CONFIG_NAME}.cmake + @ONLY + ) + message(STATUS "Generated ${CMAKE_INSTALL_PREFIX}/cmake/ConfigurationTypes_${CMAKE_INSTALL_CONFIG_NAME}.cmake") + ]=]) + string(CONFIGURE "${install_configuration_type_template}" install_configuration_type @ONLY) + install(CODE "${install_configuration_type}" + COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME} ) # Transform the LY_EXTERNAL_SUBDIRS list into a json array diff --git a/cmake/install/ConfigurationType_config.cmake.in b/cmake/install/ConfigurationType_config.cmake.in new file mode 100644 index 0000000000..074e034899 --- /dev/null +++ b/cmake/install/ConfigurationType_config.cmake.in @@ -0,0 +1,11 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +include_guard(GLOBAL) + +list(APPEND CMAKE_CONFIGURATION_TYPES @CMAKE_INSTALL_CONFIG_NAME@) diff --git a/cmake/install/ConfigurationTypes.cmake b/cmake/install/ConfigurationTypes.cmake new file mode 100644 index 0000000000..709f3e71ab --- /dev/null +++ b/cmake/install/ConfigurationTypes.cmake @@ -0,0 +1,22 @@ +# +# Copyright (c) Contributors to the Open 3D Engine Project. +# For complete copyright and license terms please see the LICENSE at the root of this distribution. +# +# SPDX-License-Identifier: Apache-2.0 OR MIT +# +# + +include_guard(GLOBAL) + + +# In SDK builds CMAKE_CONFIGURATION_TYPES will be filled by entries generated per configuration build. +# At install time we generate `cmake/ConfigurationTypes_.cmake` files that append the configuration +# to CMAKE_CONFIGURATION_TYPES +set(CMAKE_CONFIGURATION_TYPES "" CACHE STRING "" FORCE) + +# For the SDK case, we want to only define the confiuguration types that have been added to the SDK +file(GLOB configuration_type_files "cmake/ConfigurationTypes_*.cmake") +foreach(configuration_type_file ${configuration_type_files}) + include(${configuration_type_file}) +endforeach() +ly_set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES}) # propagate to parent \ No newline at end of file