blob: 671bc7d97f2d5b8c23322db81baab9efcebdaf7c [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001macro (addDllCopyCommand target sourceDebug sourceRelease)
2 add_custom_command(TARGET ${target} POST_BUILD
3 COMMAND ${CMAKE_COMMAND} -E copy_if_different
4 "$<$<CONFIG:Debug>:${sourceDebug}>$<$<CONFIG:Release>:${sourceRelease}>$<$<CONFIG:RelWithDebInfo>:${sourceRelease}>$<$<CONFIG:MinSizeRel>:${sourceRelease}>"
5 $<TARGET_FILE_DIR:${target}>)
6endmacro()
7
telsoa014fcda012018-03-09 14:13:49 +00008# Checks if the given list contains an entry which matches the given regex.
9function(listContainsRegex result list regex)
10 set(${result} 0 PARENT_SCOPE)
11 foreach(element ${list})
12 if(${element} MATCHES ${regex})
13 set(${result} 1 PARENT_SCOPE)
14 return()
15 endif()
16 endforeach()
17endfunction()
18
19macro(addDllCopyCommands target)
20 if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
21 # Get the list of dependencies for the given target, so we can copy just the DLLs we need.
22 get_target_property(target_deps_str ${target} LINK_LIBRARIES)
23 set(target_deps)
24 list(APPEND target_deps ${target_deps_str})
25
26 cmake_policy(SET CMP0057 NEW) # Enable the "IN_LIST" operator
27
28 # armnn.dll
29 if ("armnn" IN_LIST target_deps)
30 addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnn>/armnn.dll" "$<TARGET_FILE_DIR:armnn>/armnn.dll")
31 endif()
32
Rob Hughesb0f1dd72019-07-23 15:34:01 +010033 # armnnTfLiteParser.dll
34 if ("armnnTfLiteParser" IN_LIST target_deps)
35 addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnnTfLiteParser>/armnnTfLiteParser.dll"
36 "$<TARGET_FILE_DIR:armnnTfLiteParser>/armnnTfLiteParser.dll")
37 endif()
telsoa014fcda012018-03-09 14:13:49 +000038 endif()
39endmacro()