telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | macro (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}>) |
| 6 | endmacro() |
| 7 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 8 | # Checks if the given list contains an entry which matches the given regex. |
| 9 | function(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() |
| 17 | endfunction() |
| 18 | |
| 19 | macro(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 Hughes | b0f1dd7 | 2019-07-23 15:34:01 +0100 | [diff] [blame] | 33 | # 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() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 38 | endif() |
| 39 | endmacro() |