意外"No cmake_minimum_required command is present",但似乎存在
Unexpected "No cmake_minimum_required command is present", but it seems to be present
问题
我有一个顶层 CMakeLists.txt
项目,如下所示:
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
...
set(PACKAGE_NAME "foo")
...
project(${PACKAGE_NAME} C CXX Rust)
当我从顶层 运行 cmake3 -B build .
时,我收到很多警告和错误,包括:
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.
CMake Error at CMakeLists.txt:25 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:26 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:27 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:28 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:29 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:30 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:31 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:32 (install):
install PROGRAMS given no DESTINATION!
CMake Error at CMakeLists.txt:33 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:34 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:36 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:37 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:38 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:39 (install):
install PROGRAMS given no DESTINATION!
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.17)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
我真的不明白的是 CMake Error at CMakeLists.txt:39
之类的错误中的行号(例如 39)
似乎与我创建的 CMakeLists.txt 中的行不一致(有几行只是空行)。
问题:
- 为什么我得到的错误输出似乎与我创建的
CMakeLists.txt
不一致?
如果您收到与您正在查看的 CMakeLists.txt
文件不对应的错误输出的意外错误,这可能是因为 CMake 缓存了一些来自先前构建尝试的构建信息。
您可以通过从项目中删除任何 CMakeCache.txt
( 而不是 CMakeLists.txt
)文件并重新构建来解决此错误。
问题
我有一个顶层 CMakeLists.txt
项目,如下所示:
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
...
set(PACKAGE_NAME "foo")
...
project(${PACKAGE_NAME} C CXX Rust)
当我从顶层 运行 cmake3 -B build .
时,我收到很多警告和错误,包括:
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.
CMake Error at CMakeLists.txt:25 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:26 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:27 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:28 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:29 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:30 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:31 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:32 (install):
install PROGRAMS given no DESTINATION!
CMake Error at CMakeLists.txt:33 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:34 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:36 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:37 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:38 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:39 (install):
install PROGRAMS given no DESTINATION!
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.17)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
我真的不明白的是 CMake Error at CMakeLists.txt:39
之类的错误中的行号(例如 39)
似乎与我创建的 CMakeLists.txt 中的行不一致(有几行只是空行)。
问题:
- 为什么我得到的错误输出似乎与我创建的
CMakeLists.txt
不一致?
如果您收到与您正在查看的 CMakeLists.txt
文件不对应的错误输出的意外错误,这可能是因为 CMake 缓存了一些来自先前构建尝试的构建信息。
您可以通过从项目中删除任何 CMakeCache.txt
( 而不是 CMakeLists.txt
)文件并重新构建来解决此错误。