centos安装cmake-3.22版本

命令如下:

wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1.tar.gz
tar -xzvf cmake-3.22.1.tar.gz && cd cmake-3.22.1/ && ./bootstrap && gmake && gmake install

设置环境PATH,修改~/.bashrc,添加 export PATH="$PATH:/usr/local/bin"

并重新更新环境变量即可

source ~/.bashrc
[root@bogon cmake]#cmake -version
version 3.22.1

suite maintained and supported by Kitware (kitware.com/cmake).

安装OK

测试:

#include <iostream>
int main(int argc, char *argv[])
{
   std::cout << "Hello CMake!" << std::endl;
   return 0;
}

 CMakeLists.txt

# Set the minimum version of CMake that can be used
# To find the cmake version run
# $ cmake --version
cmake_minimum_required(VERSION 3.5)

# Set the project name
project (hello_cmake)

# Add an executable
add_executable(hello_cmake main.cpp)

 执行命令

mkdir build && cd build && cmake ../ && make

 Link ok。Enjoy

示例:

https://github.com/ttroy50/cmake-examples

  

posted @ 2021-12-14 09:42  风吹大风车  阅读(2135)  评论(0)    收藏  举报