使CMake选择静态连接可能吗?
问题描述:
我正在开发一个与SOCI链接的项目,它既是静态库也是动态库。我想CMake选择静态版本,如果可用,否则动态。有没有合理的方法来做这个在CMake?
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.
答
听起来像您需要添加CMAKE_EXE_LINKER_FLAGS = -static
Sounds like you need to add CMAKE_EXE_LINKER_FLAGS=-static