Making install to be completely a post-processing step. We need this so all dependencies are declared and ready when we generate the target files
This commit is contained in:
@@ -12,10 +12,4 @@
|
||||
if(NOT INSTALLED_ENGINE)
|
||||
ly_get_absolute_pal_filename(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Platform/${PAL_PLATFORM_NAME})
|
||||
include(${pal_dir}/Install_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
|
||||
else()
|
||||
|
||||
# Provide empty implementation so ly_add_target continues working
|
||||
function(ly_install_target ly_install_target_NAME)
|
||||
endfunction()
|
||||
|
||||
endif()
|
||||
+29
-54
@@ -202,7 +202,7 @@ function(ly_add_target)
|
||||
endif()
|
||||
|
||||
if (ly_add_target_INCLUDE_DIRECTORIES)
|
||||
ly_target_include_directories(${ly_add_target_NAME}
|
||||
target_include_directories(${ly_add_target_NAME}
|
||||
${ly_add_target_INCLUDE_DIRECTORIES}
|
||||
)
|
||||
endif()
|
||||
@@ -299,7 +299,7 @@ function(ly_add_target)
|
||||
endif()
|
||||
|
||||
# Store the target so we can walk through all of them in LocationDependencies.cmake
|
||||
set_property(GLOBAL APPEND PROPERTY LY_ALL_TARGETS ${ly_add_target_NAME})
|
||||
set_property(GLOBAL APPEND PROPERTY LY_ALL_TARGETS ${interface_name})
|
||||
|
||||
set(runtime_dependencies_list SHARED MODULE EXECUTABLE APPLICATION)
|
||||
if(linking_options IN_LIST runtime_dependencies_list)
|
||||
@@ -330,18 +330,6 @@ function(ly_add_target)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT ly_add_target_IMPORTED)
|
||||
ly_install_target(
|
||||
${ly_add_target_NAME}
|
||||
NAMESPACE ${ly_add_target_NAMESPACE}
|
||||
INCLUDE_DIRECTORIES ${ly_add_target_INCLUDE_DIRECTORIES}
|
||||
BUILD_DEPENDENCIES ${ly_add_target_BUILD_DEPENDENCIES}
|
||||
RUNTIME_DEPENDENCIES ${ly_add_target_RUNTIME_DEPENDENCIES}
|
||||
COMPILE_DEFINITIONS ${ly_add_target_COMPILE_DEFINITIONS}
|
||||
COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT}
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
#! ly_target_link_libraries: wraps target_link_libraries handling also MODULE linkage.
|
||||
@@ -401,7 +389,7 @@ function(ly_delayed_target_link_libraries)
|
||||
endif()
|
||||
|
||||
if(item_type STREQUAL MODULE_LIBRARY)
|
||||
ly_target_include_directories(${target} ${visibility} $<TARGET_PROPERTY:${item},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
target_include_directories(${target} ${visibility} $<TARGET_PROPERTY:${item},INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
target_link_libraries(${target} ${visibility} $<TARGET_PROPERTY:${item},INTERFACE_LINK_LIBRARIES>)
|
||||
target_compile_definitions(${target} ${visibility} $<TARGET_PROPERTY:${item},INTERFACE_COMPILE_DEFINITIONS>)
|
||||
target_compile_options(${target} ${visibility} $<TARGET_PROPERTY:${item},INTERFACE_COMPILE_OPTIONS>)
|
||||
@@ -502,7 +490,7 @@ endfunction()
|
||||
# Looks at the the following variables within the platform include file to set the equivalent target properties
|
||||
# LY_FILES_CMAKE -> extract list of files -> target_sources
|
||||
# LY_FILES -> target_source
|
||||
# LY_INCLUDE_DIRECTORIES -> ly_target_include_directories
|
||||
# LY_INCLUDE_DIRECTORIES -> target_include_directories
|
||||
# LY_COMPILE_DEFINITIONS -> target_compile_definitions
|
||||
# LY_COMPILE_OPTIONS -> target_compile_options
|
||||
# LY_LINK_OPTIONS -> target_link_options
|
||||
@@ -528,7 +516,11 @@ macro(ly_configure_target_platform_properties)
|
||||
message(FATAL_ERROR "The supplied PLATFORM_INCLUDE_FILE(${platform_include_file}) cannot be included.\
|
||||
Parsing of target will halt")
|
||||
endif()
|
||||
target_sources(${ly_add_target_NAME} PRIVATE ${platform_include_file})
|
||||
if(ly_add_target_HEADERONLY)
|
||||
target_sources(${ly_add_target_NAME} INTERFACE ${platform_include_file})
|
||||
else()
|
||||
target_sources(${ly_add_target_NAME} PRIVATE ${platform_include_file})
|
||||
endif()
|
||||
ly_source_groups_from_folders("${platform_include_file}")
|
||||
|
||||
if(LY_FILES_CMAKE)
|
||||
@@ -544,7 +536,7 @@ macro(ly_configure_target_platform_properties)
|
||||
target_sources(${ly_add_target_NAME} PRIVATE ${LY_FILES})
|
||||
endif()
|
||||
if (LY_INCLUDE_DIRECTORIES)
|
||||
ly_target_include_directories(${ly_add_target_NAME} ${LY_INCLUDE_DIRECTORIES})
|
||||
target_include_directories(${ly_add_target_NAME} ${LY_INCLUDE_DIRECTORIES})
|
||||
endif()
|
||||
if(LY_COMPILE_DEFINITIONS)
|
||||
target_compile_definitions(${ly_add_target_NAME} ${LY_COMPILE_DEFINITIONS})
|
||||
@@ -647,42 +639,6 @@ function(ly_add_source_properties)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(ly_target_include_directories TARGET)
|
||||
|
||||
# Add the includes to the build and install interface
|
||||
set(reserved_keywords PRIVATE PUBLIC INTERFACE)
|
||||
unset(last_keyword)
|
||||
foreach(include ${ARGN})
|
||||
if(${include} IN_LIST reserved_keywords)
|
||||
list(APPEND adapted_includes ${include})
|
||||
elseif(IS_ABSOLUTE ${include})
|
||||
list(APPEND adapted_includes
|
||||
$<BUILD_INTERFACE:${include}>
|
||||
)
|
||||
else()
|
||||
string(GENEX_STRIP ${include} include_genex_expr)
|
||||
if(include_genex_expr STREQUAL include) # only for cases where there are no generation expressions
|
||||
# We will be installing the includes using the same directory structure used in our source tree.
|
||||
# The INSTALL_INTERFACE path tells CMake the location of the includes relative to the install prefix.
|
||||
# When the target is imported into an external project, cmake will find these includes at <install_prefix>/include/<path_relative_to_root>
|
||||
# where <install_prefix> is the location of the lumberyard install on disk.
|
||||
file(REAL_PATH ${include} include_real)
|
||||
file(RELATIVE_PATH install_dir ${CMAKE_SOURCE_DIR} ${include_real})
|
||||
list(APPEND adapted_includes
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${include}>
|
||||
$<INSTALL_INTERFACE:include/${install_dir}>
|
||||
)
|
||||
else()
|
||||
list(APPEND adapted_includes
|
||||
${include}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
target_include_directories(${TARGET} ${adapted_includes})
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
#! ly_project_add_subdirectory: calls add_subdirectory() if the project name is in the project list
|
||||
#
|
||||
@@ -713,3 +669,22 @@ function(ly_project_add_subdirectory project_name)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# given a target name, returns the "real" name of the target if its an alias.
|
||||
# this function recursively de-aliases
|
||||
function(ly_de_alias_target target_name output_variable_name)
|
||||
# its not okay to call get_target_property on a non-existant target
|
||||
if (NOT TARGET ${target_name})
|
||||
message(FATAL_ERROR "ly_de_alias_target called on non-existant target: ${target_name}")
|
||||
endif()
|
||||
|
||||
while(target_name)
|
||||
set(de_aliased_target_name ${target_name})
|
||||
get_target_property(target_name ${target_name} ALIASED_TARGET)
|
||||
endwhile()
|
||||
|
||||
if(NOT de_aliased_target_name)
|
||||
message(FATAL_ERROR "Empty de_aliased for ${target_name}")
|
||||
endif()
|
||||
set(${output_variable_name} ${de_aliased_target_name} PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -26,7 +26,7 @@ function(ly_add_autogen)
|
||||
if(ly_add_autogen_AUTOGEN_RULES)
|
||||
set(AZCG_INPUTFILES ${ly_add_autogen_ALLFILES})
|
||||
list(FILTER AZCG_INPUTFILES INCLUDE REGEX ".*\.(xml|json|jinja)$")
|
||||
ly_target_include_directories(${ly_add_autogen_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated")
|
||||
target_include_directories(${ly_add_autogen_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated")
|
||||
execute_process(
|
||||
COMMAND ${LY_PYTHON_CMD} "${LY_ROOT_FOLDER}/Code/Framework/AzAutoGen/AzAutoGen.py" "${CMAKE_BINARY_DIR}/Azcg/TemplateCache/" "${CMAKE_CURRENT_BINARY_DIR}/Azcg/Generated/" "${CMAKE_CURRENT_SOURCE_DIR}" "${AZCG_INPUTFILES}" "${ly_add_autogen_AUTOGEN_RULES}" "-n"
|
||||
OUTPUT_VARIABLE AUTOGEN_OUTPUTS
|
||||
|
||||
@@ -17,49 +17,61 @@ file(RELATIVE_PATH runtime_output_directory ${CMAKE_BINARY_DIR} ${CMAKE_RUNTIME_
|
||||
file(RELATIVE_PATH library_output_directory ${CMAKE_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(install_output_folder "${CMAKE_INSTALL_PREFIX}/${runtime_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>")
|
||||
|
||||
#! ly_setup_targets: setups all targets
|
||||
function(ly_setup_targets)
|
||||
get_property(all_targets GLOBAL PROPERTY LY_ALL_TARGETS)
|
||||
foreach(target IN LISTS all_targets)
|
||||
ly_setup_target(${target})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
#! ly_install_target: registers the target to be installed by cmake install.
|
||||
#
|
||||
# \arg:NAME name of the target
|
||||
# \arg:COMPONENT the grouping string of the target used for splitting up the install
|
||||
# into smaller packages.
|
||||
# All other parameters are forwarded to ly_generate_target_find_file
|
||||
function(ly_install_target ly_install_target_NAME)
|
||||
#! ly_setup_target: setups the target to be installed by cmake install.
|
||||
function(ly_setup_target ALIAS_TARGET_NAME)
|
||||
|
||||
set(options)
|
||||
set(oneValueArgs NAMESPACE COMPONENT)
|
||||
set(multiValueArgs INCLUDE_DIRECTORIES BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES COMPILE_DEFINITIONS)
|
||||
|
||||
cmake_parse_arguments(ly_install_target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
unset(TARGET_NAME)
|
||||
ly_de_alias_target(${ALIAS_TARGET_NAME} TARGET_NAME)
|
||||
|
||||
get_target_property(absolute_target_source_dir ${TARGET_NAME} SOURCE_DIR)
|
||||
file(RELATIVE_PATH target_source_dir ${CMAKE_SOURCE_DIR} ${absolute_target_source_dir})
|
||||
|
||||
# All include directories marked PUBLIC or INTERFACE will be installed
|
||||
set(include_location "include")
|
||||
get_target_property(include_directories ${ly_install_target_NAME} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
||||
get_target_property(include_directories ${TARGET_NAME} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if (include_directories)
|
||||
set_target_properties(${ly_install_target_NAME} PROPERTIES PUBLIC_HEADER "${include_directories}")
|
||||
# The include directories are specified relative to the CMakeLists.txt file that adds the target.
|
||||
# We need to install the includes relative to our source tree root because that's where INSTALL_INTERFACE
|
||||
# will point CMake when it looks for headers
|
||||
file(RELATIVE_PATH relative_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
string(APPEND include_location "/${relative_path}")
|
||||
unset(public_headers)
|
||||
foreach(include_directory ${include_directories})
|
||||
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)
|
||||
# We install all header types for the time being until we clean up certain libraries that contain all sorts
|
||||
# of files in the public include directories (e.g. CryCommon)
|
||||
file(GLOB_RECURSE current_public_headers
|
||||
LIST_DIRECTORIES false
|
||||
${include_directory}/*.h
|
||||
${include_directory}/*.hpp
|
||||
${include_directory}/*.inl
|
||||
)
|
||||
list(APPEND public_headers ${current_public_headers})
|
||||
endif()
|
||||
endforeach()
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES PUBLIC_HEADER "${public_headers}")
|
||||
endif()
|
||||
|
||||
# Get the output folders, archive is always the same, but runtime/library can be in subfolders defined per target
|
||||
file(RELATIVE_PATH archive_output_directory ${CMAKE_BINARY_DIR} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
||||
|
||||
get_target_property(target_runtime_output_directory ${ly_install_target_NAME} RUNTIME_OUTPUT_DIRECTORY)
|
||||
get_target_property(target_runtime_output_directory ${TARGET_NAME} RUNTIME_OUTPUT_DIRECTORY)
|
||||
if(target_runtime_output_directory)
|
||||
file(RELATIVE_PATH target_runtime_output_subdirectory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${target_runtime_output_directory})
|
||||
endif()
|
||||
|
||||
get_target_property(target_library_output_directory ${ly_install_target_NAME} LIBRARY_OUTPUT_DIRECTORY)
|
||||
get_target_property(target_library_output_directory ${TARGET_NAME} LIBRARY_OUTPUT_DIRECTORY)
|
||||
if(target_library_output_directory)
|
||||
file(RELATIVE_PATH target_library_output_subdirectory ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${target_library_output_directory})
|
||||
endif()
|
||||
|
||||
install(
|
||||
TARGETS ${ly_install_target_NAME}
|
||||
TARGETS ${TARGET_NAME}
|
||||
ARCHIVE
|
||||
DESTINATION ${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>
|
||||
COMPONENT ${ly_install_target_COMPONENT}
|
||||
@@ -70,81 +82,78 @@ function(ly_install_target ly_install_target_NAME)
|
||||
DESTINATION ${runtime_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_runtime_output_subdirectory}
|
||||
COMPONENT ${ly_install_target_COMPONENT}
|
||||
PUBLIC_HEADER
|
||||
DESTINATION ${include_location}
|
||||
# The include directories are specified relative to the CMakeLists.txt file that adds the target.
|
||||
# We need to install the includes relative to our source tree root
|
||||
DESTINATION ${include_location}/${target_source_dir}
|
||||
COMPONENT ${ly_install_target_COMPONENT}
|
||||
)
|
||||
|
||||
ly_generate_target_find_file(NAME ${ly_install_target_NAME} ${ARGN})
|
||||
ly_generate_target_config_file(${ly_install_target_NAME})
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
#! ly_generate_target_find_file: generates the Find${target}.cmake file which is used when importing installed packages.
|
||||
#
|
||||
# \arg:NAME name of the target
|
||||
# \arg:NAMESPACE namespace declaration for this target. It will be used for IDE and dependencies
|
||||
# \arg:INCLUDE_DIRECTORIES paths to the include directories
|
||||
# \arg:BUILD_DEPENDENCIES list of interfaces this target depends on (could be a compilation dependency
|
||||
# if the dependency is only exposing an include path, or could be a linking
|
||||
# dependency is exposing a lib)
|
||||
# \arg:RUNTIME_DEPENDENCIES list of dependencies this target depends on at runtime
|
||||
# \arg:COMPILE_DEFINITIONS list of compilation definitions this target will use to compile
|
||||
function(ly_generate_target_find_file)
|
||||
|
||||
set(options)
|
||||
set(oneValueArgs NAME NAMESPACE)
|
||||
set(multiValueArgs INCLUDE_DIRECTORIES COMPILE_DEFINITIONS BUILD_DEPENDENCIES RUNTIME_DEPENDENCIES)
|
||||
cmake_parse_arguments(ly_generate_target_find_file "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
set(NAME_PLACEHOLDER ${ly_generate_target_find_file_NAME})
|
||||
unset(NAMESPACE_PLACEHOLDER)
|
||||
unset(COMPILE_DEFINITIONS_PLACEHOLDER)
|
||||
unset(include_directories_interface_props)
|
||||
unset(INCLUDE_DIRECTORIES_PLACEHOLDER)
|
||||
set(RUNTIME_DEPENDENCIES_PLACEHOLDER ${ly_generate_target_find_file_RUNTIME_DEPENDENCIES})
|
||||
|
||||
# These targets will be imported. We will expose PUBLIC and INTERFACE properties as INTERFACE properties since
|
||||
# only INTERFACE properties can be exposed on imported targets
|
||||
ly_strip_private_properties(COMPILE_DEFINITIONS_PLACEHOLDER ${ly_generate_target_find_file_COMPILE_DEFINITIONS})
|
||||
ly_strip_private_properties(include_directories_interface_props ${ly_generate_target_find_file_INCLUDE_DIRECTORIES})
|
||||
ly_strip_private_properties(BUILD_DEPENDENCIES_PLACEHOLDER ${ly_generate_target_find_file_BUILD_DEPENDENCIES})
|
||||
|
||||
if(ly_generate_target_find_file_NAMESPACE)
|
||||
set(NAMESPACE_PLACEHOLDER "NAMESPACE ${ly_generate_target_find_file_NAMESPACE}")
|
||||
# CMakeLists.txt file
|
||||
string(REGEX MATCH "(.*)::(.*)$" match ${ALIAS_TARGET_NAME})
|
||||
if(match)
|
||||
set(NAMESPACE_PLACEHOLDER "NAMESPACE ${CMAKE_MATCH_1}")
|
||||
set(NAME_PLACEHOLDER ${CMAKE_MATCH_2})
|
||||
else()
|
||||
set(NAMESPACE_PLACEHOLDER "")
|
||||
set(NAME_PLACEHOLDER ${TARGET_NAME})
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "\n" COMPILE_DEFINITIONS_PLACEHOLDER "${COMPILE_DEFINITIONS_PLACEHOLDER}")
|
||||
get_target_property(COMPILE_DEFINITIONS_PLACEHOLDER ${TARGET_NAME} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(COMPILE_DEFINITIONS_PLACEHOLDER)
|
||||
string(REPLACE ";" "\n" COMPILE_DEFINITIONS_PLACEHOLDER "${COMPILE_DEFINITIONS_PLACEHOLDER}")
|
||||
else()
|
||||
unset(COMPILE_DEFINITIONS_PLACEHOLDER)
|
||||
endif()
|
||||
|
||||
# Includes need additional processing to add the install root
|
||||
foreach(include ${include_directories_interface_props})
|
||||
file(RELATIVE_PATH relative_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${include})
|
||||
string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/include/${relative_path}\n")
|
||||
endforeach()
|
||||
get_target_property(include_directories_interface_props ${TARGET_NAME} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
unset(INCLUDE_DIRECTORIES_PLACEHOLDER)
|
||||
if(include_directories_interface_props)
|
||||
foreach(include ${include_directories_interface_props})
|
||||
string(APPEND INCLUDE_DIRECTORIES_PLACEHOLDER "\${LY_ROOT_FOLDER}/include/${target_source_dir}\n")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "\n" BUILD_DEPENDENCIES_PLACEHOLDER "${BUILD_DEPENDENCIES_PLACEHOLDER}")
|
||||
string(REPLACE ";" "\n" RUNTIME_DEPENDENCIES_PLACEHOLDER "${RUNTIME_DEPENDENCIES_PLACEHOLDER}")
|
||||
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
|
||||
string(REPLACE ";" "\n" RUNTIME_DEPENDENCIES_PLACEHOLDER "${RUNTIME_DEPENDENCIES_PLACEHOLDER}")
|
||||
else()
|
||||
unset(RUNTIME_DEPENDENCIES_PLACEHOLDER)
|
||||
endif()
|
||||
|
||||
# Since a CMakeLists 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/${ly_generate_target_find_file_NAME}/CMakeLists.txt @ONLY)
|
||||
get_target_property(target_source_dir ${ly_generate_target_find_file_NAME} SOURCE_DIR)
|
||||
file(RELATIVE_PATH target_source_dir_relative ${CMAKE_SOURCE_DIR} ${target_source_dir})
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/install/${ly_generate_target_find_file_NAME}/CMakeLists.txt"
|
||||
DESTINATION ${target_source_dir_relative}/${ly_generate_target_find_file_NAME}
|
||||
get_target_property(inteface_build_dependencies_props ${TARGET_NAME} INTERFACE_LINK_LIBRARIES)
|
||||
unset(INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER)
|
||||
if(inteface_build_dependencies_props)
|
||||
foreach(build_dependency ${inteface_build_dependencies_props})
|
||||
# Skip wrapping produced when targets are not created in the same directory
|
||||
if(NOT ${build_dependency} MATCHES "^::@")
|
||||
string(APPEND INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER "${build_dependency}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# We also need to declare teh private link libraries since we will use that to generate the runtime dependencies
|
||||
get_target_property(private_build_dependencies_props ${TARGET_NAME} LINK_LIBRARIES)
|
||||
unset(PRIVATE_BUILD_DEPENDENCIES_PLACEHOLDER)
|
||||
if(private_build_dependencies_props)
|
||||
foreach(build_dependency ${private_build_dependencies_props})
|
||||
# Skip wrapping produced when targets are not created in the same directory
|
||||
if(NOT ${build_dependency} MATCHES "^::@")
|
||||
string(APPEND PRIVATE_BUILD_DEPENDENCIES_PLACEHOLDER "${build_dependency}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# 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)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/install/${NAME_PLACEHOLDER}/CMakeLists.txt"
|
||||
DESTINATION ${target_source_dir}/${NAME_PLACEHOLDER}
|
||||
COMPONENT ${ly_install_target_COMPONENT}
|
||||
)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
#! ly_generate_target_config_file: generates the ${target}_$<CONFIG>.cmake files for a target
|
||||
#
|
||||
# The generated file will set the location of the target binary per configuration
|
||||
# These per config files will be included by the target's find file to set the location of the binary/
|
||||
# \arg:NAME name of the target
|
||||
function(ly_generate_target_config_file NAME)
|
||||
|
||||
get_target_property(target_type ${NAME} TYPE)
|
||||
# Config file
|
||||
get_target_property(target_type ${TARGET_NAME} TYPE)
|
||||
|
||||
set(target_file_contents "# Generated by O3DE install\n\n")
|
||||
if(NOT target_type STREQUAL INTERFACE_LIBRARY)
|
||||
@@ -152,66 +161,43 @@ function(ly_generate_target_config_file NAME)
|
||||
unset(target_location)
|
||||
set(runtime_types EXECUTABLE APPLICATION)
|
||||
if(target_type IN_LIST runtime_types)
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${runtime_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_runtime_output_subdirectory}/$<TARGET_FILE_NAME:${NAME}>\"")
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${runtime_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_runtime_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>\"")
|
||||
elseif(target_type STREQUAL MODULE_LIBRARY)
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${NAME}>\"")
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>\"")
|
||||
elseif(target_type STREQUAL SHARED_LIBRARY)
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${NAME}>\"")
|
||||
string(APPEND target_file_contents "ly_add_target_files(TARGETS ${NAME} FILES \"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${NAME}>\")\n")
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${TARGET_NAME}>\"")
|
||||
string(APPEND target_file_contents "target_link_libraries(${TARGET_NAME} INTERFACE \"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>\")\n")
|
||||
else() # STATIC_LIBRARY, OBJECT_LIBRARY, INTERFACE_LIBRARY
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${NAME}>\"")
|
||||
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${TARGET_NAME}>\"")
|
||||
endif()
|
||||
|
||||
string(APPEND target_file_contents
|
||||
"set(target_location ${target_location})
|
||||
set_target_properties(${NAME}
|
||||
set_target_properties(${TARGET_NAME}
|
||||
PROPERTIES
|
||||
$<$<CONFIG:profile>:IMPORTED_LOCATION \"\${target_location}\">
|
||||
IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>> \"\${target_location}\"
|
||||
)
|
||||
if(EXISTS \"\${target_location}\")
|
||||
set(${NAME}_$<CONFIG>_FOUND TRUE)
|
||||
set(${NAME_PLACEHOLDER}_$<CONFIG>_FOUND TRUE)
|
||||
else()
|
||||
set(${NAME}_$<CONFIG>_FOUND FALSE)
|
||||
set(${NAME_PLACEHOLDER}_$<CONFIG>_FOUND FALSE)
|
||||
endif()
|
||||
")
|
||||
endif()
|
||||
|
||||
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/install/${NAME}/${NAME}_$<CONFIG>.cmake" CONTENT "${target_file_contents}")
|
||||
get_target_property(target_source_dir ${NAME} SOURCE_DIR)
|
||||
file(RELATIVE_PATH target_source_dir_relative ${CMAKE_SOURCE_DIR} ${target_source_dir})
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/install/${NAME}/${NAME}_$<CONFIG>.cmake"
|
||||
DESTINATION ${target_source_dir_relative}/${NAME}
|
||||
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/install/${NAME_PLACEHOLDER}/${NAME_PLACEHOLDER}_$<CONFIG>.cmake" CONTENT "${target_file_contents}")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/install/${NAME_PLACEHOLDER}/${NAME_PLACEHOLDER}_$<CONFIG>.cmake"
|
||||
DESTINATION ${target_source_dir}/${NAME_PLACEHOLDER}
|
||||
COMPONENT ${ly_install_target_COMPONENT}
|
||||
)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
#! ly_strip_private_properties: strips private properties since we're exporting an interface target
|
||||
#
|
||||
# \arg:INTERFACE_PROPERTIES list of interface properties to be returned
|
||||
function(ly_strip_private_properties INTERFACE_PROPERTIES)
|
||||
set(reserved_keywords PRIVATE PUBLIC INTERFACE)
|
||||
unset(last_keyword)
|
||||
unset(stripped_props)
|
||||
foreach(prop ${ARGN})
|
||||
if(${prop} IN_LIST reserved_keywords)
|
||||
set(last_keyword ${prop})
|
||||
else()
|
||||
if (NOT last_keyword STREQUAL "PRIVATE")
|
||||
list(APPEND stripped_props ${prop})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(${INTERFACE_PROPERTIES} ${stripped_props} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
#! ly_setup_o3de_install: orchestrates the installation of the different parts. This is the entry point from the root CMakeLists.txt
|
||||
function(ly_setup_o3de_install)
|
||||
|
||||
ly_setup_targets()
|
||||
ly_setup_cmake_install()
|
||||
ly_setup_target_generator()
|
||||
ly_setup_runtime_dependencies()
|
||||
@@ -479,7 +465,6 @@ function(ly_setup_others)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
#! ly_setup_target_generator: install source files needed for project launcher generation
|
||||
function(ly_setup_target_generator)
|
||||
|
||||
|
||||
@@ -212,7 +212,10 @@ function(ly_delayed_generate_runtime_dependencies)
|
||||
list(APPEND CMAKE_MODULE_PATH ${additional_module_paths})
|
||||
|
||||
get_property(all_targets GLOBAL PROPERTY LY_ALL_TARGETS)
|
||||
foreach(target IN LISTS all_targets)
|
||||
foreach(aliased_target IN LISTS all_targets)
|
||||
|
||||
unset(target)
|
||||
ly_de_alias_target(${aliased_target} target)
|
||||
|
||||
# Exclude targets that dont produce runtime outputs
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
@@ -222,18 +225,18 @@ function(ly_delayed_generate_runtime_dependencies)
|
||||
|
||||
unset(runtime_dependencies)
|
||||
set(runtime_commands "
|
||||
function(ly_copy source_file target_directory)
|
||||
get_filename_component(target_filename \"\${source_file}\" NAME)
|
||||
if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\")
|
||||
if(NOT EXISTS \"\${target_directory}\")
|
||||
file(MAKE_DIRECTORY \"\${target_directory}\")
|
||||
endif()
|
||||
if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\")
|
||||
file(LOCK \"\${target_directory}/\${target_filename}.lock\" GUARD FUNCTION TIMEOUT 30)
|
||||
file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
function(ly_copy source_file target_directory)
|
||||
get_filename_component(target_filename \"\${source_file}\" NAME)
|
||||
if(NOT \"\${source_file}\" STREQUAL \"\${target_directory}/\${target_filename}\")
|
||||
if(NOT EXISTS \"\${target_directory}\")
|
||||
file(MAKE_DIRECTORY \"\${target_directory}\")
|
||||
endif()
|
||||
if(\"\${source_file}\" IS_NEWER_THAN \"\${target_directory}/\${target_filename}\")
|
||||
file(LOCK \"\${target_directory}/\${target_filename}.lock\" GUARD FUNCTION TIMEOUT 30)
|
||||
file(COPY \"\${source_file}\" DESTINATION \"\${target_directory}\" FILE_PERMISSIONS ${LY_COPY_PERMISSIONS})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
\n")
|
||||
|
||||
ly_get_runtime_dependencies(runtime_dependencies ${target})
|
||||
|
||||
@@ -11,11 +11,5 @@
|
||||
|
||||
# Empty implementations for untested platforms to fix build errors.
|
||||
|
||||
function(ly_install_target ly_install_target_NAME)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
function(ly_setup_o3de_install)
|
||||
|
||||
endfunction()
|
||||
@@ -11,11 +11,5 @@
|
||||
|
||||
# Empty implementations for untested platforms to fix build errors.
|
||||
|
||||
function(ly_install_target ly_install_target_NAME)
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
function(ly_setup_o3de_install)
|
||||
|
||||
endfunction()
|
||||
@@ -143,7 +143,11 @@ function(ly_delayed_generate_runtime_dependencies)
|
||||
|
||||
get_property(all_targets GLOBAL PROPERTY LY_ALL_TARGETS)
|
||||
unset(test_runner_dependencies)
|
||||
foreach(target IN LISTS all_targets)
|
||||
foreach(aliased_target IN LISTS all_targets)
|
||||
|
||||
unset(target)
|
||||
ly_de_alias_target(${aliased_target} target)
|
||||
|
||||
# Exclude targets that dont produce runtime outputs
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if(NOT target_type IN_LIST LY_TARGET_TYPES_WITH_RUNTIME_OUTPUTS)
|
||||
|
||||
@@ -204,7 +204,10 @@ function(ly_test_impact_export_source_target_mappings MAPPING_TEMPLATE_FILE)
|
||||
get_property(LY_ALL_TARGETS GLOBAL PROPERTY LY_ALL_TARGETS)
|
||||
|
||||
# Walk the build targets
|
||||
foreach(target ${LY_ALL_TARGETS})
|
||||
foreach(aliased_target ${LY_ALL_TARGETS})
|
||||
|
||||
unset(target)
|
||||
ly_de_alias_target(${aliased_target} target)
|
||||
message(TRACE "Exporting static source file mappings for ${target}")
|
||||
|
||||
# Target name and path relative to root
|
||||
|
||||
@@ -22,7 +22,9 @@ ly_add_target(
|
||||
@INCLUDE_DIRECTORIES_PLACEHOLDER@
|
||||
BUILD_DEPENDENCIES
|
||||
INTERFACE
|
||||
@BUILD_DEPENDENCIES_PLACEHOLDER@
|
||||
@INTERFACE_BUILD_DEPENDENCIES_PLACEHOLDER@
|
||||
PRIVATE
|
||||
@PRIVATE_BUILD_DEPENDENCIES_PLACEHOLDER@
|
||||
RUNTIME_DEPENDENCIES
|
||||
@RUNTIME_DEPENDENCIES_PLACEHOLDER@
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user