diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index 5fd1b793692..9327ed4b463 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -186,21 +186,24 @@ macro(ie_register_plugins_dynamic) # Unregister .xml files for plugins from current build tree - set(plugins_to_remove ${IE_REGISTER_POSSIBLE_PLUGINS}) - # Remove legacy plugin names from plugins.xml in case of incremental build - set(plugins_to_remove ${plugins_to_remove} AutoPlugin MultiDevicePlugin HeteroPlugin clDNNPlugin GNAPlugin MKLDNNPlugin myriadPlugin) set(config_output_file "$/plugins.xml") - foreach(plugin IN LISTS plugins_to_remove) + foreach(name IN LISTS PLUGIN_FILES) + string(REPLACE ":" ";" name "${name}") + list(LENGTH name length) + if(NOT ${length} EQUAL 2) + message(FATAL_ERROR "Unexpected error, please, contact developer of this script") + endif() + list(GET name 0 device_name) add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD COMMAND "${CMAKE_COMMAND}" -D "IE_CONFIG_OUTPUT_FILE=${config_output_file}" - -D "IE_PLUGIN_NAME=${plugin}" + -D "IE_PLUGIN_NAME=${device_name}" -D "IE_CONFIGS_DIR=${CMAKE_BINARY_DIR}/plugins" -P "${IEDevScripts_DIR}/plugins/unregister_plugin_cmake.cmake" COMMENT - "Remove ${plugin} from the plugins.xml file" + "Remove ${device_name} from the plugins.xml file" VERBATIM) endforeach() diff --git a/cmake/developer_package/plugins/register_plugin_cmake.cmake b/cmake/developer_package/plugins/register_plugin_cmake.cmake index 645818e17fe..6472c6a18a7 100644 --- a/cmake/developer_package/plugins/register_plugin_cmake.cmake +++ b/cmake/developer_package/plugins/register_plugin_cmake.cmake @@ -46,19 +46,34 @@ endforeach() set(newContent "") file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content) +set(already_exists_in_xml OFF) foreach(line IN LISTS content) - if("${line}" MATCHES "") + if(NOT already_exists_in_xml) foreach(plugin_file IN LISTS plugin_files_to_add) - file(READ "${plugin_file}" content) - set(newContent "${newContent} -${content}") + get_filename_component(plugin_name "${plugin_file}" NAME_WE) + if("${line}" MATCHES "name=\"${plugin_name}\"") + set(already_exists_in_xml ON) + endif() endforeach() endif() + if (NOT already_exists_in_xml) + if("${line}" MATCHES "") + foreach(plugin_file IN LISTS plugin_files_to_add) + file(READ "${plugin_file}" content) + set(newContent "${newContent} +${content}") + endforeach() + endif() - if(newContent) - set(newContent "${newContent}\n${line}") - else() - set(newContent "${line}") + if(newContent) + set(newContent "${newContent}\n${line}") + else() + set(newContent "${line}") + endif() + endif() + + if("${line}" MATCHES "") + set(already_exists_in_xml OFF) endif() endforeach() diff --git a/cmake/developer_package/plugins/unregister_plugin_cmake.cmake b/cmake/developer_package/plugins/unregister_plugin_cmake.cmake index aeab39848af..3fb504db1fd 100644 --- a/cmake/developer_package/plugins/unregister_plugin_cmake.cmake +++ b/cmake/developer_package/plugins/unregister_plugin_cmake.cmake @@ -15,7 +15,7 @@ file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content) set(skip_plugin OFF) foreach(line IN LISTS content) - if("${line}" MATCHES "${IE_PLUGIN_NAME}") + if("${line}" MATCHES "name=\"${IE_PLUGIN_NAME}\"") set(skip_plugin ON) endif()