首页 > 解决方案 > Cmake编译器未知

问题描述

我正在尝试使用 cmake 在命令行上构建我的空项目。我的项目有这个准系统文件结构

-Project
 -Build
 -CMakeLists.txt (empty file)
 -main.cpp (contains hello world and nothing else)

我在项目的构建文件夹中运行命令“cmake ..”但是我收到了这个错误......


CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
  No CMAKE_C_COMPILER could be found.



CMake Error in CMakeLists.txt:
  No CMAKE_CXX_COMPILER could be found.

我已经安装了所有必需的 Visual Studio 模块,当我尝试通过 GUI 配置相同的 cmake 项目时,我没有同样的问题,可以通过 Visual Studio 打开项目。

标签: c++cmake

解决方案


我已经弄清楚了这个问题,在安装VS之前安装cmake是这个问题的主要原因。卸载cmake,重新安装然后重新启动您的电脑似乎可以解决问题。


推荐阅读