[CMake] Trouble with EXTERNALPROJECT_ADD, configure, and CFLAGS

Dan Kegel dank at kegel.com
Tue Oct 25 13:05:58 EDT 2011


I did

include(ExternalProject)
ExternalProject_Add(
    CeltTarget
    SOURCE_DIR ${CMAKE_SOURCE_DIR}/celt
    INSTALL_DIR ${CMAKE_BINARY_DIR}/prefix
    CONFIGURE_COMMAND ${CMAKE_SOURCE_DIR}/celt/configure -C
--prefix=${CMAKE_BINARY_DIR}/prefix --disable-shared --with-pic
CFLAGS="-g -O2 -fPIC"
)

but configure failed when I typed 'make', saying

configure: error: in
`/home/dank/foo/build/CeltTarget-prefix/src/CeltTarget-build':
configure: error: C compiler cannot create executables
See `config.log' for more details.

config.log said

configure:3552: checking whether the C compiler works
configure:3574: gcc "-g -O2 -fPIC"   conftest.c  >&5
gcc: error: "-g: No such file or directory

So, it seems to be a quoting problem.
(Removing the quotes doesn't work, of course, since then configure
complains that there's no such option -O2.)
Has anyone else run into this?
What's the right way to pass in cflags to the configure script in
ExternalProject_Add?

http://www.mail-archive.com/cmake@cmake.org/msg26433.html looks related.

$ cmake --version
cmake version 2.8.5


More information about the CMake mailing list