我试着理解以前的帮助:
所以我用gtest写了一个非常简单的项目用例。
目前我有:
% cat CMakeLists.txt cmake_minimum_required(VERSION 3.24) project(p) include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # release-1.12.1 OVERRIDE_FIND_PACKAGE FetchContent_MakeAvailable(googletest) if(TARGET GTest::gtest_main) message("Target was found") endif() find_package(GTest 1.12.1 REQUIRED) # Now make sure hwy uses our gtest 1.12.1: set(HWY_SYSTEM_GTEST ON CACHE BOOL "") FetchContent_Declare( GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 22e3d7276f4157d4a47586ba9fd91dd6303f441a # 1.0.1 FetchContent_MakeAvailable(hwy)
如果我运行它,我得到的是:
$ cmake ..