aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2015-12-20 04:50:20 +0000
committerRui Abreu Ferreira <raf-ep@gmx.com>2016-08-07 21:57:28 +0100
commitdb7fdcd0bab8d5333bc89ab90ff256fcbdccde96 (patch)
tree341c6a8ca774164bc65dbbea720d293378d09f03 /cmake
parentf53c8258bed7354678e5e355efa2acc471deb11a (diff)
downloadrneovim-db7fdcd0bab8d5333bc89ab90ff256fcbdccde96.tar.gz
rneovim-db7fdcd0bab8d5333bc89ab90ff256fcbdccde96.tar.bz2
rneovim-db7fdcd0bab8d5333bc89ab90ff256fcbdccde96.zip
MSVC: Build third-party dependencies as release DLLs
Using /MT was causing issues when building luarocks, revert it, use the dynammic runtime and generate release DLLs for the dependencies. Some refactoring was required because for linking cmake looks for the import libraries (.lib) but on runtime executables we need the .dll files to be in the same folder. The DLLs are placed in the bin/ folder in order for nvim.exe to run during the build and tests. The install target installs the DLLs with the nvim binary - uses GetPrerequisites to find runtime DLLs. Some minor issues that required adjustments: - [MSVC] FindMsgpack.cmake now looks for msgpack_import.lib instead of msgpack.lib - The lua-client fails to find libuv.lib, instead it looks for uv.lib, added second copy of the file to the install command. - [MSVC] CMAKE_BUILD_TYPE affects the output paths, default to Release. Part of these changes are credited to @jasonwilliams200OK who fixed the third-party recipes to consistently use the same build type.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindMsgpack.cmake7
-rw-r--r--cmake/WindowsDllCopy.cmake30
2 files changed, 36 insertions, 1 deletions
diff --git a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake
index 015737d658..8881a34332 100644
--- a/cmake/FindMsgpack.cmake
+++ b/cmake/FindMsgpack.cmake
@@ -42,7 +42,12 @@ if(MSGPACK_USE_STATIC)
"${CMAKE_STATIC_LIBRARY_PREFIX}msgpack${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
-list(APPEND MSGPACK_NAMES msgpackc msgpack)
+if(MSVC)
+ # The import library for the msgpack DLL has a different name
+ list(APPEND MSGPACK_NAMES msgpack_import)
+else()
+ list(APPEND MSGPACK_NAMES msgpackc msgpack)
+endif()
find_library(MSGPACK_LIBRARY NAMES ${MSGPACK_NAMES}
# Check each directory for all names to avoid using headers/libraries from
diff --git a/cmake/WindowsDllCopy.cmake b/cmake/WindowsDllCopy.cmake
new file mode 100644
index 0000000000..fbbabf3a0c
--- /dev/null
+++ b/cmake/WindowsDllCopy.cmake
@@ -0,0 +1,30 @@
+# 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 -DBINARY=")
+endif()
+if(NOT DEFINED DST)
+ message(FATAL_ERROR "Missing required arguments -DDST=")
+endif()
+if(NOT DEFINED CMAKE_PREFIX_PATH)
+ message(FATAL_ERROR "Missing required arguments -DCMAKE_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()
+
+ message("Copying ${DLL_NAME} to ${DST}")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${DLL_PATH} ${DST})
+ unset(DLL_PATH CACHE)
+endforeach()
+