Files
o3de/cmake/Dependencies.cmake
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

44 lines
1.6 KiB
CMake

#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
include(FindPackageHandleStandardArgs)
#! ly_add_dependencies: wrapper to add_dependencies, however, this wrapper collaborates with
# LYWrappers.cmake to delay adding dependencies if the target is not declared yet.
#
# This wrapper will add the dependency to the indicated target immediately if the target was
# already added. If the target was not added at the moment this function is called, the dependency
# will be stored in a global variable which ly_add_target will access and create those dependencies
# after the target is added.
#
# \arg:TARGET name of the target
# \arg:DEPENDENCIES dependencies to add to TARGET
#
function(ly_add_dependencies TARGET)
if(NOT TARGET)
message(FATAL_ERROR "You must provide a target")
endif()
set (extra_function_args ${ARGN})
if(num_extra_args)
message(FATAL_ERROR "You must provide at least a dependency")
endif()
if(${TARGET} IN_LIST extra_function_args)
message(FATAL_ERROR "Cyclic dependency detected ${TARGET} depends on ${extra_function_args}")
endif()
if(TARGET ${TARGET})
# Target already created, add it
ly_parse_third_party_dependencies("${extra_function_args}")
add_dependencies(${TARGET} ${extra_function_args})
else()
set_property(GLOBAL APPEND PROPERTY LY_DELAYED_DEPENDENCIES_${TARGET} ${extra_function_args})
endif()
endfunction()