使用dockcross

时间:2019-04-10 22:34:33

标签: cmake external-project

我正在尝试使用ExternalProject_Add构建tinyxml2。它可以在我的主系统(Arch Linux)上正常工作,但是在dockcross(更具体地说,dockcross/linux-armv6)中运行它时,我遇到一些问题。

以下最小的CMakeLists.txt可通过dockcross进行工作(配置和构建):

cmake_minimum_required(VERSION 3.1)

project(external-tinyxml2)
include(ExternalProject)

ExternalProject_add(
    tinyxml2
    URL https://github.com/leethomason/tinyxml2/archive/7.0.1.tar.gz
    PREFIX tinyxml2
    )

但是以下内容却没有(注意添加的行:CONFIGURE_COMMAND ${CMAKE_COMMAND} -S<SOURCE_DIR>):

cmake_minimum_required(VERSION 3.1)

project(external-tinyxml2)
include(ExternalProject)

ExternalProject_add(
    tinyxml2
    URL https://github.com/leethomason/tinyxml2/archive/7.0.1.tar.gz
    PREFIX tinyxml2
    CONFIGURE_COMMAND ${CMAKE_COMMAND} -S<SOURCE_DIR>
    )

它实际上导致以下错误输出:

[ 25%] No patch step for 'tinyxml2'
[ 37%] No update step for 'tinyxml2'
[ 50%] Performing configure step for 'tinyxml2'
CMake Deprecation Warning at CMakeLists.txt:11 (cmake_policy):
  The OLD behavior for policy CMP0063 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Error at /usr/share/cmake-3.13/Modules/CMakeDetermineCompilerId.cmake:161 (file):
  file problem creating directory: /CMakeFiles/3.13.2/CompilerIdC
Call Stack (most recent call first):
  /usr/share/cmake-3.13/Modules/CMakeDetermineCompilerId.cmake:31 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  /usr/share/cmake-3.13/Modules/CMakeDetermineCCompiler.cmake:112 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:14 (project)

[... other similar errors ...]

CMake Error at /usr/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:37 (try_compile):
  Failed to set working directory to /CMakeFiles/CMakeTmp/testCCompiler.c :
  No such file or directory
Call Stack (most recent call first):
  CMakeLists.txt:14 (project)


-- Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: /CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. /CMakeCache.txt
CMake Error: : System Error: Permission denied
CMakeFiles/tinyxml2.dir/build.make:108: recipe for target 'tinyxml2/src/tinyxml2-stamp/tinyxml2-configure' failed
make[2]: *** [tinyxml2/src/tinyxml2-stamp/tinyxml2-configure] Error 1
make[2]: Leaving directory '/work/build'
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/tinyxml2.dir/all' failed
make[1]: *** [CMakeFiles/tinyxml2.dir/all] Error 2
make[1]: Leaving directory '/work/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
make: Leaving directory '/work/build

直接从ockercross(即不使用ExternalProject_Add)构建tinyxml2效果很好。

那里可能出了什么问题?

1 个答案:

答案 0 :(得分:0)

实际上,这是CMake中的一个错误,已报告(并已修复)here

对于具有此错误的CMake版本,解决方法是像这样运行它(请注意,-S<SOURCE_DIR>变成<SOURCE_DIR>):

ExternalProject_add(
    tinyxml2
    URL https://github.com/leethomason/tinyxml2/archive/7.0.1.tar.gz
    PREFIX tinyxml2
    CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
    )