Jim Flynn | 6217c3d | 2022-06-14 10:58:23 +0100 | [diff] [blame] | 1 | # |
| 2 | # Copyright © 2018-2021 Arm Ltd and Contributors. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 5 | macro (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}>) |
| 10 | endmacro() |
| 11 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | # Checks if the given list contains an entry which matches the given regex. |
| 13 | function(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() |
| 21 | endfunction() |
| 22 | |
| 23 | macro(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 Hughes | b0f1dd7 | 2019-07-23 15:34:01 +0100 | [diff] [blame] | 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() |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | endif() |
| 43 | endmacro() |