Implemented changes in the ly_setup_target() command to forward the ly_create_alias() command calls to the configured CMakeLists.txt per installed target
This commit is contained in:
+13
-2
@@ -47,6 +47,10 @@ function(ly_create_alias)
|
||||
if (NOT TARGET ${ly_create_alias_NAME})
|
||||
add_library(${ly_create_alias_NAME} ALIAS ${de_aliased_target_name})
|
||||
endif()
|
||||
# Store off the arguments needed used ly_create_alias into a DIRECTORY property
|
||||
# This will be used to re-create the calls in the generated CMakeLists.txt in the INSTALL step
|
||||
string(REPLACE ";" " " create_alias_args "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}")
|
||||
set_property(DIRECTORY APPEND PROPERTY LY_CREATE_ALIAS_ARGUMENTS "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -75,6 +79,13 @@ function(ly_create_alias)
|
||||
|
||||
# now add the final alias:
|
||||
add_library(${ly_create_alias_NAMESPACE}::${ly_create_alias_NAME} ALIAS ${ly_create_alias_NAME})
|
||||
|
||||
# Store off the arguments needed used ly_create_alias into a DIRECTORY property
|
||||
# This will be used to re-create the calls in the generated CMakeLists.txt in the INSTALL step
|
||||
|
||||
# Replace the CMake list separator with a space to replicate the space separated TARGETS arguments
|
||||
string(REPLACE ";" " " create_alias_args "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}")
|
||||
set_property(DIRECTORY APPEND PROPERTY LY_CREATE_ALIAS_ARGUMENTS "${create_alias_args}")
|
||||
endfunction()
|
||||
|
||||
# ly_enable_gems
|
||||
@@ -143,7 +154,7 @@ endfunction()
|
||||
function(ly_enable_gems_delayed)
|
||||
get_property(ly_delayed_enable_gems GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS)
|
||||
foreach(project_target_variant ${ly_delayed_enable_gems})
|
||||
# we expect a colon seperated list of
|
||||
# we expect a colon separated list of
|
||||
# PROJECT_NAME,target_name,variant_name
|
||||
string(REPLACE "," ";" project_target_variant_list "${project_target_variant}")
|
||||
list(LENGTH project_target_variant_list project_target_variant_length)
|
||||
@@ -152,7 +163,7 @@ function(ly_enable_gems_delayed)
|
||||
endif()
|
||||
|
||||
if(NOT project_target_variant_length EQUAL 3)
|
||||
message(FATAL_ERROR "Invalid specificaiton of gems, expected 'project','target','variant' and got ${project_target_variant}")
|
||||
message(FATAL_ERROR "Invalid specification of gems, expected 'project','target','variant' and got ${project_target_variant}")
|
||||
endif()
|
||||
|
||||
list(POP_BACK project_target_variant_list variant)
|
||||
|
||||
@@ -155,6 +155,25 @@ function(ly_setup_target ALIAS_TARGET_NAME)
|
||||
list(REMOVE_DUPLICATES INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER)
|
||||
string(REPLACE ";" "\n" INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER}")
|
||||
|
||||
# Replicate the ly_create_alias() calls based on the SOURCE_DIR for each target that generates an installed CMakeLists.txt
|
||||
string(JOIN "\n" create_alias_template
|
||||
"if(NOT TARGET @ALIAS_NAME@)"
|
||||
" ly_create_alias(NAME @ALIAS_NAME@ NAMESPACE @ALIAS_NAMESPACE@ TARGETS @ALIAS_TARGETS@)"
|
||||
"endif()"
|
||||
""
|
||||
)
|
||||
get_property(create_alias_commands_arg_list DIRECTORY ${absolute_target_source_dir} PROPERTY LY_CREATE_ALIAS_ARGUMENTS)
|
||||
foreach(create_alias_single_command_arg_list ${create_alias_commands_arg_list})
|
||||
# Split the ly_create_alias arguments back out based on commas
|
||||
string(REPLACE "," ";" create_alias_single_command_arg_list "${create_alias_single_command_arg_list}")
|
||||
list(POP_FRONT create_alias_single_command_arg_list ALIAS_NAME)
|
||||
list(POP_FRONT create_alias_single_command_arg_list ALIAS_NAMESPACE)
|
||||
# The rest of the list are the target dependencies
|
||||
set(ALIAS_TARGETS ${create_alias_single_command_arg_list})
|
||||
string(CONFIGURE "${create_alias_template}" create_alias_command @ONLY)
|
||||
string(APPEND CREATE_ALIASES_PLACEHOLDER ${create_alias_command})
|
||||
endforeach()
|
||||
|
||||
# Since a CMakeLists.txt could contain multiple targets, we generate it in a folder per target
|
||||
configure_file(${LY_ROOT_FOLDER}/cmake/install/TargetCMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/install/${NAME_PLACEHOLDER}/CMakeLists.txt @ONLY)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ set(FILES
|
||||
EngineJson.cmake
|
||||
FileUtil.cmake
|
||||
Findo3de.cmake
|
||||
Gems.cmake
|
||||
GeneralSettings.cmake
|
||||
Install.cmake
|
||||
LyAutoGen.cmake
|
||||
|
||||
@@ -27,6 +27,7 @@ ly_add_target(
|
||||
@RUNTIME_DEPENDENCIES_PLACEHOLDER@
|
||||
)
|
||||
|
||||
@CREATE_ALIASES_PLACEHOLDER@
|
||||
set(configs @CMAKE_CONFIGURATION_TYPES@)
|
||||
foreach(config ${configs})
|
||||
include("@NAME_PLACEHOLDER@_${config}.cmake" OPTIONAL)
|
||||
|
||||
Reference in New Issue
Block a user