[CMake] ".." in CMAKE_BINARY_DIR breaks ADD_CUSTOM_COMMAND

Trevor Kellaway tkellaway at asl-electronics.co.uk
Sat Mar 10 19:36:59 EST 2007


Hi,

Whilst trying to trying to replicate an existing build environment I've
found that if ".." is present in CMAKE_BINARY_DIR an otherwise
*absolute* path seems to break ADD_CUSTOM_COMMAND with the following,
even though the displayed path is correct:

	CMake Error: Cannot find source file
"V:/project/target/DebugSimPC/host_Debug.udc" for target "app"

My existing build environment uses the following layout:

	V:/project/source/
	V:/project/target/

Currently I have CMakeList.txt in V:/project/source/, and within this I
was trying to set CMAKE_BINARY_DIR via:

	SET (CMAKE_BINARY_DIR
${CMAKE_SOURCE_DIR}/../target/${SYS_BTYPE})

It looks like CMake is getting confused by the presence of the "..", and
I presume treating it as a relative path, when it contains a full path
from root (this does beg the question is this classified as a relative
path, I'd say not, as I always think of relative paths origin as one
relative to a current directory).

I had to workaround this by striping the last directory and appending
the argument via:

	STRING(REGEX REPLACE "(.*/)[^/]+" "\\1" CMAKE_BINARY_DIR
"${CMAKE_SOURCE_DIR}")
	SET (CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}target/${SYS_BTYPE})


Does anyone have any advice on building out of source, I see numerous
references to this, but haven't stumbled across any examples,
especially:

1) where should you place the top level CMakeList.txt? (one level above
the project, or in it?)
2) how do you invoke CMake (do you pass arguments for the build types
and output directory, do you prebuild a cache file?)

My current build system has numerous output variants of build target, so
I'm currently passing the variant via SYS_BTYPE environment variable so
that invocation of CMake only requires the -G option (to keep it simple
for other developers on the project).

Any tips or pointers to good URLs gratefully received.

 - TrevK


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070311/02478d50/attachment.htm


More information about the CMake mailing list