Link static library using CMake

孤者浪人 提交于 2019-11-29 15:02:19
ComicSansMS

You cannot link libraries into libraries directly.

Some compilers allow you to do this (e.g. MS Visual Studio has an option), but others don't, which is why CMake also won't allow it. See this answer for what your options are to deal with this.

target_link_libraries(my_target PRIVATE lib_name${CMAKE_STATIC_LIBRARY_SUFFIX})

I have libpq.a and libpq.so (postgres) and with this solution it links to the static library so I can execute my_target on a clean OS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!