[CMake] FindX11 and FindLibXml2: different behaviors when using static/dynamic libraries

olivier.pierard at cenaero.be olivier.pierard at cenaero.be
Tue Nov 10 17:29:19 EST 2009


Dear all,

For the compilation of my project, I want to provide a static or dynamic
linked final executable (e.g.: linking preferentially with .a or .so
libraries on Linux).  For this, I set up a cache variable which enables to
modify CMAKE_FIND_LIBRARY_SUFFIXES (".a;.so" or ".so;.a").  By the way, I
don't know if that's the good way ?

In a find module that I wrote myself, I call FindX11.cmake and
FindXml2.cmake (provided by my distribution - suse 10.3).  Everything works
perfectly for dynamically linked libraries but fails at final link when
using static link.  Among the numerous errors, I can find things like
-
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/libX11.a(xcb_lock.o):
In function `_XPutXCBBuffer':
(.text+0xd9): undefined reference to `xcb_get_request_sent'
-
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../lib64/libxml2.a(threads.o):
In function `xmlInitThreads':
(.text+0x3a): undefined reference to `pthread_key_create'

I guess it means that a static library is missing in the final link.  But
such dependencies shouldn't be taken by the corresponding find Module ?  In
that case, could you provide me a reference site where I can find reliable
find modules.  Or Am I missing something in my own find module ?

Thanks for your help !

Olivier


More information about the CMake mailing list