Making CMake choose static linkage when possible?

2019-04-17 12:51发布

问题:

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:

Sounds like you need to add CMAKE_EXE_LINKER_FLAGS=-static



标签: c++ linker cmake