]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
win*.sh,cmake: Fix Windows linking errors 41217/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 7 May 2021 09:23:30 +0000 (09:23 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 7 May 2021 09:23:30 +0000 (09:23 +0000)
The Windows build is hitting linking errors after
bumping the Boost version to 1.75. The issue is that Boost
is now setting the zlib dependecy using INTERFACE_LINK_LIBRARIES,
which means that it's no longer located using the standard
"find_package" mechanism.

In order for the linker to locate zlib, we'll add it to the
linker search path.

[1] https://github.com/boostorg/boost_install/issues/47

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
CMakeLists.txt
win32_build.sh

index ac8fee04d1d63e1745ff140bb870c89eb5e179f3..55647fa24aba6a7f969617f051bdda74380470ae 100644 (file)
@@ -52,6 +52,7 @@ if(MINGW)
   set(CMAKE_CXX_LINK_EXECUTABLE
     "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
 
+  link_directories(${MINGW_LINK_DIRECTORIES})
 endif()
 
 option(WITH_CCACHE "Build with ccache.")
index 9e88df93f815e0326a1f1903b58ecb7f2c14984c..d8b5f76f9818dedb38ca81ddf1a1eddb719d98a4 100755 (executable)
@@ -96,6 +96,12 @@ dokanLibDir="${depsToolsetDir}/dokany/lib"
 depsDirs="$lz4Dir;$curlDir;$sslDir;$boostDir;$zlibDir;$backtraceDir;$snappyDir"
 depsDirs+=";$winLibDir"
 
+# Cmake recommends using CMAKE_PREFIX_PATH instead of link_directories.
+# Still, some library dependencies may not include the full path (e.g. Boost
+# sets the "-lz" flag through INTERFACE_LINK_LIBRARIES), which is why
+# we have to ensure that the linker will be able to locate them.
+linkDirs="$zlibDir/lib"
+
 lz4Lib="${lz4Dir}/lib/dll/liblz4-1.dll"
 lz4Include="${lz4Dir}/lib"
 curlLib="${curlDir}/lib/libcurl.dll.a"
@@ -149,6 +155,7 @@ fi
 # symbols. Until we fix the dependencies (which are either unspecified
 # or circular), we'll have to stick to static linking.
 cmake -D CMAKE_PREFIX_PATH=$depsDirs \
+      -D MINGW_LINK_DIRECTORIES="$linkDirs" \
       -D CMAKE_TOOLCHAIN_FILE="$MINGW_CMAKE_FILE" \
       -D WITH_LIBCEPHSQLITE=OFF \
       -D WITH_RDMA=OFF -D WITH_OPENLDAP=OFF \