2

I'm trying to use CMake's ExternalProject_Add command to build an Autotools project on Ubuntu 18.04 using cmake 3.15.7. Here is the command I'm using:

set(THIRD_PARTY_DIRS ${CMAKE_SOURCE_DIR}/third_party)
set(RAPTOR_SOURCE_DIR ${THIRD_PARTY_DIRS}/raptor2-2.0.15)
set(RAPTOR_BINARY_DIR ${RAPTOR_SOURCE_DIR}/build)
set(RAPTOR_INSTALL_PREFIX ${RAPTOR_SOURCE_DIR}/install_dir)

ExternalProject_Add(raptor
        SOURCE_DIR ${RAPTOR_SOURCE_DIR} # exists in the third party directory
        BINARY_DIR ${RAPTOR_BINARY_DIR}
        MKDIR ${RAPTOR_INSTALL_PREFIX}

        USES_TERMINAL_CONFIGURE 1 # Added these in to try them, they do not seem to do anything
        USES_TERMINAL_BUILD 1
        USES_TERMINAL_INSTALL 1

        #note: this command has been manually tested outside of cmake and works perfectly
        CONFIGURE_COMMAND "${RAPTOR_SOURCE_DIR}/autogen.sh --prefix=${RAPTOR_INSTALL_PREFIX}" 
        BUILD_COMMAND "make"
        INSTALL_COMMAND "make install"
        )

Which causes the error:

/bin/sh: 1: /mnt/d/libsemsim/third_party/raptor2-2.0.15/autogen.sh --prefix=/mnt/d/libsemsim/third_party/raptor2-2.0.15/install_dir: not found
CMakeFiles/raptor.dir/build.make:106: recipe for target 'raptor-prefix/src/raptor-stamp/raptor-configure' failed
make[3]: *** [raptor-prefix/src/raptor-stamp/raptor-configure] Error 127
CMakeFiles/Makefile2:241: recipe for target 'CMakeFiles/raptor.dir/all' failed
make[2]: *** [CMakeFiles/raptor.dir/all] Error 2
CMakeFiles/Makefile2:253: recipe for target 'CMakeFiles/raptor.dir/rule' failed
make[1]: *** [CMakeFiles/raptor.dir/rule] Error 2
Makefile:183: recipe for target 'raptor' failed
make: *** [raptor] Error 2

The variation of this command


ExternalProject_Add(raptor
        SOURCE_DIR ${RAPTOR_SOURCE_DIR} 
        BINARY_DIR ${RAPTOR_BINARY_DIR}

        USES_TERMINAL_CONFIGURE 1 
        USES_TERMINAL_BUILD 1
        USES_TERMINAL_INSTALL 1
        CONFIGURE_COMMAND "${RAPTOR_SOURCE_DIR}/autogen.sh"  
        BUILD_COMMAND "make"
        INSTALL_COMMAND "make install"
        )

i.e. not providing a prefix path, causes cmake to hang and do nothing.

Can anybody suggest what I am doing wrong here?

Here is some additional information in case its helpful

(base) ciaran@DESKTOP-K0APGUV:/mnt/d/libsemsim/third_party/raptor2-2.0.15$ pwd
/mnt/d/libsemsim/third_party/raptor2-2.0.15
(base) ciaran@DESKTOP-K0APGUV:/mnt/d/libsemsim/third_party/raptor2-2.0.15$ tree -L 1
.
├── AUTHORS
├── CMakeLists.txt
├── COPYING
├── COPYING.LIB
├── INSTALL
├── INSTALL.html
├── LICENSE-2.0.txt
├── LICENSE.html
├── LICENSE.txt
├── Makefile
├── Makefile.am
├── Makefile.in
├── NEWS
├── NEWS.html
├── NOTICE
├── README
├── README-cmake.md
├── README.html
├── RELEASE.html
├── UPGRADING.html
├── aclocal.m4
├── autogen.sh
├── autom4te.cache
├── build
├── config.log
├── config.status
├── configure
├── configure.ac
├── data
├── docs
├── examples
├── gtk-doc.make
├── install.ubuntu
├── install_dir
├── librdfa
├── libtool
├── mkinstalldirs
├── raptor2.pc
├── raptor2.pc.in
├── raptor2.rdf
├── raptor2.rdf.in
├── raptor2.spec
├── raptor2.spec.in
├── scripts
├── src
├── tests
└── utils

edit

As suggested in the comments I tried separating the command and arguments in the call to CONFIGURE_COMMAND

set(prefix "${RAPTOR_INSTALL_PREFIX}")
ExternalProject_Add(raptor
        SOURCE_DIR ${RAPTOR_SOURCE_DIR}
        BINARY_DIR ${RAPTOR_BINARY_DIR}
        MKDIR ${RAPTOR_INSTALL_PREFIX}

        USES_TERMINAL_CONFIGURE 1
        USES_TERMINAL_BUILD 1
        USES_TERMINAL_INSTALL 1
        CONFIGURE_COMMAND "${RAPTOR_SOURCE_DIR}/autogen.sh" "--prefix=${RAPTOR_INSTALL_PREFIX}"
        BUILD_COMMAND "make"
        INSTALL_COMMAND "make install"
        )

But I'm still getting the "hanging" problem:

[ 12%] Creating directories for 'raptor'
[ 25%] No download step for 'raptor'
[ 50%] No patch step for 'raptor'
[ 50%] No update step for 'raptor'
[ 62%] Performing configure step for 'raptor'

Its been like this for over an hour.

CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
  • 1
    "... what I am doing wrong here?" - You enclose the COMMAND's executable and its arguments into **double quotes**, so CMake treats them as one "big" executable. Everything before `: not found` in the error message is a file which shell tries to run. – Tsyvarev May 04 '20 at 16:11
  • Similar question [here](https://stackoverflow.com/questions/24519499/cmake-wont-run-build-command-in-externalproject-add-correctly). – Kevin May 05 '20 at 11:31

0 Answers0