[CMake] Pass PATH to ExternalProject_Add

David Cole david.cole at kitware.com
Tue Nov 30 11:47:54 EST 2010


Write a wrapper script for your configure command, set the ENV var
inside the wrapper script before calling configure.

That's the best way to do it with as-is CMake.


On Tuesday, November 30, 2010, Joke de Buhr <joke at seiken.de> wrote:
> Hi,
>
> I added some ExternalProject_Add directives to my project. Each of them runs
> the sequence of configure, make all, make install. Later projects need run
> commands generated in early projects during their build phases.
>
> Each project installs generated files at the place ${BUILD_DIR} which is set
> at the top of the cmake file and passed down to the configure command. I tried
> setting ENV{PATH} to include the directory ${BUILD_DIR}/bin but cmake doesn't
> pass the changed environment variable down to the ExternalProject_Add
> directives. Since the changed environment isn't passed down later projects
> don't look for generated commands in ${BUILD_DIR}/bin.
>
> How can I pass down the PATH environment to ExternalProject_Add?
>
>
> CMakeLists.txt:
>
>
> set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/build")
> set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/build/bin")
>
> ExternalProject_Add(project0
>     CONFIGURE_COMMAND ./configure --prefix=${BUILD_DIR}
>     BUILD_IN_SOURCE 1
> )
>
> ExternalProject_Add(project1
>     DEPENDS project0
>     CONFIGURE_COMMAND ./configure --prefix=${BUILD_DIR}
>     BUILD_IN_SOURCE 1
> )
>


More information about the CMake mailing list