不支持的协议,而downlod tar.gz包

我刚把2.8版的CMake2.8版升级到3.2

它在CMake 2.8工作魅力,但升级之后就失败了。

我正在尝试使用ExternalProject_Add() CMake函数来构build第三方库。

 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协议下载外部项目。

问题:

有什么方法可以使用https协议下载和构build外部项目?

错误:

 [ 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 

问题可能是CMake附带的CURL库默认不支持SSL。 我不得不编译cmake:

 ./bootstrap --system-curl make sudo make install 

…这工作,因为我的系统curl有SSL支持。

它对我的工作如下:

  1. 更新openssl

     sudo apt-get install openssl libssl-dev 
  2. 修改引导文件以启用CMAKE_USE_OPENSSL。 将此行替换为:

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

     /@path_to_cmake/bootstrap 

在我的ExternalProject_Add() ,我使用了GIT_REPOSITORYURL选项。

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

luacov下载并建立成功。

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

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

并按预期工作。

谢谢。

在CMake不支持https协议的计算机上,我遇到了同样的问题。

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

看起来像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' ... 

对于CMake 3.8.0这为我工作:

  1. 安装/更新openssl:

     yum install openssl openssl-devel 
  2. 适应来自CMake论坛的解决方案由Brad King 答复 :

     ./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. 请享用!