You don&#39;t.<br><br>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.<br><br>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.<br>
<br>Not sure if there&#39;s an existing such feature request in the bug tracker or not...<br><br><br>HTH,<br>David<br><br><br><div class="gmail_quote">On Thu, Apr 22, 2010 at 12:45 PM, kent williams <span dir="ltr">&lt;<a href="mailto:nkwmailinglists@gmail.com">nkwmailinglists@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I need to build TCL &amp; TK with CFLAGS and CXXFLAGS matching what&#39;s<br>
being used in the rest of my ExternalProjects.<br>
<br>
The following doesn&#39;t work:<br>
<br>
set(COMPILER_STUFF<br>
CC=${CMAKE_C_COMPILER} C<br>
XX=${CMAKE_CXX_COMPILER}<br>
CFLAGS=&quot;${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}&quot;<br>
CXXFLAGS=&quot;${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}&quot;)<br>
<br>
set(TCL_DEPEND tcl)<br>
set(proj tcl)<br>
ExternalProject_Add(${proj}<br>
CVS_REPOSITORY &quot;:pserver:anonymous:@tcl.cvs.sourceforge.net:/cvsroot/tcl&quot;<br>
CVS_TAG -r core-8-5-7<br>
CVS_MODULE  &quot;tcl&quot;<br>
CONFIGURE_COMMAND<br>
${COMPILER_STUFF}<br>
${BRAINSTracer_BINARY_DIR}/tcl-prefix/src/tcl/unix/configure<br>
--prefix=${BRAINSTracer_BINARY_DIR}<br>
INSTALL_DIR ${BRAINSTracer_BINARY_DIR}<br>
UPDATE_COMMAND &quot;&quot;<br>
)<br>
<br>
You get this error message:<br>
<br>
cd /scratch/kent/newbuild/BT-build/<br>
make -j1<br>
/opt/cmake-2.9.20100421/bin/cmake<br>
-H/scratch/kent/newbuild/BRAINSTracerQT<br>
-B/scratch/kent/newbuild/BT-build --check-build-system<br>
CMakeFiles/Makefile.cmake 0<br>
-- Configuring done<br>
-- Generating done<br>
-- Build files have been written to: /scratch/kent/newbuild/BT-build<br>
/opt/cmake-2.9.20100421/bin/cmake -E cmake_progress_start<br>
/scratch/kent/newbuild/BT-build/CMakeFiles<br>
/scratch/kent/newbuild/BT-build/CMakeFiles/progress.marks<br>
make -f CMakeFiles/Makefile2 all<br>
make[1]: Entering directory `/scratch/kent/newbuild/BT-build&#39;<br>
make -f CMakeFiles/tcl.dir/build.make CMakeFiles/tcl.dir/depend<br>
make[2]: Entering directory `/scratch/kent/newbuild/BT-build&#39;<br>
cd /scratch/kent/newbuild/BT-build &amp;&amp;<br>
/opt/cmake-2.9.20100421/bin/cmake -E cmake_depends &quot;Unix Makefiles&quot;<br>
/scratch/kent/newbuild/BRAINSTracerQT<br>
/scratch/kent/newbuild/BRAINSTracerQT /scratch/kent/newbuild/BT-build<br>
/scratch/kent/newbuild/BT-build<br>
/scratch/kent/newbuild/BT-build/CMakeFiles/tcl.dir/DependInfo.cmake<br>
--color=<br>
make[2]: Leaving directory `/scratch/kent/newbuild/BT-build&#39;<br>
make -f CMakeFiles/tcl.dir/build.make CMakeFiles/tcl.dir/build<br>
make[2]: Entering directory `/scratch/kent/newbuild/BT-build&#39;<br>
/opt/cmake-2.9.20100421/bin/cmake -E cmake_progress_report<br>
/scratch/kent/newbuild/BT-build/CMakeFiles<br>
[  0%] Performing configure step for &#39;tcl&#39;<br>
cd /scratch/kent/newbuild/BT-build/tcl-prefix/src/tcl-build &amp;&amp;<br>
CC=/usr/bin/gcc4 XX=/usr/bin/g++4 &quot;CFLAGS=\&quot;-m64 -O3 -DNDEBUG\&quot;&quot;<br>
&quot;CXXFLAGS=\&quot;-m64 -O3 -DNDEBUG\&quot;&quot;<br>
/scratch/kent/newbuild/BT-build/tcl-prefix/src/tcl/unix/configure<br>
--prefix=/scratch/kent/newbuild/BT-build<br>
/bin/sh: CFLAGS=&quot;-m64 -O3 -DNDEBUG&quot;: command not found<br>
make[2]: *** [tcl-prefix/src/tcl-stamp/tcl-configure] Error 127<br>
make[2]: Leaving directory `/scratch/kent/newbuild/BT-build&#39;<br>
make[1]: *** [CMakeFiles/tcl.dir/all] Error 2<br>
make[1]: Leaving directory `/scratch/kent/newbuild/BT-build&#39;<br>
make: *** [all] Error 2<br>
<br>
Compilation exited abnormally with code 2 at Thu Apr 22 11:43:43<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>