diff --git a/cmake/developer_package/api_validator/api_validator.cmake b/cmake/developer_package/api_validator/api_validator.cmake index fe3683ca9af..49d51986fab 100644 --- a/cmake/developer_package/api_validator/api_validator.cmake +++ b/cmake/developer_package/api_validator/api_validator.cmake @@ -32,6 +32,8 @@ function(_ie_add_api_validator_post_build_step_recursive) NOT ${API_VALIDATOR_TARGET} IN_LIST API_VALIDATOR_TARGETS) list(APPEND API_VALIDATOR_TARGETS ${API_VALIDATOR_TARGET}) endif() + # keep checks target list to track cyclic dependencies, leading to infinite recursion + list(APPEND checked_targets ${API_VALIDATOR_TARGET}) if(NOT LIBRARY_TYPE STREQUAL "INTERFACE_LIBRARY") get_target_property(LINKED_LIBRARIES ${API_VALIDATOR_TARGET} LINK_LIBRARIES) @@ -43,6 +45,10 @@ function(_ie_add_api_validator_post_build_step_recursive) foreach(library IN LISTS LINKED_LIBRARIES INTERFACE_LINKED_LIBRARIES) if(TARGET "${library}") get_target_property(orig_library ${library} ALIASED_TARGET) + if(orig_library IN_LIST checked_targets OR library IN_LIST checked_targets) + # in case of cyclic dependencies, we need to skip current target + continue() + endif() if(TARGET "${orig_library}") _ie_add_api_validator_post_build_step_recursive(TARGET ${orig_library}) else()