From: Roland Schulz Date: Tue, 17 Mar 2015 03:27:01 +0000 (-0700) Subject: Fix linking with static libxml2 X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=94a2a8aee0d8449de43519cd05b0ecd38b10a47c;p=alexxy%2Fgromacs.git Fix linking with static libxml2 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ffab22d20a..4a2650bb7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ######################################################################## diff --git a/cmake/gmxTestLibXml2.cmake b/cmake/gmxTestLibXml2.cmake index 48e1c21d66..7e5387c0c9 100644 --- a/cmake/gmxTestLibXml2.cmake +++ b/cmake/gmxTestLibXml2.cmake @@ -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