如何修复 CMake "make: *** No targets specified and no makefile found. Stop."

问题:

你正在尝试构建使用 CMake 构建系统的软件。

你正在尝试运行 make 来构建,但你看到此错误消息:

error.txt
make: *** No targets specified and no makefile found.  Stop.

解决方案

在运行 make 之前,你需要使用 CMake 配置你的构建。

最简单的方法是运行

cmake-config.sh
cmake .

通常你只需要为每个项目执行一次;当你运行 make 时,CMake 会自动检测 CMakeLists.txt 的更改。

之后,你可以再次运行 make。如果构建成功,你将看到类似这样的消息:

cmake-build-output.txt
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable main
[100%] Built target main

Check out similar posts by category: CMake