我正在使用具有以下依赖项的项目:
grpc
- 谷歌测试
- 基准
同时我的项目有基准。
当我使用声明以下依赖项时,FetchContent出现以下错误:
add_library cannot create target "benchmark" because another target
with the same name already exists. The existing target is an executable
created in source directory
我CMakeLists.txt的是:
cmake_minimum_required(VERSION 3.15)
project(dahj)
set(CMAKE_CXX_STANDARD 14)
include(FetchContent)
FetchContent_Declare(
grpc
GIT_REPOSITORY https://github.com/grpc/grpc.git
GIT_TAG v1.17.2
)
FetchContent_MakeAvailable(grpc)
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.5.0
)
FetchContent_MakeAvailable(benchmark)
add_executable(dahj main.cpp grpc++)
我知道我可以使用基准而不获取它,而只需链接它。但是,如果grpc决定取消基准作为依赖项,它会破坏我的构建。有一个更好的方法吗?