From 7d891edb9a934c18483866527764b54443a69a5d Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Wed, 23 Jun 2021 19:45:32 -0700 Subject: [PATCH] LYN-4780 CMake generation fails on a prebuilt (SDK) engine (#1541) * fix for some install generation issues around ly_enable_gems * setting the right SettingsRegistry path for imported targets * missing "include" in the exported target * Fixed issue with the GEM_FILE argument being specified in replicated ly_enable_gems call If the original call to `ly_enable_gems` supplied an argument for GEM_FILE, then in the replicated `ly_enable_gems` call in the install layout CMakeLists.txt, supplied both the GEMS and GEM_FILE argument which are mutually exclusive, due to the `ly_enable_gems` function populating the `ly_enable_gems_GEMS` variable from the content of the `ly_enable_gems_GEM_FILE` file. Furthermore the install layout does not copy over the file that was parsed by the GEM_FILE argument, so it would point to a non-existent file the install layout. * Fixed comment Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- cmake/Gems.cmake | 10 ++++++++-- cmake/Platform/Common/Install_common.cmake | 18 ++++-------------- cmake/SettingsRegistry.cmake | 9 ++++++++- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/cmake/Gems.cmake b/cmake/Gems.cmake index 0665152793..94928fdd40 100644 --- a/cmake/Gems.cmake +++ b/cmake/Gems.cmake @@ -155,7 +155,13 @@ function(ly_enable_gems) # This will be used to re-create the ly_enable_gems call in the generated CMakeLists.txt at the INSTALL step # Replace the CMake list separator with a space to replicate the space separated TARGETS arguments - string(REPLACE ";" " " enable_gems_args "${ly_enable_gems_PROJECT_NAME},${ly_enable_gems_GEMS},${ly_enable_gems_GEM_FILE},${ly_enable_gems_VARIANTS},${ly_enable_gems_TARGETS}") + if(NOT ly_enable_gems_PROJECT_NAME STREQUAL "__NOPROJECT__") + set(replicated_project_name ${ly_enable_gems_PROJECT_NAME}) + endif() + # The GEM_FILE file is used to populate the GEMS argument via the ENABLED_GEMS variable in the file. + # Furthermore the GEM_FILE itself is not copied over to the install layout, so make its argument entry blank and use the list of GEMS + # stored in ly_enable_gems_GEMS + string(REPLACE ";" " " enable_gems_args "${replicated_project_name},${ly_enable_gems_GEMS},,${ly_enable_gems_VARIANTS},${ly_enable_gems_TARGETS}") set_property(DIRECTORY APPEND PROPERTY LY_ENABLE_GEMS_ARGUMENTS "${enable_gems_args}") endfunction() @@ -234,4 +240,4 @@ function(ly_enable_gems_delayed) endif() endforeach() endforeach() -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index c724567060..307f5c3ef8 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -151,7 +151,7 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar cmake_path(RELATIVE_PATH include BASE_DIRECTORY ${LY_ROOT_FOLDER} OUTPUT_VARIABLE target_include) cmake_path(NORMAL_PATH target_include) # Escape the LY_ROOT_FOLDER variable so that it isn't resolved during the install step - string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/${target_include}\n") + string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/${include_location}/${target_include}\n") endif() endforeach() endif() @@ -286,22 +286,12 @@ function(ly_setup_subdirectory absolute_target_source_dir) # Reproduce the ly_enable_gems() calls made in the the SOURCE_DIR for this target into the CMakeLists.txt that # is about to be generated - string(JOIN "\n" enable_gems_template - " ly_enable_gems(@enable_gem_PROJECT_NAME@ @enable_gem_GEM@ @enable_gem_GEM_FILE@ @enable_gem_VARIANTS@ @enable_gem_TARGETS@)" - "endif()" - "" - ) + set(enable_gems_template "ly_enable_gems(@enable_gem_PROJECT_NAME@ @enable_gem_GEMS@ @enable_gem_GEM_FILE@ @enable_gem_VARIANTS@ @enable_gem_TARGETS@)\n") get_property(enable_gems_commands_arg_list DIRECTORY ${absolute_target_source_dir} PROPERTY LY_ENABLE_GEMS_ARGUMENTS) foreach(enable_gems_single_command_arg_list ${enable_gems_commands_arg_list}) # Split the ly_enable_gems arguments back out based on commas - string(REPLACE "," ";" ly_enable_gems_single_command_arg_list "${enable_gems_single_command_arg_list}") - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_PROJECT_NAME) - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_GEM) - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_GEM_FILE) - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_GEM) - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_VARIANTS) - list(POP_FRONT enable_gems_single_command_arg_list enable_gem_TARGETS) - foreach(enable_gem_arg_kw IN ITEMS PROJECT_NAME GEM GEM_FILE GEM VARIANTS TARGETS) + string(REPLACE "," ";" enable_gems_single_command_arg_list "${enable_gems_single_command_arg_list}") + foreach(enable_gem_arg_kw IN ITEMS PROJECT_NAME GEMS GEM_FILE VARIANTS TARGETS) list(POP_FRONT enable_gems_single_command_arg_list enable_gem_${enable_gem_arg_kw}) if(enable_gem_${enable_gem_arg_kw}) # if the argument exist append to argument keyword to the front diff --git a/cmake/SettingsRegistry.cmake b/cmake/SettingsRegistry.cmake index b3cb3f7706..3aff1bdc5c 100644 --- a/cmake/SettingsRegistry.cmake +++ b/cmake/SettingsRegistry.cmake @@ -184,7 +184,14 @@ function(ly_delayed_generate_settings_registry) list(JOIN target_gem_dependencies_names ",\n" target_gem_dependencies_names) string(CONFIGURE ${gems_json_template} gem_json @ONLY) - if(prefix) + get_target_property(is_imported ${target} IMPORTED) + if(is_imported) + unset(target_dir) + foreach(conf IN LISTS CMAKE_CONFIGURATION_TYPES) + string(TOUPPER ${conf} UCONF) + string(APPEND target_dir $<$:${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${UCONF}}>) + endforeach() + elseif(prefix) set(target_dir $) else() set(target_dir $)