当前位置 博文首页 > 小龙狗的博客:CentOS下CMake源码编译安装

    小龙狗的博客:CentOS下CMake源码编译安装

    作者:[db:作者] 时间:2021-07-09 22:02

    1. 安装

    执行命令

    [root@VM-0-9-centos ~]# cd /home
    [root@VM-0-9-centos home]# mkdir cmake
    [root@VM-0-9-centos home]# cd cmake
    [root@VM-0-9-centos cmake]# wget https://github.com/Kitware/CMake/releases/download/v3.19.0-rc3/cmake-3.19.0-rc3-Linux-x86_64.tar.gz
    [root@VM-0-9-centos cmake]# tar -xvf cmake-3.19.0-rc3/
    [root@VM-0-9-centos cmake]# cd cmake-3.19.0-rc3/
    [root@VM-0-9-centos cmake-3.19.0-rc3]# ./bootstrap
    [root@VM-0-9-centos cmake-3.19.0-rc3]# gmake
    [root@VM-0-9-centos cmake-3.19.0-rc3]# gmake install
    

    查看状态

    cmake --version
    

    2. 测试

    创建测试文件夹和两个文件

    [root@VM-0-9-centos cmake-3.19.0-rc3]# mkdir xltest
    [root@VM-0-9-centos cmake-3.19.0-rc3]# cd xltest
    [root@VM-0-9-centos xltest]# vim cmaketest.cpp
    [root@VM-0-9-centos xltest]# vim CMakeLists.txt
    

    其中cmaketest.cpp 如下

    #include <iostream>
    using namespace std;
    int main()
    {
    	cout<<"Hello Cmake!"<<endl;
    	return 0;
    }
    

    CMakeLists.txt 如下

    cmake_minimum_required(VERSION 3.0)
    project(cmaketest)
    set(SOURCE cmaketest)
    add_executable(${PROJECT_NAME} ${SOURCE})
    

    执行cmake

    [root@VM-0-9-centos xltest]# cmake .
    

    执行make

    [root@VM-0-9-centos xltest]# make
    

    执行可执行文件看到如下,安装成功

    [root@VM-0-9-centos xltest]# ./cmaketest
    Hello Cmake!
    

    3. 问题及解决

    问题如下,

    -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
    CMake Error at Utilities/cmcurl/CMakeLists.txt:505 (message):
      Could not find OpenSSL.  Install an OpenSSL development package or
      configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/cmake/cmake-3.19.0-rc3/CMakeFiles/CMakeOutput.log".
    See also "/home/cmake/cmake-3.19.0-rc3/CMakeFiles/CMakeError.log".
    ---------------------------------------------
    Error when bootstrapping CMake:
    Problem while running initial CMake
    ---------------------------------------------
    

    解决办法

    yum install openssl*
    

    .
    .
    .
    .
    .
    .


    桃花仙人种桃树,又摘桃花换酒钱_

    cs
    下一篇:没有了