【发布时间】:2011-12-09 00:28:40
【问题描述】:
我正在使用 cmake 编译我的一个工作项目,这是交易
-
client/
CMakeLists.txt
server/
CMakeLists.txt
libs/
libstuff/
CMakeLists.txt
CMakeLists.txt
所以我希望能够单独编译每个子项目,并从根文件夹构建客户端和服务器。
假设客户端和服务器需要 libstuff。
我尝试在客户端和服务器 CMakeLists.txt 中使用带有 lib 路径的“add_subdirectory”,当您编译服务器或客户端时它可以工作,但如果您尝试从根目录运行:
CMake Error at common/libplugin/CMakeLists.txt:33 (ADD_LIBRARY):
add_library cannot create target "plugin" because another target with the
same name already exists. The existing target is a static library created
in source directory "/home/adrien/git/r-type/common/libplugin". See
documentation for policy CMP0002 for more details.
所以我是一个带 cmake 的新人,我不确定我应该做什么,我应该使用 add_dependencies 吗?
感谢您的帮助,
【问题讨论】:
-
“单独编译”是什么意思?如果构建VS项目或者makefile,可以选择编译哪个项目...