[CMake] linking static vs dynamic

Alexander Neundorf a.neundorf-work at gmx.net
Sat Feb 12 15:35:29 EST 2011


On Saturday 12 February 2011, Dominik Szczerba wrote:
> I never actually saw a solution to this problem in cmake:
> I need to link (independent constraint from above) with libguide.a and
> not libguide.so (in intel compiler, does not matter much), but both
> are available, and cmake always takes the shared one when given
> "guide" as the desired library to be linked.
> Is there an elegant way of static linking (other than -static passed
> to the linker for static linking of everything) of this particular lib
> other than hacking (like deleting the .so from the folder)?
> PS. This opens up a box of other related problems, like the
> (independent) need to link some parts statically on exotic HPC
> systems.

Using the full name of the library in the find_library call:
find_library(GUIDE_LIBRARY libguide.a)
instead of 
find_library(GUIDE_LIBRARY guide)
should work.

Alex


More information about the CMake mailing list