neovim/cmake/WindowsDllCopy.cmake
Enan Ajmain b4a92309f8
ci: print DLL copy messages only in CI environment (#22260)
In Windows, library DLL's are copied in the building process, and a message for each copy is printed. This is useful to have in the log of CI, but annoying to see when you're building and rebuilding nvim constantly. Work around this issue by only enabling the messages on CI.
2023-02-14 18:58:38 +01:00

32 lines
1.0 KiB
CMake

# In Windows we need to find dependency DLLs and install them along with our
# binaries. This script uses the following variables:
#
# - BINARY: The binary file whose dependencies need to be installed
# - DST: The destination path
# - CMAKE_PREFIX_PATH: A list of directories to search for dependencies
if(NOT DEFINED BINARY)
message(FATAL_ERROR "Missing required argument -D BINARY=")
endif()
if(NOT DEFINED DST)
message(FATAL_ERROR "Missing required arguments -D DST=")
endif()
if(NOT DEFINED CMAKE_PREFIX_PATH)
message(FATAL_ERROR "Missing required arguments -D CMAKE_PREFIX_PATH=")
endif()
include(GetPrerequisites)
get_prerequisites(${BINARY} DLLS 1 1 "" "${CMAKE_PREFIX_PATH}")
foreach(DLL_NAME ${DLLS})
find_program(DLL_PATH ${DLL_NAME})
if(NOT DLL_PATH)
message(FATAL_ERROR "Unable to find dependency ${DLL_NAME}")
endif()
if($ENV{CI} MATCHES "true")
message("Copying ${DLL_NAME} to ${DST}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${DLL_PATH} ${DST})
unset(DLL_PATH CACHE)
endforeach()