8

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?

1 Answer 1

13

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.

1
  • Thanks for the answer, @Tsyvarev. I ended up using the BUILD_IN_SOURCE option. I was expecting the files to be copied into the build directory, instead of a subdirectory. Commented Apr 16, 2018 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.