tags:

views:

136

answers:

2

I'm working on a project that's link against SOCI, which comes as both static and dynamic libraries. I'd like CMake to choose the static version when available, and dynamic otherwise. Is there a reasonable way to do this in CMake? I've come up with nothing looking through the docs so far.

+1  A: 

Sounds like you need to add CMAKE_EXE_LINKER_FLAGS=-static

hwatkins
However, don't forget it is GCC specific solution. Though, OP doesn't specify what compiler/linker/system is under consideration.
mloskot
A: 

...and don't forget that besides being a gcc specific solution, gcc will fail to link if you pass -static but not all libraries provided for linkage are static - which can easily happen if you use the FindXXXX.cmake modules.

pszilard