blob: 525eec4c68a37b77eb844f93332a5b822e123073 [file] [log] [blame]
Jim Flynn0dcef532022-06-14 10:58:23 +01001#
2# Copyright © 2018-2021 Arm Ltd and Contributors. All rights reserved.
3# SPDX-License-Identifier: MIT
4#
telsoa014fcda012018-03-09 14:13:49 +00005macro (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
telsoa014fcda012018-03-09 14:13:49 +000012# 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
Rob Hughesb0f1dd72019-07-23 15:34:01 +010037 # 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()
telsoa014fcda012018-03-09 14:13:49 +000042 endif()
43endmacro()