blob: 2a807bed40d87d1a49d3c34439e2da858ece5eb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
From 49f7f7566ecd45ce87be07ac46bb27cf2abf9c3c Mon Sep 17 00:00:00 2001
From: Samuel Martin <s.martin49@gmail.com>
Date: Sun, 31 Aug 2014 10:08:47 +0200
Subject: [PATCH] cmake: make sure the libxml2 module correctly set all ldflags
in case of static link
libxml2 dependencies against zlib and libiconv are optional.
When executing a statically linked build, the default libxml2 CMake
module fails to get the libxml2 dependencies (both the required and
optional ones); so the link phase fails.
However, pkg-config correctly gives these dependencies, even for static
build. So, extend the libxml2 library list with what the pkg_check_modules
CMake primitive (which will uses pkg-config) found.
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
cmake/modules/FindLibXml2.cmake | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/cmake/modules/FindLibXml2.cmake b/cmake/modules/FindLibXml2.cmake
index 8d3c77e..19bc930 100644
--- a/cmake/modules/FindLibXml2.cmake
+++ b/cmake/modules/FindLibXml2.cmake
@@ -39,6 +39,19 @@ FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2
${PC_LIBXML_LIBRARY_DIRS}
)
+# Make sure we get all ldflags in case of static link
+IF(NOT BUILD_SHARED_LIBS)
+ FOREACH(_lib ${PC_LIBXML_STATIC_LIBRARIES})
+ STRING(TOUPPER ${_lib} _Ulib)
+ FIND_LIBRARY(_${_Ulib}_LIBRARIES NAMES ${_lib} lib${_lib}
+ HINTS
+ ${PC_LIBXML_LIBDIR}
+ ${PC_LIBXML_LIBRARY_DIRS}
+ )
+ LIST(APPEND LIBXML2_LIBRARIES ${_${_Ulib}_LIBRARIES})
+ ENDFOREACH()
+ENDIF(NOT BUILD_SHARED_LIBS)
+
FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint)
# for backwards compat. with KDE 4.0.x:
SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}")
--
2.1.0
|