WindowsDllCopy.cmake (1028B)
1 # In Windows we need to find dependency DLLs and install them along with our 2 # binaries. This script uses the following variables: 3 # 4 # - BINARY: The binary file whose dependencies need to be installed 5 # - DST: The destination path 6 # - CMAKE_PREFIX_PATH: A list of directories to search for dependencies 7 8 if(NOT DEFINED BINARY) 9 message(FATAL_ERROR "Missing required argument -D BINARY=") 10 endif() 11 if(NOT DEFINED DST) 12 message(FATAL_ERROR "Missing required arguments -D DST=") 13 endif() 14 if(NOT DEFINED CMAKE_PREFIX_PATH) 15 message(FATAL_ERROR "Missing required arguments -D CMAKE_PREFIX_PATH=") 16 endif() 17 18 include(GetPrerequisites) 19 get_prerequisites(${BINARY} DLLS 1 1 "" "${CMAKE_PREFIX_PATH}") 20 foreach(DLL_NAME ${DLLS}) 21 find_program(DLL_PATH ${DLL_NAME}) 22 if(NOT DLL_PATH) 23 message(FATAL_ERROR "Unable to find dependency ${DLL_NAME}") 24 endif() 25 26 if(CI_BUILD) 27 message("Copying ${DLL_NAME} to ${DST}") 28 endif() 29 execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${DLL_PATH} ${DST}) 30 unset(DLL_PATH CACHE) 31 endforeach()