[CMake] Quoting, spaces in include paths,
CMake input files generation, life, the universe and everything.
Nicolas Tisserand
nicolas.tisserand at gmail.com
Tue Feb 12 11:25:04 EST 2008
Hi all,
I am maintaining a build system for a project that uses a number of
external libraries whose sources are built with the whole project (ie:
not looked up in the host system).
Below is a trimmed down version of how the project is set up.
In that trimmed down version, libfoo is an external library, libbar a
custom library, built on top of libfoo, and exebaz an executable
depending on libbar (and thus on libfoo).
---- /CMakeLists.txt
ADD_SUBDIRECTORY(extern/libfoo)
ADD_SUBDIRECTORY(src/libbar)
ADD_SUBDIRECTORY(src/exebaz)
---- /extern/libfoo/CMakeLists.txt
PROJECT(Foo)
SET(FOO_INCLUDES ${Foo_SOURCE_DIR})
SET(FOO_USE_FILE ${Foo_BINARY_DIR}/UseFoo.cmake CACHE FILEPATH "")
MARK_AS_ADVANCED(FOO_USE_FILE)
CONFIGURE_FILE(UseFoo.cmake.in ${FOO_USE_FILE} @ONLY)
---- /extern/libfoo/UseFoo.cmake.in
SET(FOO_INCLUDES @FOO_INCLUDES@)
INCLUDE_DIRECTORIES(${FOO_INCLUDES})
---- /src/libbar/CMakeLists.txt
PROJECT(Bar)
INCLUDE(${FOO_USE_FILE})
SET(BAR_INCLUDES ${Bar_SOURCE_DIR} ${FOO_INCLUDES})
SET(BAR_USE_FILE ${Bar_BINARY_DIR}/UseBar.cmake CACHE FILEPATH "")
MARK_AS_ADVANCED(BAR_USE_FILE)
CONFIGURE_FILE(UseBar.cmake.in ${BAR_USE_FILE} @ONLY)
---- /extern/libbar/UseBar.cmake.in
SET(BAR_INCLUDES @BAR_INCLUDES@)
INCLUDE_DIRECTORIES(${BAR_INCLUDES})
---- /src/exebaz/CMakeLists.txt
PROJECT(Bar)
INCLUDE(${BAR_USE_FILE})
----
This has been setup this way so that final targets require a minimum
amount of CMake code.
Include and library paths are transitively propagated to the final
target, with just one cmake file include, just like libraries
dependencies.
I'm using the visual studio 8 generator on windows.
Everything works nice and smooth... except when the full path of the
project root contains spaces (when it's on the windows desktop for
instance: "C:\Document and Settings\user\Desktop").
In that case, the include paths in the generated project are split at
spaces, and visual studio fails to compile the project.
According to:
http://www.cmake.org/Wiki/index.php?title=CMake_FAQ#How_can_I_get_quoting_and_escapes_to_work_properly.3F
I first tried to be creative and played around various levels of
quoting, before or after the "Use*.cmake" file configurations, without
success.
I also tried the ESCAPE_QUOTES option of the CONFIGURE_FILE function.
No luck either.
I now need some world class CMake guru wisdom...
Any thoughts?
--
Nicolas
More information about the CMake
mailing list