CMake ERROR:could not find git for clone of xxx

本文介绍了一种在使用CMake构建项目过程中遇到的错误“could not find git for clone of ExternalProject_Discregrid”的解决方法。该问题可能由于网络限制导致CMake无法从GitHub克隆所需的外部项目。文中提供了解决方案,包括注释掉CMakeLists.txt中涉及git的部分,并手动下载缺失的库源码,然后更新本地路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

利用CMake编译源码,出现 CMake ERROR:could not find git for clone of ExternalProject_Discregrid.

之后查看项目目录下的CMakeLists.txt, 打开,发现:


(这些本来都是没有被注释过的,用来从repositories添加外部项目的,可能是没有翻墙的原因,此处虽然给出了GIT_REPOSITORY后面的git地址,CMake的时候仍然显示没有找到git)

【解决办法】

将上面的那些注释掉,直接手动从GitHub上下载缺的库源码,之后改成本地的路径,如下:


注意,此处的${CMAKE_SOURCE_DIR}即为你项目所在的编译目录,下载的源码放在这个目录下的一个子目录就好,之后再后面补全路径,如上。

最后,这么改了之后,就成功生成了项目文件,虽然VS一编译还是一堆错,不过好在CMake还是成功了。


tt@ubuntu:~/protobuf/carto_ws/src/cartographer/build$ cmake .. -- Build type: Release CMake Deprecation Warning at /usr/src/googletest/googlemock/CMakeLists.txt:41 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. CMake Deprecation Warning at /usr/src/googletest/googletest/CMakeLists.txt:48 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. CMake Error at CMakeLists.txt:32 (find_package): By not providing "Findabsl.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "absl", but CMake did not find one. Could not find a package configuration file provided by "absl" with any of the following names: abslConfig.cmake absl-config.cmake Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set "absl_DIR" to a directory containing one of the above files. If "absl" provides a separate development package or SDK, be sure it has been installed. -- Configuring incomplete, errors occurred! See also "/home/tt/protobuf/carto_ws/src/cartographer/build/CMakeFiles/CMakeOutput.log". See also "/home/tt/protobuf/carto_ws/src/cartographer/build/CMakeFiles/CMakeError.log". tt@ubuntu:~/pr
03-25
CMake Error at CMakeLists.txt:47 (find_package): By not providing "FindAntithftActvnSrv_proxy.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "AntithftActvnSrv_proxy", but CMake did not find one. Could not find a package configuration file provided by "AntithftActvnSrv_proxy" with any of the following names: AntithftActvnSrv_proxyConfig.cmake antithftactvnsrv_proxy-config.cmake Add the installation prefix of "AntithftActvnSrv_proxy" to CMAKE_PREFIX_PATH or set "AntithftActvnSrv_proxy_DIR" to a directory containing one of the above files. If "AntithftActvnSrv_proxy" provides a separate development package or SDK, be sure it has been installed. --- Failed <<< CCSMTailgateCtrlApp_business [4.41s, exited with code 1] ]0;colcon build [5/6 done] [0 ongoing]Summary: 4 packages finished [1min 9s] 1 package failed: CCSMTailgateCtrlApp_business 5 packages had stderr output: CCSMTailgateCtrlApp_business HWConversionBodyReqService_proxy TrOpenCtrlSrv_proxy VehMtnStsService_proxy VehicleModeManagementService_proxy 1 package not processed command error: /home/zkos_docker/sdk/cmd_tools/3.0.03.02.0000/zkos_app_builder.sh -i /home/zkos_docker/D/app_all/2_LockingGlobalApp/locking/LockingGlobalApp -o /home/zkos_docker/D/app_all/2_LockingGlobalApp/locking/LockingGlobalApp --retry_file /tmp/zkos_boot_cnt_13701741675355 --worker_num 12 --platform platform-x64-linux --prebuilt /home/zkos_docker/sdk/sdk/3.0.03.02.0000/platform-x64-linux-debug --prebuilt-ver 3.0.03.02.0000 --sdk-root-path D:/ZKOS_3.0_PLAT_CN_SDK_ALL_IN_ONE_03.02.0000_20250307-020013_R0137
03-12
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值