Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set WORKING_DIRECTORY for ExternalProject_Add CONFIGURE_COMMAND

I'm trying to add an Automake project as an external project. The Automake configure script (usually run with ./configure) contains a relative path to a resource file. The file is found when I run configure manually, because my working directory is in the source directory. However, when I run configure with the ExternalProject_Add, it can't find the resource file because the working directory is CMAKE_CURRENT_BINARY_DIR.

ExternalProject_Add(zlib
        SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
        CONFIGURE_COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/configure
        BUILD_COMMAND make)

How can I set the working directory for the configuration step so that the config script finds the required files?

like image 745
the_storyteller Avatar asked Apr 16 '18 17:04

the_storyteller


1 Answers

In ExternalProject_Add configuration step is performed with build directory (BINARY_DIR option) being current, so you may set this option:

ExternalProject_Add(...
    BINARY_DIR <dir>
    ...
)

For in-source builds (when build directory is the same as source directory), BUILD_IN_SOURCE option could be used as alternative to set BINARY_DIR option:

ExternalProject_Add(...
    BUILD_IN_SOURCE 1
    ...
)

More info see at ExternalProject documentation page.

like image 120
Tsyvarev Avatar answered Oct 02 '22 14:10

Tsyvarev