[CMake] Pass PATH to ExternalProject_Add

Michael Wild themiwi at gmail.com
Tue Nov 30 14:40:16 EST 2010


Often you can also pass options to configure scripts specifying the
location of special tools.

Michael

On 11/30/2010 05:47 PM, David Cole wrote:
> 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