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

kent williams nkwmailinglists at gmail.com
Thu Apr 22 16:27:58 EDT 2010


The following seems to be working.  The regular expressions to test
the build type are kinda fugly, but at least they're case-insensitive.

I don't know how to make this Windows-compatible, but then Windows
can't run configure scripts anyway.

-------------------BuildTcl.cmake---------------------------------------
set(EXPORT_CFLAGS "${CMAKE_C_FLAGS}")
set(EXPORT_CXXFLAGS "${CMAKE_CXX_FLAGS}")

if(CMAKE_BUILD_TYPE MATCHES [Dd][Ee][Bb][Uu][Gg])
set(EXPORT_CFLAGS "${EXPORT_CFLAGS} ${CMAKE_C_FLAGS_DEBUG}")
set(EXPORT_CXXFLAGS "${EXPORT_CXXFLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
endif(CMAKE_BUILD_TYPE MATCHES [Dd][Ee][Bb][Uu][Gg])

if(CMAKE_BUILD_TYPE MATCHES [Rr][Ee][Ll][Ee][Aa][Ss][Ee])
set(EXPORT_CFLAGS "${EXPORT_CFLAGS} ${CMAKE_C_FLAGS_RELEASE}")
set(EXPORT_CXXFLAGS "${EXPORT_CXXFLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
endif(CMAKE_BUILD_TYPE MATCHES [Rr][Ee][Ll][Ee][Aa][Ss][Ee])

set(CONFIG_WRAPPER ${BRAINSTracer_BINARY_DIR}/runconfigure.sh )
configure_file(${BRAINSTracer_SOURCE_DIR}/runconfigure.sh.in
${CONFIG_WRAPPER} @ONLY)

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
sh ${CONFIG_WRAPPER}
${CMAKE_CURRENT_BINARY_DIR}/tcl-prefix/src/tcl/unix/configure
--prefix=${CMAKE_CURRENT_BINARY_DIR}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
UPDATE_COMMAND ""
)

-------------------------------runconfigure.sh-------------------------------
#!/bin/sh
export CFLAGS="@EXPORT_CFLAGS@"
export CXXFLAGS="@EXPORT_CXXFLAGS@"
export CC=@CMAKE_C_COMPILER@
export CXX=@CMAKE_CXX_COMPILER@
exec $*


More information about the CMake mailing list