下载tar.gz包

时间:2015-04-23 07:27:44

标签: linux build download cmake

我刚刚将我的CMake从2.8升级到3.2。

它在CMake 2.8中的功能就像一个魅力,但在升级后,它失败了。

我正在尝试使用ExternalProject_Add() CMake功能构建第三方库。

ExternalProject_Add(
  luacov
  URL https://github.com/keplerproject/luacov/archive/v0.7.tar.gz
  DOWNLOAD_DIR ${EXTERNAL_PROJECT_DOWNLOAD_DIR}
  CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${MY_TOOLCHAIN_FILE}
  SOURCE_DIR ${EXTERNAL_PROJECT_SRC_DIR}/luacov
  BINARY_DIR ${EXTERNAL_PROJECT_BUILD_DIR}/luacov
  UPDATE_COMMAND ""
  PATCH_COMMAND ""
)

我的观察:

  1. 使用GIT_REPOSITORY选项,ExternalProject_Add()允许httphttps协议下载外部项目。
  2. 使用URL选项,ExternalProject_Add()仅允许http,但不允许https协议下载外部项目。
  3. 问题:

    有没有办法使用https协议下载和构建外部项目?

    错误:

    [ 16%] Performing download step (download, verify and extract) for 'luacov'
    -- downloading...
     src='https://github.com/keplerproject/luacov/archive/v0.7.tar.gz'
     dst='/home/build/my_build/external_projects/downloads/v0.7.tar.gz'
     timeout='none'
    CMake Error at /home/build/my_build/luacov-prefix/src/luacov-stamp/download-luacov.cmake:21 (message):
     error: downloading
    'https://github.com/keplerproject/luacov/archive/v0.7.tar.gz' failed
    
    status_code: 1
    status_string: "Unsupported protocol"
    log: Protocol "https" not supported or disabled in libcurl
    
    Closing connection -1
    
    make[3]: *** [luacov-prefix/src/luacov-stamp/luacov-download] Error 1
    make[2]: *** [CMakeFiles/luacov.dir/all] Error 2
    make[1]: *** [CMakeFiles/luacov.dir/rule] Error 2
    make: *** [luacov] Error 2
    

7 个答案:

答案 0 :(得分:18)

问题可能是默认情况下,CMake附带的CURL库不支持SSL。我不得不用以下代码编译cmake:

front-end:
    build: .
    ports:
      - "4200:4200"
    volumes:
      - ./code:/code

......这很有效,因为我的系统卷曲有SSL支持。

答案 1 :(得分:10)

它对我有用的是:

  1. 更新openssl

    sudo apt-get install openssl libssl-dev
    
  2. 修改bootstrap文件以启用CMAKE_USE_OPENSSL。将此{{3}}替换为:

    cmake_options="-DCMAKE_BOOTSTRAP=1 -DCMAKE_USE_OPENSSL=ON"
    
  3. 在cmake文件夹中正常运行bootstrap脚本

    /@path_to_cmake/bootstrap
    

答案 2 :(得分:3)

在我的ExternalProject_Add()中,我使用GIT_REPOSITORY选项URL。{/ p>

#URL https://github.com/keplerproject/luacov/archive/v0.7.tar.gz
GIT_REPOSITORY https://github.com/keplerproject/luacov.git

luacov下载并成功构建。

对于任何https协议,请使用DOWNLOAD_COMMAND函数的ExternalProject_Add()选项。

DOWNLOAD_COMMAND wget https://github.com/keplerproject/luacov/archive/v0.7.tar.gz

并按预期工作。

感谢。

答案 3 :(得分:2)

我在计算机中构建库时遇到同样的问题,其中CMake不支持https协议。

我必须按照@ dekkard评论的建议选择-DCMAKE_USE_OPENSSL = ON来自己构建cmake。

答案 4 :(得分:2)

对于CMake 3.8.0,这对我有用:

  1. 安装/更新openssl:

    yum install openssl openssl-devel
    
  2. 通过Brad King调整CMake forum reply的解决方案:

    ./configure --prefix=/software/cmake-3.8.0/ --parallel=${NPROC} -- \ 
        -/DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON
    make -j ${NPROC} 
    make install
    
  3. 享受!

答案 5 :(得分:1)

与Cmake 3.2.1一样,它按预期工作。

这是我的示例项目/ CMakeLists.txt:

PROJECT(TestDownload)

SET(CMAKE_CXX_COMPILER "/path/to/bin/g++")
SET(CMAKE_C_COMPILER "/path/to/bin/gcc")

SET(CMAKE_CXX_FLAGS "")
SET(CMAKE_C_FLAGS "")

cmake_minimum_required(VERSION 3.2)
include(ExternalProject)

ExternalProject_Add(
  luacov
  URL https://github.com/keplerproject/luacov/archive/v0.7.tar.gz
  DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/luacov
  UPDATE_COMMAND ""
  PATCH_COMMAND ""
  INSTALL_COMMAND ""
)

命令:

$ cd project
$ mkdir build && cd build
$ cmake ..
...
$ make all
Scanning dependencies of target luacov
[ 12%] Creating directories for 'luacov'
[ 25%] Performing download step (download, verify and extract) for 'luacov'
-- downloading...
     src='https://github.com/keplerproject/luacov/archive/v0.7.tar.gz'
     dst='/tmp/project/build/luacov/v0.7.tar.gz'
     timeout='none'
-- [download 7% complete]
-- [download 21% complete]
-- [download 76% complete]
-- [download 100% complete]
-- downloading... done
-- verifying file...
     file='/tmp/project/build/luacov/v0.7.tar.gz'
-- verifying file... warning: did not verify file - no URL_HASH specified?
-- extracting...
     src='/tmp/project/build/luacov/v0.7.tar.gz'
     dst='/tmp/project/build/luacov-prefix/src/luacov'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 37%] No patch step for 'luacov'
[ 50%] No update step for 'luacov'
...

答案 6 :(得分:-2)

我通常只会将URL从https修改为http。