From 9f6434fc681e6dec623237b8935aa824aae8a5e0 Mon Sep 17 00:00:00 2001 From: amzn-phist <52085794+amzn-phist@users.noreply.github.com> Date: Wed, 25 Aug 2021 14:16:40 -0500 Subject: [PATCH] Fix an issue with project-centric ninja builds [Linux] (#3429) * Fix an issue with project-centric ninja builds Normalizes relative paths when adding engine.json as a cmake configure dependency. It should match the dependency added later which uses absolute path. Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> * Fix typo Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com> --- cmake/Findo3de.cmake | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmake/Findo3de.cmake b/cmake/Findo3de.cmake index b0d30f1dcc..26b3719d14 100644 --- a/cmake/Findo3de.cmake +++ b/cmake/Findo3de.cmake @@ -17,23 +17,27 @@ endfunction() o3de_current_file_path(current_path) -# Make sure we are matching LY_ENGINE_NAME_TO_USE with the current engine -file(READ ${current_path}/../engine.json engine_json) -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${current_path}/../engine.json) +# Make sure the cmake configure dependency added here is a normalized path to engine.json, +# because later it's read again using a path like ${LY_ROOT_FOLDER}/engine.json, which +# is also normalized. They should match to avoid errors on some build systems. +cmake_path(SET engine_json_path NORMALIZE ${current_path}/../engine.json) +file(READ ${engine_json_path} engine_json) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${engine_json_path}) string(JSON this_engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name) if(json_error) - message(FATAL_ERROR "Unable to read key 'engine_name' from '${current_path}/../engine.json', error: ${json_error}") + message(FATAL_ERROR "Unable to read key 'engine_name' from '${engine_json_path}', error: ${json_error}") endif() +# Make sure we are matching LY_ENGINE_NAME_TO_USE with the current engine set(found_matching_engine FALSE) if(this_engine_name STREQUAL LY_ENGINE_NAME_TO_USE) set(found_matching_engine TRUE) endif() find_package_handle_standard_args(o3de - "Could not find an engine with matching ${LY_ENGINE_NAME_TO_USE}" - found_matching_engine + "Could not find an engine with matching ${LY_ENGINE_NAME_TO_USE}" + found_matching_engine ) macro(o3de_initialize) @@ -41,4 +45,4 @@ macro(o3de_initialize) set(LY_PROJECTS ${CMAKE_CURRENT_LIST_DIR}) o3de_current_file_path(current_path) add_subdirectory(${current_path}/.. o3de) -endmacro() \ No newline at end of file +endmacro()