【问题标题】:using CMake to build Google Test使用 CMake 构建 Google Test
【发布时间】:2025-12-11 09:15:02
【问题描述】:

我正在尝试使用 CMake 构建 Google Test。 正如 Google Test 的 README 中提到的, 我已发出以下命令:

  mkdir mybuild       # Create a directory to hold the build output.
  cd mybuild
  cmake D:\gtest-1.6.0 # (in the README this was set as:cmake ${GTEST_DIR}, but since on my machine D:\gtest-1.6.0 is where I have downloaded gtest, I have used that in command prompt.

这是我得到的错误:

有什么帮助吗?任何帮助将不胜感激,因为我坚持下去并且无法继续前进......谢谢。 附言。我的机器上安装了 Visual Studio 10。

【问题讨论】:

    标签: c++ cmake googletest


    【解决方案1】:

    如果您将 Visual c++ 编译器与 cmake 一起使用,则必须从 Visual c++ 命令提示符启动它。否则 cmake 将找不到你的编译器。

    【讨论】:

    • 嗨,是的,我已经安装了 Visual Studio 10。我也下载了 CMake 2.6。附言。什么是“开发命令提示符”?
    • 我编辑了我的答案。您可以在 Visual Studio 应用程序文件夹中找到它。有关信息,请参阅msdn.microsoft.com/en-us/library/ms235639%28v=vs.80%29.aspx
    • 嗨,谢谢,但即使我使用 Visual Studio 命令提示符 (2010),我也会遇到同样的问题。 : ((
    • 请发布 D:\gtest-1.6.0\CMakeLists.txt 包含的内容。
    • 您好,请看这里:filedropper.com/cmakelists - 太大,无法在此处复制和粘贴..