banner.gif adie's blog
主页 博客 胭脂泪,相留醉,几时重,自是人生长恨水长东
统计
日志总数: 128
评论总数: 123
日志分类
日志归档
最近日志
最近评论
订阅
rss2.gif

atom.gif

google_rss
yc.gif 【编程】 阅读 62 次

VC2022 CMake 配置 GTest

2024-10-27 14:13:36

编译程序时遇到错误:

| CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:230 (message):

| Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR

| GTEST_MAIN_LIBRARY)

| Call Stack (most recent call first):

| C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)

| C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.29/Modules/FindGTest.cmake:270 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)

| third_party/testing.cmake:57 (find_package)

| CMakeLists.txt:387 (include)

 

检查 VS 中是安装了 Google Test 的:

或许这个只能用于 IDE, CMake 中无法使用吧.

重新安装:

1. 下载源代码

git clone git@github.com:google/googletest.git googletest

2. 使用 x64 Native Tools Command Prompt for VS 2022 进入源代码目录:
mkdir build
cd build
cmake ..
cmake --build . --config RelWithDebInfo
cmake -DBUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=D:/builds/googletest/setupfiles  -P cmake_install.cmake

set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;D:\builds\googletest\setupfiles

echo find_package(GTest REQUIRED) > test.txt
cmake -N -P test.txt

▲评论

X 正在回复:
姓 名: 留下更多信息
性 别:
邮 件:
主 页:
Q Q:
来 自:
职 业:
评 论:
验 证:


Valid HTML 4.01 Strict Valid CSS!
Copyleft.A!die Software Studio.ADSS
Power by webmaster@adintr.com