Private dependencies are not propagated to other targets in generated install layout (#5581)

* transfering private dependencies as runtime dependencies for the generated targets in the install layout

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Update cmake/Platform/Common/Install_common.cmake

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

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

* Update cmake/Platform/Common/Install_common.cmake

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

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

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
monroegm-disable-blank-issue-2
Esteban Papp 4 years ago committed by GitHub
parent bceadf7597
commit b44ce82435
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -167,18 +167,16 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar
endforeach() endforeach()
list(JOIN INCLUDE_DIRECTORIES_PLACEHOLDER "\n" INCLUDE_DIRECTORIES_PLACEHOLDER) list(JOIN INCLUDE_DIRECTORIES_PLACEHOLDER "\n" INCLUDE_DIRECTORIES_PLACEHOLDER)
string(REPEAT " " 8 PLACEHOLDER_INDENT)
get_target_property(RUNTIME_DEPENDENCIES_PLACEHOLDER ${TARGET_NAME} MANUALLY_ADDED_DEPENDENCIES)
if(RUNTIME_DEPENDENCIES_PLACEHOLDER) # not found properties return the name of the variable with a "-NOTFOUND" at the end, here we set it to empty if not found
set(RUNTIME_DEPENDENCIES_PLACEHOLDER "${PLACEHOLDER_INDENT}${RUNTIME_DEPENDENCIES_PLACEHOLDER}")
list(JOIN RUNTIME_DEPENDENCIES_PLACEHOLDER "\n${PLACEHOLDER_INDENT}" RUNTIME_DEPENDENCIES_PLACEHOLDER)
else()
unset(RUNTIME_DEPENDENCIES_PLACEHOLDER)
endif()
string(REPEAT " " 12 PLACEHOLDER_INDENT) string(REPEAT " " 12 PLACEHOLDER_INDENT)
get_property(interface_build_dependencies_props TARGET ${TARGET_NAME} PROPERTY LY_DELAYED_LINK) get_property(interface_build_dependencies_props TARGET ${TARGET_NAME} PROPERTY LY_DELAYED_LINK)
unset(INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER) unset(INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER)
# We can have private build dependencies that contains direct or indirect runtime dependencies.
# Since imported targets cannot contain build dependencies, we need another way to propagate the runtime dependencies.
# We dont want to put such dependencies in the interface because a user can mistakenly use a symbol that is not available
# when using the engine from source (and that the author of the target didn't want to set public).
# To overcome this, we will actually expose the private build dependencies as runtime dependencies. Our runtime dependency
# algorithm will walk recursively also through static libraries and will only copy binaries to the output.
unset(RUNTIME_DEPENDENCIES_PLACEHOLDER)
if(interface_build_dependencies_props) if(interface_build_dependencies_props)
cmake_parse_arguments(build_deps "" "" "PRIVATE;PUBLIC;INTERFACE" ${interface_build_dependencies_props}) cmake_parse_arguments(build_deps "" "" "PRIVATE;PUBLIC;INTERFACE" ${interface_build_dependencies_props})
# Interface and public dependencies should always be exposed # Interface and public dependencies should always be exposed
@ -191,6 +189,8 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar
if("${target_type}" STREQUAL "STATIC_LIBRARY") if("${target_type}" STREQUAL "STATIC_LIBRARY")
set(build_deps_target "${build_deps_target};${build_deps_PRIVATE}") set(build_deps_target "${build_deps_target};${build_deps_PRIVATE}")
endif() endif()
# But we will also pass the private dependencies as runtime dependencies (note the comment above)
set(RUNTIME_DEPENDENCIES_PLACEHOLDER ${build_deps_PRIVATE})
foreach(build_dependency IN LISTS build_deps_target) foreach(build_dependency IN LISTS build_deps_target)
# Skip wrapping produced when targets are not created in the same directory # Skip wrapping produced when targets are not created in the same directory
if(build_dependency) if(build_dependency)
@ -200,6 +200,18 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME absolute_tar
endif() endif()
list(JOIN INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "\n" INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER) list(JOIN INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "\n" INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER)
string(REPEAT " " 8 PLACEHOLDER_INDENT)
get_target_property(manually_added_dependencies ${TARGET_NAME} MANUALLY_ADDED_DEPENDENCIES)
if(manually_added_dependencies) # not found properties return the name of the variable with a "-NOTFOUND" at the end, here we set it to empty if not found
list(APPEND RUNTIME_DEPENDENCIES_PLACEHOLDER ${manually_added_dependencies})
endif()
if(RUNTIME_DEPENDENCIES_PLACEHOLDER)
set(RUNTIME_DEPENDENCIES_PLACEHOLDER "${PLACEHOLDER_INDENT}${RUNTIME_DEPENDENCIES_PLACEHOLDER}")
list(JOIN RUNTIME_DEPENDENCIES_PLACEHOLDER "\n${PLACEHOLDER_INDENT}" RUNTIME_DEPENDENCIES_PLACEHOLDER)
else()
unset(RUNTIME_DEPENDENCIES_PLACEHOLDER)
endif()
string(REPEAT " " 8 PLACEHOLDER_INDENT) string(REPEAT " " 8 PLACEHOLDER_INDENT)
# If a target has an LY_PROJECT_NAME property, forward that property to new target # If a target has an LY_PROJECT_NAME property, forward that property to new target
get_target_property(target_project_association ${TARGET_NAME} LY_PROJECT_NAME) get_target_property(target_project_association ${TARGET_NAME} LY_PROJECT_NAME)

Loading…
Cancel
Save