更新时间:2022-02-25 06:13:47
一个简单的解决方案是使用 if
来保护客户端和服务器CMake列表文件中的 add_subdirectory
调用。 目标是有条件的,即:
A simple solution is to guard the add_subdirectory
calls in both the client and the server CMake list file with an if
using a TARGET conditional, i.e.:
if (NOT TARGET plugin)
add_subdirectory("${CMAKE_SOURCE_DIR}/common/libplugin")
endif()
这可以防止多次添加 libplugin
子目录。
This prevents the libplugin
sub-directory from being added more than once.