[CMake] prefer static to dynamic library on linux

Timenkov Yuri ytimenkov at parallels.com
Sat May 3 05:57:26 EDT 2008


On Thursday 01 May 2008 16:05:34 Bill Hoffman wrote:
> Leopold Palomo Avellaneda wrote:
> > A Dimecres 30 Abril 2008, John Doe va escriure:
> >> Hello,
> >>
> >> I just started using ubuntu linux and it is a pleasure to see that
> >> they provide both static and shared versions of libtcl8.4.  Is there a
> >> way to tell cmake to prefer the static version of this library, even
> >> if they are in the same directory, /usr/lib.
> >
> > On way to do it is to add "-static" to your CMAKE_EXE_LINKER_FLAGS. Then,
> > the linker will link use the static. Be carefull because, I think that it
> > will like _all_ in static.
>
> In CMake 2.6 if you give the full path to the static library then CMake
> will link that library.  CMake 2.6 uses full paths to libraries and does
> not break things into -L -l.
This is possible in CMake 2.4 too. There was a similar discussion in FindBoost 
thread. (http://www.cmake.org/pipermail/cmake/2008-April/020995.html)
Shortly, the trick is with playing with CMAKE_FIND_LIBRARY_SUFFIXES variable.

>
> -Bill
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake




More information about the CMake mailing list