cmake版本3.22.1,cmake_minimum_required(VERSION 填几)
时间: 2024-08-14 22:03:20 浏览: 70
`cmake_minimum_required` 是 CMake 中的一项配置指令,用于设定构建系统的最低支持 CMake 版本。如果你的项目使用的 CMake 版本是 3.22.1,那么在 `CMakeLists.txt` 文件中设置 `cmake_minimum_required` 时,应该填 `3.22`,因为 CMake 版本号通常只保留两位小数表示主要和次要版本,例如 3.22 表示至少需要 CMake 3.22.x(x 可以为任意的小版本更新)。完整的行看起来应该是这样的:
```cmake
cmake_minimum_required(VERSION 3.22)
```
这样做的目的是确保使用较旧版本 CMake 构建项目的用户能够收到关于版本过低的警告信息,并告知他们升级到更高版本的 CMake 以支持该项目。
相关问题
-- cmake version 3.22.1 CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to te
ll CMake the minimum required version for your project. For example, if you want to set the minimum required version to 3.22.1, you can modify your `CMakeLists.txt` file as follows:
```cmake
cmake_minimum_required(VERSION 3.22.1)
```
By specifying the minimum required version, you ensure that your project is compatible with that version or any higher versions of CMake. This warning is to inform you that compatibility with CMake versions older than 2.8.12 will be removed in the future.
(base) lmj@lmj-Ubuntu:/opt/sdk.20230309/horus_sdk_release/build$ sudo cmake ../ -- cmake version 3.22.1 CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:11 (project): The CMAKE_C_COMPILER: arm-linux-gnueabihf-gcc is not a full path and was not found in the PATH. Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. CMake Error at CMakeLists.txt:11 (project): The CMAKE_CXX_COMPILER: arm-linux-gnueabihf-g++ is not a full path and was not found in the PATH. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "/opt/sdk.20230309/horus_sdk_release/build/CMakeFiles/CMakeOutput.log". See also "/opt/sdk.20230309/horus_sdk_release/build/CMakeFiles/CMakeError.log".
根据你提供的错误信息,看起来 CMake 在配置项目时无法找到 C 和 C++ 编译器。这可能是由于缺少路径或编译器未正确安装所致。你可以尝试以下解决方法:
1. 确保你已经正确安装了 `arm-linux-gnueabihf-gcc` 和 `arm-linux-gnueabihf-g++` 编译器。你可以通过在终端中运行 `arm-linux-gnueabihf-gcc --version` 和 `arm-linux-gnueabihf-g++ --version` 来检查它们是否已安装。
2. 如果编译器已正确安装,但仍然无法找到,请尝试使用绝对路径设置环境变量 `CC` 和 `CXX`。例如,如果编译器的完整路径为 `/path/to/arm-linux-gnueabihf-gcc` 和 `/path/to/arm-linux-gnueabihf-g++`,你可以在终端中运行以下命令:
```
export CC=/path/to/arm-linux-gnueabihf-gcc
export CXX=/path/to/arm-linux-gnueabihf-g++
```
然后再次运行 `sudo cmake ../`。
3. 如果以上方法仍然无效,你可以尝试编辑 CMakeLists.txt 文件,在文件开头添加以下内容,指定编译器的完整路径:
```
set(CMAKE_C_COMPILER "/path/to/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "/path/to/arm-linux-gnueabihf-g++")
```
然后保存文件并再次运行 `sudo cmake ../`。
希望这些方法能够解决你的问题。如果你有任何其他疑问,请随时提问。
阅读全文