CMake Error at /usr/local/lib/cmake/Ceres/FindGlog.cmake:349 (add_library):
add_library cannot create imported target "glog::glog" because another
target with the same name already exists.
SOLUTION:在add glog::glog target之前判断一下是否target到glog::glog了,如果没有target到,再添加glog::glog target。在/usr/local/lib/cmake/Ceres下的FindGlog.cmake文件中的
# add glog::glog target
add_library(glog::glog INTERFACE IMPORTED)
target_include_directories(glog::glog INTERFACE ${GLOG_INCLUDE_DIRS})
target_link_libraries(glog::glog INTERFACE ${GLOG_LIBRARY})
修改为:
# add glog::glog target
if(NOT TARGET glog::glog)
add_library(glog::glog INTERFACE IMPORTED)
target_include_directories(glog::glog INTERFACE ${GLOG_INCLUDE_DIRS})
target_link_libraries(glog::glog INTERFACE ${GLOG_LIBRARY})
endif()