Fix linking with static libxml2
authorRoland Schulz <roland@utk.edu>
Tue, 17 Mar 2015 03:27:01 +0000 (20:27 -0700)
committerRoland Schulz <roland@utk.edu>
Tue, 17 Mar 2015 08:34:19 +0000 (04:34 -0400)
static libxml2 can have a dependency on libz. This uses the same approach
as we did prior for fftw. Always add libz to required libraries (even for
dynamic when not needed) when libz is found.

Change-Id: I75291508d7f36921793e01f920fab644e0324369

CMakeLists.txt
cmake/gmxTestLibXml2.cmake

index ffab22d20af413fdb33981ee3c8966df72684cad..4a2650bb7d30b93a4d78c55870ca0880d01f54a6 100644 (file)
@@ -473,6 +473,11 @@ include(gmxManageSharedLibraries)
 # Find external packages                                               #
 ########################################################################
 
+# TNG wants zlib if it is available. And static libxml2 might have a dependency
+find_package(ZLIB QUIET)
+include(gmxTestZLib)
+gmx_test_zlib(HAVE_ZLIB)
+
 # Unconditionally find the package, as it is also required for unit
 # tests. This exports LIBXML2_FOUND, which we should not use because
 # it does not tell us that linking will succeed. Instead, we test that
@@ -608,13 +613,6 @@ if (GMX_BUILD_UNITTESTS AND NOT HAVE_LIBXML2)
         "Either set GMX_BUILD_UNITTESTS=OFF or tell CMake how to find a working version of libxml2.")
 endif()
 
-if(GMX_USE_TNG AND NOT GMX_EXTERNAL_TNG)
-    # TNG wants zlib if it is available
-    find_package(ZLIB QUIET)
-    include(gmxTestZLib)
-    gmx_test_zlib(HAVE_ZLIB)
-endif()
-
 ########################################################################
 # Generate development version info for cache
 ########################################################################
index 48e1c21d661875fc1190684154ac2482d04287a4..7e5387c0c9b09e681f6fce9b8a59d739717e0098 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014, by the GROMACS development team, led by
+# Copyright (c) 2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -50,6 +50,9 @@ function(GMX_TEST_LIBXML2 VARIABLE)
         if(_do_libxml2_recompile)
             unset(LIBXML2_LINKS_OK CACHE)
         endif()
+        if(HAVE_ZLIB)
+            set(LIBXML2_LIBRARIES "${LIBXML2_LIBRARIES}" z PARENT_SCOPE) #not needed for dynamic but does not hurt
+        endif()
         check_library_exists("${LIBXML2_LIBRARIES}" "xmlTextWriterEndAttribute" "" LIBXML2_LINKS_OK)
         if(LIBXML2_LINKS_OK)
             #check that xml headers can be included