Fixes for SDK include directory structure (#1319)

* Updates the install of SDK includes

Needs some fixes so that public include paths that were going up
directories or had multiple path components would resolve to correct
destination paths during install.

* Updates the logic to fix AutoGen includes

AutoGen headers were a special case because matching relative paths
failed due to the headers existing under the build path.

* Removes trailling slashes from inc dirs

This addresses a quirk in CMake where installing a directory with a
trailing slash has different behavior than one without.  The include
paths being processed had a wide mix of slash or not.

* Update cmake/Platform/Common/Install_common.cmake

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixes fatal errors in the last change

The call to cmake_path IS_PREFIX was ill-formed.  Also the trailing
directory separator was being removed from the DESTINATION but really
needed to be removed from the DIRECTORY.

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
Eric Phister
2021-06-17 10:29:28 -05:00
committed by GitHub
parent 39c396c4cd
commit c0d9db6739
+16 -2
View File
@@ -42,8 +42,20 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME)
string(GENEX_STRIP ${include_directory} include_genex_expr)
if(include_genex_expr STREQUAL include_directory) # only for cases where there are no generation expressions
unset(current_public_headers)
cmake_path(NORMAL_PATH include_directory)
string(REGEX REPLACE "/$" "" include_directory "${include_directory}")
cmake_path(IS_PREFIX LY_ROOT_FOLDER ${absolute_target_source_dir} NORMALIZE include_directory_child_of_o3de_root)
if(NOT include_directory_child_of_o3de_root)
message(FATAL_ERROR "Include directory of \"${include_directory}\" is outside of the O3DE root folder of \"${LY_ROOT_FOLDER}\". For the INSTALL step, the O3DE root folder must be a prefix of all include directories")
endif()
cmake_path(RELATIVE_PATH include_directory BASE_DIRECTORY ${LY_ROOT_FOLDER} OUTPUT_VARIABLE rel_include_dir)
cmake_path(APPEND include_location "${rel_include_dir}" ".." OUTPUT_VARIABLE destination_dir)
cmake_path(NORMAL_PATH destination_dir)
install(DIRECTORY ${include_directory}
DESTINATION ${include_location}/${target_source_dir}
DESTINATION ${destination_dir}
COMPONENT ${install_component}
FILES_MATCHING
PATTERN *.h
@@ -116,7 +128,9 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME)
string(GENEX_STRIP ${include} include_genex_expr)
if(include_genex_expr STREQUAL include) # only for cases where there are no generation expressions
file(RELATIVE_PATH relative_include ${absolute_target_source_dir} ${include})
string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/include/${target_source_dir}/${relative_include}\n")
cmake_path(APPEND include_location "${target_source_dir}" "${relative_include}" OUTPUT_VARIABLE target_include)
cmake_path(NORMAL_PATH target_include)
string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/${target_include}\n")
endif()
endforeach()
endif()