Skip to content

Commit 456fbe1

Browse files
authored
Refactored the project external subdirectory visit workflow (o3de#8388)
* Refactored the project external subdirectory visit workflow The order in which directories are visited when configuring a project is now as follows 1. Engine Code directories 1. User supplied LY_EXTERNAL_SUBDIRS via the CMake Cache Variable. 1. Engine Gem directories("external_subdirectories") 1. Engine references to registered gems("gem_names") 1. Project references to registered gems("gem_names") 1. The Project root directory 1. The Project Gem directories("external_subdirectories") This change allows projects to use cmake functionality exposed by gem's CMake files. resolves o3de#8376 Signed-off-by: lumberyard-employee-dm <[email protected]> * Removed circular dependencies from the Atom set of gems gem.json files. Signed-off-by: lumberyard-employee-dm <[email protected]> * Added support to the External Subdirectory visit logic to reorder gems Any gems that are listed in the "Dependencies" section of the gem.json file are now visited before that gem. Signed-off-by: lumberyard-employee-dm <[email protected]> * Remove unnecessary warning in launcher_generator.cmake The "project_name" field in the project.json has already been read in Projects.cmake Signed-off-by: lumberyard-employee-dm <[email protected]>
1 parent 92e701c commit 456fbe1

File tree

25 files changed

+277
-203
lines changed

25 files changed

+277
-203
lines changed

CMakeLists.txt

+7-8
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,13 @@ add_o3de_manifest_json_external_subdirectories()
5353
# Add the projects first so the Launcher can find them
5454
include(cmake/Projects.cmake)
5555

56-
if(LY_EXTERNAL_SUBDIRS)
57-
set_property(GLOBAL APPEND PROPERTY LY_EXTERNAL_SUBDIRS ${LY_EXTERNAL_SUBDIRS})
58-
endif()
5956

6057
if(NOT INSTALLED_ENGINE)
61-
# Add external subdirectories listed in the engine.json. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
62-
# external subdirectories. This should go before adding the rest of the targets so the targets are available to the launcher.
58+
# Add external subdirectories listed in the engine.json.
59+
# LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra
60+
# external subdirectories.
6361
add_engine_json_external_subdirectories()
6462

65-
# Invoke add_subdirectory on external subdirectories that should be used a this point
66-
add_subdirectory_on_external_subdirs()
67-
6863
# Add the rest of the targets
6964
add_subdirectory(Assets)
7065
add_subdirectory(Code)
@@ -74,6 +69,10 @@ if(NOT INSTALLED_ENGINE)
7469
add_subdirectory(Templates)
7570
add_subdirectory(Tools)
7671

72+
# Invoke add_subdirectory on all external subdirectories
73+
# that is in use by the union of projects specified by path in LY_PROJECTS
74+
add_subdirectory_on_external_subdirs()
75+
7776
else()
7877
ly_find_o3de_packages()
7978
add_subdirectory_on_external_subdirs()

Code/LauncherUnified/launcher_generator.cmake

+45-58
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@ set_property(GLOBAL PROPERTY LAUNCHER_UNIFIED_BINARY_DIR ${CMAKE_CURRENT_BINARY_
1111
# Launcher targets for a project need to be generated when configuring a project.
1212
# When building the engine source, this file will be included by LauncherUnified's CMakeLists.txt
1313
# When using an installed engine, this file will be included by the FindLauncherGenerator.cmake script
14-
get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME)
15-
foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJECTS)
14+
get_property(O3DE_PROJECTS_NAME GLOBAL PROPERTY O3DE_PROJECTS_NAME)
15+
foreach(project_name project_path IN ZIP_LISTS O3DE_PROJECTS_NAME LY_PROJECTS)
1616

1717
# Computes the realpath to the project
1818
# If the project_path is relative, it is evaluated relative to the ${LY_ROOT_FOLDER}
1919
# Otherwise the the absolute project_path is returned with symlinks resolved
2020
file(REAL_PATH ${project_path} project_real_path BASE_DIRECTORY ${LY_ROOT_FOLDER})
21-
if(NOT project_name)
22-
o3de_read_json_key(project_name ${project_real_path}/project.json "project_name")
23-
message(WARNING "The project located at path ${project_real_path} has a valid \"project name\" of '${project_name}' read from it's project.json file."
24-
" This indicates that the ${project_real_path}/CMakeLists.txt is not properly appending the \"project name\" "
25-
"to the LY_PROJECTS_TARGET_NAME global property. Other configuration errors might occur")
26-
endif()
2721

2822
################################################################################
2923
# Assets
@@ -143,63 +137,56 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC
143137
# Server
144138
################################################################################
145139
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
140+
ly_add_target(
141+
NAME ${project_name}.ServerLauncher APPLICATION
142+
NAMESPACE AZ
143+
FILES_CMAKE
144+
${CMAKE_CURRENT_LIST_DIR}/launcher_project_files.cmake
145+
PLATFORM_INCLUDE_FILES
146+
${pal_dir}/launcher_project_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
147+
COMPILE_DEFINITIONS
148+
PRIVATE
149+
# Adds the name of the project/game
150+
LY_PROJECT_NAME="${project_name}"
151+
# Adds the ${project_name}_ServerLauncher target as a define so for the Settings Registry to use
152+
# when loading .setreg file specializations
153+
# This is needed so that only gems for the project server launcher are loaded
154+
LY_CMAKE_TARGET="${project_name}_ServerLauncher"
155+
INCLUDE_DIRECTORIES
156+
PRIVATE
157+
.
158+
${CMAKE_CURRENT_BINARY_DIR}/${project_name}.ServerLauncher/Includes # required for StaticModules.inl
159+
BUILD_DEPENDENCIES
160+
PRIVATE
161+
AZ::Launcher.Static
162+
AZ::Launcher.Server.Static
163+
${server_build_dependencies}
164+
RUNTIME_DEPENDENCIES
165+
${server_runtime_dependencies}
166+
)
167+
# Needs to be set manually after ly_add_target to prevent the default location overriding it
168+
set_target_properties(${project_name}.ServerLauncher
169+
PROPERTIES
170+
FOLDER ${project_name}
171+
LY_PROJECT_NAME ${project_name}
172+
)
146173

147-
get_property(server_projects GLOBAL PROPERTY LY_LAUNCHER_SERVER_PROJECTS)
148-
if(${project_name} IN_LIST server_projects)
149-
150-
ly_add_target(
151-
NAME ${project_name}.ServerLauncher APPLICATION
152-
NAMESPACE AZ
153-
FILES_CMAKE
154-
${CMAKE_CURRENT_LIST_DIR}/launcher_project_files.cmake
155-
PLATFORM_INCLUDE_FILES
156-
${pal_dir}/launcher_project_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
157-
COMPILE_DEFINITIONS
158-
PRIVATE
159-
# Adds the name of the project/game
160-
LY_PROJECT_NAME="${project_name}"
161-
# Adds the ${project_name}_ServerLauncher target as a define so for the Settings Registry to use
162-
# when loading .setreg file specializations
163-
# This is needed so that only gems for the project server launcher are loaded
164-
LY_CMAKE_TARGET="${project_name}_ServerLauncher"
165-
INCLUDE_DIRECTORIES
166-
PRIVATE
167-
.
168-
${CMAKE_CURRENT_BINARY_DIR}/${project_name}.ServerLauncher/Includes # required for StaticModules.inl
169-
BUILD_DEPENDENCIES
170-
PRIVATE
171-
AZ::Launcher.Static
172-
AZ::Launcher.Server.Static
173-
${server_build_dependencies}
174-
RUNTIME_DEPENDENCIES
175-
${server_runtime_dependencies}
176-
)
177-
# Needs to be set manually after ly_add_target to prevent the default location overriding it
178-
set_target_properties(${project_name}.ServerLauncher
179-
PROPERTIES
180-
FOLDER ${project_name}
181-
LY_PROJECT_NAME ${project_name}
182-
)
183-
184-
if(LY_DEFAULT_PROJECT_PATH)
185-
if (TARGET ${project_name})
186-
get_target_property(project_server_launcher_additional_args ${project_name} SERVERLAUNCHER_ADDITIONAL_VS_DEBUGGER_COMMAND_ARGUMENTS)
187-
if (project_server_launcher_additional_args)
188-
# Avoid pushing param-NOTFOUND into the argument in case this property wasn't found
189-
set(additional_server_vs_debugger_args "${project_server_launcher_additional_args}")
190-
endif()
174+
if(LY_DEFAULT_PROJECT_PATH)
175+
if (TARGET ${project_name})
176+
get_target_property(project_server_launcher_additional_args ${project_name} SERVERLAUNCHER_ADDITIONAL_VS_DEBUGGER_COMMAND_ARGUMENTS)
177+
if (project_server_launcher_additional_args)
178+
# Avoid pushing param-NOTFOUND into the argument in case this property wasn't found
179+
set(additional_server_vs_debugger_args "${project_server_launcher_additional_args}")
191180
endif()
192-
193-
set_property(TARGET ${project_name}.ServerLauncher APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS
194-
"--project-path=\"${LY_DEFAULT_PROJECT_PATH}\" ${additional_server_vs_debugger_args}")
195181
endif()
196182

197-
# Associate the Servers Gem Variant with each projects ServerLauncher
198-
ly_set_gem_variant_to_load(TARGETS ${project_name}.ServerLauncher VARIANTS Servers)
183+
set_property(TARGET ${project_name}.ServerLauncher APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS
184+
"--project-path=\"${LY_DEFAULT_PROJECT_PATH}\" ${additional_server_vs_debugger_args}")
199185
endif()
200186

187+
# Associate the Servers Gem Variant with each projects ServerLauncher
188+
ly_set_gem_variant_to_load(TARGETS ${project_name}.ServerLauncher VARIANTS Servers)
201189
endif()
202-
203190
endforeach()
204191

205192
#! Defer generation of the StaticModules.inl file needed in monolithic builds until after all the CMake targets are known

Gems/Atom/Asset/ImageProcessingAtom/gem.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"documentation_url": "",
1616
"dependencies": [
1717
"Atom_RPI",
18-
"Atom_RHI",
19-
"Atom"
18+
"Atom_RHI"
2019
]
2120
}

Gems/Atom/Feature/Common/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"documentation_url": "",
1616
"dependencies": [
1717
"Atom_RPI",
18-
"Atom",
1918
"ImGui",
2019
"Atom_RHI"
2120
]

Gems/Atom/RHI/DX12/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
"requirements": "",
1515
"documentation_url": "",
1616
"dependencies": [
17-
"Atom_RHI"
1817
]
1918
}

Gems/Atom/RHI/Metal/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
"requirements": "",
1515
"documentation_url": "",
1616
"dependencies": [
17-
"Atom_RHI"
1817
]
1918
}

Gems/Atom/RHI/Null/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
"requirements": "",
1515
"documentation_url": "",
1616
"dependencies": [
17-
"Atom_RHI"
1817
]
1918
}

Gems/Atom/RHI/Vulkan/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
"requirements": "",
1515
"documentation_url": "",
1616
"dependencies": [
17-
"Atom_RHI"
1817
]
1918
}

Gems/Atom/RHI/gem.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
"Atom_RHI_DX12",
2323
"Atom_RHI_Metal",
2424
"Atom_RHI_Vulkan",
25-
"Atom_RHI_Salem",
26-
"Atom_RHI_Null",
27-
"Atom_Feature_Common"
25+
"Atom_RHI_Null"
2826
]
2927
}

Gems/AtomLyIntegration/AtomBridge/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"ImguiAtom",
2727
"AtomFont",
2828
"AtomViewportDisplayInfo",
29-
"Atom",
3029
"AtomShader",
3130
"ImageProcessingAtom",
3231
"AtomToolsFramework",

Gems/AtomLyIntegration/AtomFont/gem.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"documentation_url": "",
1616
"dependencies": [
1717
"Atom_RHI",
18-
"Atom_RPI",
19-
"Atom_AtomBridge"
18+
"Atom_RPI"
2019
]
2120
}

Gems/AtomLyIntegration/AtomImGuiTools/gem.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"requirements": "",
1818
"documentation_url": "",
1919
"dependencies": [
20-
"ImguiAtom",
21-
"Atom"
20+
"ImguiAtom"
2221
]
2322
}

Gems/AtomLyIntegration/AtomViewportDisplayIcons/gem.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"dependencies": [
1717
"Atom_RHI",
1818
"Atom_RPI",
19-
"Atom_Bootstrap",
20-
"Atom_AtomBridge"
19+
"Atom_Bootstrap"
2120
]
2221
}

Gems/AtomLyIntegration/EMotionFXAtom/gem.json

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"documentation_url": "",
1616
"dependencies": [
1717
"EMotionFX",
18-
"Atom",
1918
"Atom_Feature_Common",
2019
"Atom_RPI",
2120
"Atom_RHI",

Templates/DefaultProject/Template/CMakeLists.txt

-11
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,4 @@ if(NOT PROJECT_NAME)
1818
include(cmake/EngineFinder.cmake OPTIONAL)
1919
find_package(o3de REQUIRED)
2020
o3de_initialize()
21-
else()
22-
# Add the project_name to global LY_PROJECTS_TARGET_NAME property
23-
file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json)
24-
25-
string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name")
26-
if(json_error)
27-
message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'")
28-
endif()
29-
30-
set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name})
31-
3221
endif()

Templates/DefaultProject/Template/Gem/CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,3 @@ ly_create_alias(NAME ${Name}.Servers NAMESPACE Gem TARGETS Gem::${Name})
7474

7575
# Enable the specified list of gems from GEM_FILE or GEMS list for this specific project:
7676
ly_enable_gems(PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake)
77-
78-
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
79-
# this property causes it to actually make a ServerLauncher.
80-
# if you don't want a Server application, you can remove this and the
81-
# following ly_enable_gems lines.
82-
set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS ${Name})
83-
endif()

Templates/MinimalProject/Template/CMakeLists.txt

-11
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,4 @@ if(NOT PROJECT_NAME)
1818
include(cmake/EngineFinder.cmake OPTIONAL)
1919
find_package(o3de REQUIRED)
2020
o3de_initialize()
21-
else()
22-
# Add the project_name to global LY_PROJECTS_TARGET_NAME property
23-
file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json)
24-
25-
string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name")
26-
if(json_error)
27-
message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'")
28-
endif()
29-
30-
set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name})
31-
3221
endif()

Templates/MinimalProject/Template/Gem/CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,3 @@ ly_create_alias(NAME ${Name}.Servers NAMESPACE Gem TARGETS Gem::${Name})
7474

7575
# Enable the specified list of gems from GEM_FILE or GEMS list for this specific project:
7676
ly_enable_gems(PROJECT_NAME ${Name} GEM_FILE enabled_gems.cmake)
77-
78-
79-
if(PAL_TRAIT_BUILD_SERVER_SUPPORTED)
80-
# this property causes it to actually make a ServerLauncher.
81-
# if you don't want a Server application, you can remove this and the
82-
# following ly_enable_gems lines.
83-
set_property(GLOBAL APPEND PROPERTY LY_LAUNCHER_SERVER_PROJECTS ${Name})
84-
endif()

Tools/LyTestTools/tests/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ ly_add_pytest(
1616
COMPONENT TestTools
1717
)
1818

19-
get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME)
20-
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS_TARGET_NAME)
19+
get_property(O3DE_PROJECTS_NAME GLOBAL PROPERTY O3DE_PROJECTS_NAME)
20+
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST O3DE_PROJECTS_NAME)
2121
# Integration tests.
2222

2323
ly_add_pytest(

Tools/RemoteConsole/ly_remote_console/tests/CMakeLists.txt

+1-17
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,4 @@
1212
ly_add_pytest(
1313
NAME RemoteConsole_UnitTests_main_no_gpu
1414
PATH ${CMAKE_CURRENT_LIST_DIR}/unit/
15-
)
16-
17-
get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME)
18-
if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS_TARGET_NAME)
19-
# Integration tests.
20-
# ly_add_pytest(
21-
# NAME RemoteConsole_IntegTests_periodic_no_gpu
22-
# PATH ${CMAKE_CURRENT_LIST_DIR}/integ/test_remote_console.py
23-
# TEST_SERIAL
24-
# TEST_SUITE periodic
25-
# RUNTIME_DEPENDENCIES
26-
# Legacy::Editor
27-
# AssetProcessor
28-
# AutomatedTesting.GameLauncher
29-
# AutomatedTesting.Assets
30-
# )
31-
endif()
15+
)

cmake/FileUtil.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ endfunction()
112112
# the cmake project generation. This will provide a bridge to non-cmake tools to read the platform-specific cmake
113113
# project generation settings.
114114
#
115-
get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME)
115+
get_property(O3DE_PROJECTS_NAME GLOBAL PROPERTY O3DE_PROJECTS_NAME)
116116
function(ly_update_platform_settings)
117117
# Update the <platform>.last file to keep track of the recent build_dir
118118
set(ly_platform_last_path "${CMAKE_BINARY_DIR}/platform.settings")
@@ -122,7 +122,7 @@ function(ly_update_platform_settings)
122122
123123
[settings]
124124
platform=${PAL_PLATFORM_NAME}
125-
game_projects=${LY_PROJECTS_TARGET_NAME}
125+
game_projects=${O3DE_PROJECTS_NAME}
126126
asset_deploy_mode=${LY_ASSET_DEPLOY_MODE}
127127
asset_deploy_type=${LY_ASSET_DEPLOY_ASSET_TYPE}
128128
override_pak_root=${LY_ASSET_OVERRIDE_PAK_FOLDER_ROOT}

0 commit comments

Comments
 (0)