[libxml2] Add missing compile definition for static builds to CMake



commit 7a62870a3cc7173e61132a8d633f0bf078512e4b
Author: Markus Rickert <rickert fortiss org>
Date:   Thu Nov 19 22:06:23 2020 +0100

    Add missing compile definition for static builds to CMake

 CMakeLists.txt                | 4 ++++
 libxml2-config.cmake.cmake.in | 3 +++
 2 files changed, 7 insertions(+)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c918125a..1148e3e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -424,6 +424,10 @@ endif()
 
 add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS})
 
+if(NOT BUILD_SHARED_LIBS)
+       target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC)
+endif()
+
 if(LIBXML2_WITH_THREADS)
        target_compile_definitions(LibXml2 PRIVATE _REENTRANT)
        if(WIN32)
diff --git a/libxml2-config.cmake.cmake.in b/libxml2-config.cmake.cmake.in
index 6e6fc7ab..4dec6275 100644
--- a/libxml2-config.cmake.cmake.in
+++ b/libxml2-config.cmake.cmake.in
@@ -8,6 +8,7 @@
 #
 #   LIBXML2_INCLUDE_DIRS      - Directory where libxml2 headers are located.
 #   LIBXML2_LIBRARIES         - xml2 libraries to link against.
+#   LIBXML2_DEFINITIONS       - the compiler switches required for using LibXml2
 #   LIBXML2_VERSION_MAJOR     - The major version of libxml2.
 #   LIBXML2_VERSION_MINOR     - The minor version of libxml2.
 #   LIBXML2_VERSION_PATCH     - The patch version of libxml2.
@@ -62,6 +63,8 @@ if(@LIBXML2_WITH_ICONV@)
 endif()
 
 if(NOT @BUILD_SHARED_LIBS@)
+  set(LIBXML2_DEFINITIONS -DLIBXML_STATIC)
+
   if(@LIBXML2_WITH_THREADS@)
     find_dependency(Threads)
     list(APPEND LIBXML2_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]