Fix RAPTOR::RAPTOR linking: propagate libxml2 (shared) dependency - #17
Open
Astrid3333 wants to merge 1 commit into
Open
Fix RAPTOR::RAPTOR linking: propagate libxml2 (shared) dependency#17Astrid3333 wants to merge 1 commit into
Astrid3333 wants to merge 1 commit into
Conversation
Raptor built with libxml2 SAX2 support leaves xmlSAX2*, xmlParseChunk, etc. undefined at link time because RAPTOR::RAPTOR did not declare libxml2 as an interface link dependency. Static libxml2 also pulls in zlib/lzma/icu transitively, so prefer the shared library explicitly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When building COPASI with
COPASI_USE_RAPTOR=ONagainst a Raptor build that includes libxml2 SAX2 support, linkingCopasiSE(and any other target linkingRAPTOR::RAPTOR) fails with undefined references toxmlSAX2*,xmlParseChunk,xmlFree, etc.This happens because
FindRAPTOR.cmakecreates theRAPTOR::RAPTORimported target without declaring libxml2 as an interface link dependency, even though the underlyinglibraptor.awas built with libxml2 support.Additionally, on systems where
find_package(LibXml2)resolves to the staticlibxml2.a(e.g. recent Debian/Ubuntu with both static and shared libxml2 installed), linking fails a second time with undefined references to zlib (gzopen,gzread...), liblzma (lzma_code...), and ICU (ucnv_open_74...) symbols, since those transitive static dependencies aren't propagated automatically.Fix
In
CMakeModules/FindRAPTOR.cmake:find_library(LIBXML2_LIBRARY NAMES libxml2.so xml2)before callingfind_package(LibXml2 QUIET), avoiding the static-linking transitive dependency problem entirely.LibXml2::LibXml2toRAPTOR::RAPTOR'sINTERFACE_LINK_LIBRARIESso all consumers of the target (libCOPASISE-core,libCOPASISE-static,libCOPASISE-shared) automatically get the correct link flags.Testing
Verified on Ubuntu/Linux Mint (GCC 13.3.0) with a fresh
copasi-dependenciesbuild (Raptor built from source with libxml2 support) —CopasiSEnow configures and links cleanly with no manual linker flags required, whereas previouslyCMAKE_EXE_LINKER_FLAGS"=-lxml2"had to be passed manually as a workaround.