我正在编写一个 CMakeLists.txt 文件来构建我的 C++ 项目,该项目由
- libhybris.so:具有一些导出功能的共享库。
- hybris:链接到 libhybris.so 的可执行文件
- 一组链接到 libhybris.so 的各种共享库
问题是,libhybris.so 依赖于 libpcre(用于正则表达式功能),所以我有以下语句:
# libhybris.so generation
add_library( libhybris
SHARED
${LIB_SOURCES} )
...
# Needed libraries
target_link_libraries( libhybris
dl
pcre
pthread
readline )
第 3 点中的共享库之一称为 pcre.so,所以我也有以下内容:
add_library( pcre SHARED ${PCRE_SOURCES} )
...
target_link_libraries( pcre
dl
pcre
curl
pthread
readline
ffi
libhybris )
因此,当我运行“cmake .”时,出现以下错误:
-- Configuring done
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
"libhybris" of type SHARED_LIBRARY
depends on "pcre"
"pcre" of type SHARED_LIBRARY
depends on "libhybris"
At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries.
因为 CMake 认为 libhybris.so pcre 依赖项(系统 libpcre.so)与我的 pcre.so 相同,但显然不是。
如何在不更改 pcre.so 名称的情况下解决此问题?