0

我正在尝试使用ExternalProject_Add. 它在我的主系统(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

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

那里可能出了什么问题?

4

1 回答 1

0

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

对于有错误的 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>
    )
于 2019-04-11T08:43:22.500 回答