0

I am trying to build tinyxml2 using ExternalProject_Add. It works fine on my main system (Arch Linux), but I have some issues when running it inside dockcross (more specifically, dockcross/linux-armv6).

The following minimal CMakeLists.txt works (configure and build) from 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
    )

But the following doesn't (note the added line: 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>
    )

It actually results in the following error output:

[ 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

Building tinyxml2 directly from dockcross (i.e. without using ExternalProject_Add) works well.

What could be going wrong there?

JonasVautherin
  • 7,297
  • 6
  • 49
  • 95
  • As far as I understand, usage of dockcross with CMake is `dockcross cmake ...`, so you should use corresponded command as `CONFIGURE_COMMAND`. Or, at least, add `-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}` parameter to `cmake` - it is impossible to cross-compile without toolchain. BTW, what about `make VERBOSE=1` for check which actual commands are executed in both cases? – Tsyvarev Apr 10 '19 at 22:42
  • I do use `dockcross cmake`, and it fails exactly when I run that. Running without dockcross is fine. Also it seems to fail in configure step, so I don't know if I can benefit from "VERBOSE" – JonasVautherin Apr 11 '19 at 04:17
  • The error seems to be a wrong path somewhere ("no such file or directory", "permission denied"). But I'm not sure why, since it works on another Linux system... – JonasVautherin Apr 11 '19 at 04:58
  • 1
    `it seems to fail in configure step, so I don't know if I can benefit from "VERBOSE"` - this is a configuration step of the *external project*, but a build step for the outer project. I meant to run `make VERBOSE=1` when build the outer project. – Tsyvarev Apr 11 '19 at 08:01
  • What are you trying to achieve by specifying your own `CONFIGURE_COMMAND` ? – J-Christophe May 11 '19 at 05:14
  • That's actually a good point. It's not necessary here, but I also needed to use SOURCE_SUBDIR, which is not available on the cmake distributed with Ubuntu 16.04 (that I need to support) – JonasVautherin May 11 '19 at 05:49

1 Answers1

1

That is actually a bug in CMake, as reported (and fixed) here.

The workaround, for CMake versions that have the bug, is to run it like so (note that -S<SOURCE_DIR> becomes <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>
    )
JonasVautherin
  • 7,297
  • 6
  • 49
  • 95