[CMake] How do I set env variables with spaces in them in a CONFIGURE_COMMAND clause of ExternalProject_add?

David Cole david.cole at kitware.com
Thu Apr 22 13:24:13 EDT 2010


You don't.

Instead, you write a script to call as the CONFIGURE_COMMAND and in the
script, set the environment and then invoke the command requiring the
environment.

A good feature request for CMake would be to allow setting ENVIRONMENT
properties on custom commands. Then we could simply provide that as a new
arg to ExternalProject_Add and pass it through to the custom commands that
implement the build steps.

Not sure if there's an existing such feature request in the bug tracker or
not...


HTH,
David


On Thu, Apr 22, 2010 at 12:45 PM, kent williams
<nkwmailinglists at gmail.com>wrote:

> I need to build TCL & TK with CFLAGS and CXXFLAGS matching what's
> being used in the rest of my ExternalProjects.
>
> The following doesn't work:
>
> set(COMPILER_STUFF
> CC=${CMAKE_C_COMPILER} C
> XX=${CMAKE_CXX_COMPILER}
> CFLAGS="${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}"
> CXXFLAGS="${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
>
> set(TCL_DEPEND tcl)
> set(proj tcl)
> ExternalProject_Add(${proj}
> CVS_REPOSITORY ":pserver:anonymous:@tcl.cvs.sourceforge.net:/cvsroot/tcl"
> CVS_TAG -r core-8-5-7
> CVS_MODULE  "tcl"
> CONFIGURE_COMMAND
> ${COMPILER_STUFF}
> ${BRAINSTracer_BINARY_DIR}/tcl-prefix/src/tcl/unix/configure
> --prefix=${BRAINSTracer_BINARY_DIR}
> INSTALL_DIR ${BRAINSTracer_BINARY_DIR}
> UPDATE_COMMAND ""
> )
>
> You get this error message:
>
> cd /scratch/kent/newbuild/BT-build/
> make -j1
> /opt/cmake-2.9.20100421/bin/cmake
> -H/scratch/kent/newbuild/BRAINSTracerQT
> -B/scratch/kent/newbuild/BT-build --check-build-system
> CMakeFiles/Makefile.cmake 0
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /scratch/kent/newbuild/BT-build
> /opt/cmake-2.9.20100421/bin/cmake -E cmake_progress_start
> /scratch/kent/newbuild/BT-build/CMakeFiles
> /scratch/kent/newbuild/BT-build/CMakeFiles/progress.marks
> make -f CMakeFiles/Makefile2 all
> make[1]: Entering directory `/scratch/kent/newbuild/BT-build'
> make -f CMakeFiles/tcl.dir/build.make CMakeFiles/tcl.dir/depend
> make[2]: Entering directory `/scratch/kent/newbuild/BT-build'
> cd /scratch/kent/newbuild/BT-build &&
> /opt/cmake-2.9.20100421/bin/cmake -E cmake_depends "Unix Makefiles"
> /scratch/kent/newbuild/BRAINSTracerQT
> /scratch/kent/newbuild/BRAINSTracerQT /scratch/kent/newbuild/BT-build
> /scratch/kent/newbuild/BT-build
> /scratch/kent/newbuild/BT-build/CMakeFiles/tcl.dir/DependInfo.cmake
> --color=
> make[2]: Leaving directory `/scratch/kent/newbuild/BT-build'
> make -f CMakeFiles/tcl.dir/build.make CMakeFiles/tcl.dir/build
> make[2]: Entering directory `/scratch/kent/newbuild/BT-build'
> /opt/cmake-2.9.20100421/bin/cmake -E cmake_progress_report
> /scratch/kent/newbuild/BT-build/CMakeFiles
> [  0%] Performing configure step for 'tcl'
> cd /scratch/kent/newbuild/BT-build/tcl-prefix/src/tcl-build &&
> CC=/usr/bin/gcc4 XX=/usr/bin/g++4 "CFLAGS=\"-m64 -O3 -DNDEBUG\""
> "CXXFLAGS=\"-m64 -O3 -DNDEBUG\""
> /scratch/kent/newbuild/BT-build/tcl-prefix/src/tcl/unix/configure
> --prefix=/scratch/kent/newbuild/BT-build
> /bin/sh: CFLAGS="-m64 -O3 -DNDEBUG": command not found
> make[2]: *** [tcl-prefix/src/tcl-stamp/tcl-configure] Error 127
> make[2]: Leaving directory `/scratch/kent/newbuild/BT-build'
> make[1]: *** [CMakeFiles/tcl.dir/all] Error 2
> make[1]: Leaving directory `/scratch/kent/newbuild/BT-build'
> make: *** [all] Error 2
>
> Compilation exited abnormally with code 2 at Thu Apr 22 11:43:43
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100422/f0206b8b/attachment.htm>


More information about the CMake mailing list