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

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM