From ea7b8309b513b3f64fbf8f8e5185beefb242a30f Mon Sep 17 00:00:00 2001 From: mcgarrah Date: Tue, 13 Apr 2021 00:43:33 -0500 Subject: [PATCH 1/4] Updating the FOLDER filtering in the LyTestWrappers.cmake custom targets to remove leading '..' from the VS folder filter --- cmake/LYTestWrappers.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/LYTestWrappers.cmake b/cmake/LYTestWrappers.cmake index 4f8d0bc169..73a212ee0b 100644 --- a/cmake/LYTestWrappers.cmake +++ b/cmake/LYTestWrappers.cmake @@ -213,8 +213,14 @@ function(ly_add_test) add_custom_target(${unaliased_test_name} COMMAND ${CMAKE_COMMAND} -E true ${args_TEST_COMMAND} ${args_TEST_ARGUMENTS}) file(RELATIVE_PATH project_path ${LY_ROOT_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}) + set(ide_path ${project_path}) + # Visual Studio doesn't support a folder layout that starts with ".." + # So strip away the parent directory of a relative path + if (${project_path} MATCHES [[^(\.\./)+(.*)]]) + set(ide_path "${CMAKE_MATCH_2}") + endif() set_target_properties(${unaliased_test_name} PROPERTIES - FOLDER "${project_path}" + FOLDER "${ide_path}" VS_DEBUGGER_COMMAND ${test_command} VS_DEBUGGER_COMMAND_ARGUMENTS "${test_arguments_line}" ) From fa9366b81017a29f92ba1cd3ad158eccd3118ade Mon Sep 17 00:00:00 2001 From: mcgarrah Date: Tue, 13 Apr 2021 19:35:59 -0500 Subject: [PATCH 2/4] Updating the AutomatedTesting project to support being built as an External Project --- AutomatedTesting/CMakeLists.txt | 40 +++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/AutomatedTesting/CMakeLists.txt b/AutomatedTesting/CMakeLists.txt index b2d9a18c6a..289d0a6565 100644 --- a/AutomatedTesting/CMakeLists.txt +++ b/AutomatedTesting/CMakeLists.txt @@ -9,12 +9,38 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json) +#! Adds the --project-path argument to the VS IDE debugger command arguments +function(add_vs_debugger_arguments) + # Inject the project root into the --project-path argument into the Visual Studio Debugger arguments by defaults + list(APPEND app_targets AutomatedTesting.GameLauncher AutomatedTesting.ServerLauncher) + list(APPEND app_targets AssetBuilder AssetProcessor AssetProcessorBatch Editor) + foreach(app_target IN LISTS app_targets) + if (TARGET ${app_target}) + set_property(TARGET ${app_target} APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${CMAKE_CURRENT_LIST_DIR}\"") + endif() + endforeach() +endfunction() -string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name") -if(${json_error}) - message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'") -endif() +if(NOT PROJECT_NAME) + cmake_minimum_required(VERSION 3.19) + project(AutomatedTesting + LANGUAGES C CXX + VERSION 1.0.0.0 + ) + include(EngineFinder.cmake OPTIONAL) + find_package(o3de REQUIRED) + o3de_initialize() + add_vs_debugger_arguments() +else() + # Add the project_name to global LY_PROJECTS_TARGET_NAME property + file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json) -set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name}) -add_subdirectory(Gem) + string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name") + if(json_error) + message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'") + endif() + + set_property(GLOBAL APPEND PROPERTY LY_PROJECTS_TARGET_NAME ${project_target_name}) + + add_subdirectory(Gem) +endif() \ No newline at end of file From 92b8e590ce850090f197b18b328a23ab68a3e60b Mon Sep 17 00:00:00 2001 From: mcgarrah Date: Tue, 13 Apr 2021 19:42:30 -0500 Subject: [PATCH 3/4] Added better error message around when the Unified Launcher target for a Project cannot be configured due to issues querying the project name from the provided project path --- Code/LauncherUnified/CMakeLists.txt | 15 +++++++++++++++ Templates/DefaultProject/Template/CMakeLists.txt | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Code/LauncherUnified/CMakeLists.txt b/Code/LauncherUnified/CMakeLists.txt index 0d056686b8..2cd53bdb41 100644 --- a/Code/LauncherUnified/CMakeLists.txt +++ b/Code/LauncherUnified/CMakeLists.txt @@ -73,6 +73,21 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC # If the project_path is relative, it is evaluated relative to the ${LY_ROOT_FOLDER} # Otherwise the the absolute project_path is returned with symlinks resolved file(REAL_PATH ${project_path} project_real_path BASE_DIRECTORY ${LY_ROOT_FOLDER}) + if(NOT project_name) + if(NOT EXISTS ${project_real_path}/project.json) + message(FATAL_ERROR "The specified project path of ${project_real_path} does not contain a project.json file with a \"project name\" entry in it") + else() + # Add the project_name to global LY_PROJECTS_TARGET_NAME property + file(READ "${project_real_path}/project.json" project_json) + string(JSON project_name ERROR_VARIABLE json_error GET ${project_json} "project_name") + if(json_error) + message(FATAL_ERROR "There is an error reading the \"project_name\" key from the '${project_real_path}/project.json' file: ${json_error}") + endif() + 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." + " This indicates that the ${project_real_path}/CMakeLists.txt is not properly appending the \"project name\" " + "to the LY_PROJECTS_TARGET_NAME global property. Other configuration errors might occur") + endif() + endif() ################################################################################ # Monolithic game ################################################################################ diff --git a/Templates/DefaultProject/Template/CMakeLists.txt b/Templates/DefaultProject/Template/CMakeLists.txt index 24b229d05b..c314f0da5c 100644 --- a/Templates/DefaultProject/Template/CMakeLists.txt +++ b/Templates/DefaultProject/Template/CMakeLists.txt @@ -38,7 +38,7 @@ else() file(READ "${CMAKE_CURRENT_LIST_DIR}/project.json" project_json) string(JSON project_target_name ERROR_VARIABLE json_error GET ${project_json} "project_name") - if(${json_error}) + if(json_error) message(FATAL_ERROR "Unable to read key 'project_name' from 'project.json'") endif() From 957945f8093c0fbc9ced20e5bebec14e2d03ee38 Mon Sep 17 00:00:00 2001 From: mcgarrah Date: Tue, 13 Apr 2021 19:50:06 -0500 Subject: [PATCH 4/4] Clarified the error message that is output when the project.json is not found --- Code/LauncherUnified/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/LauncherUnified/CMakeLists.txt b/Code/LauncherUnified/CMakeLists.txt index 2cd53bdb41..f0eb361f42 100644 --- a/Code/LauncherUnified/CMakeLists.txt +++ b/Code/LauncherUnified/CMakeLists.txt @@ -75,7 +75,7 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC file(REAL_PATH ${project_path} project_real_path BASE_DIRECTORY ${LY_ROOT_FOLDER}) if(NOT project_name) if(NOT EXISTS ${project_real_path}/project.json) - message(FATAL_ERROR "The specified project path of ${project_real_path} does not contain a project.json file with a \"project name\" entry in it") + message(FATAL_ERROR "The specified project path of ${project_real_path} does not contain a project.json file") else() # Add the project_name to global LY_PROJECTS_TARGET_NAME property file(READ "${project_real_path}/project.json" project_json)