1# 2# Copyright © 2018-2021 Arm Ltd and Contributors. All rights reserved. 3# SPDX-License-Identifier: MIT 4# 5macro (addDllCopyCommand target sourceDebug sourceRelease) 6 add_custom_command(TARGET ${target} POST_BUILD 7 COMMAND ${CMAKE_COMMAND} -E copy_if_different 8 "$<$<CONFIG:Debug>:${sourceDebug}>$<$<CONFIG:Release>:${sourceRelease}>$<$<CONFIG:RelWithDebInfo>:${sourceRelease}>$<$<CONFIG:MinSizeRel>:${sourceRelease}>" 9 $<TARGET_FILE_DIR:${target}>) 10endmacro() 11 12# Checks if the given list contains an entry which matches the given regex. 13function(listContainsRegex result list regex) 14 set(${result} 0 PARENT_SCOPE) 15 foreach(element ${list}) 16 if(${element} MATCHES ${regex}) 17 set(${result} 1 PARENT_SCOPE) 18 return() 19 endif() 20 endforeach() 21endfunction() 22 23macro(addDllCopyCommands target) 24 if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) 25 # Get the list of dependencies for the given target, so we can copy just the DLLs we need. 26 get_target_property(target_deps_str ${target} LINK_LIBRARIES) 27 set(target_deps) 28 list(APPEND target_deps ${target_deps_str}) 29 30 cmake_policy(SET CMP0057 NEW) # Enable the "IN_LIST" operator 31 32 # armnn.dll 33 if ("armnn" IN_LIST target_deps) 34 addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnn>/armnn.dll" "$<TARGET_FILE_DIR:armnn>/armnn.dll") 35 endif() 36 37 # armnnTfLiteParser.dll 38 if ("armnnTfLiteParser" IN_LIST target_deps) 39 addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnnTfLiteParser>/armnnTfLiteParser.dll" 40 "$<TARGET_FILE_DIR:armnnTfLiteParser>/armnnTfLiteParser.dll") 41 endif() 42 endif() 43endmacro() 44