<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7233.69">
<TITLE>&quot;..&quot; in CMAKE_BINARY_DIR breaks ADD_CUSTOM_COMMAND </TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Hi,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Whilst trying to trying to replicate an existing build environment I've found that if &quot;..&quot; 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:</FONT></P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">CMake Error: Cannot find source file &quot;V:/project/target/DebugSimPC/host_Debug.udc&quot; for target &quot;app&quot;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">My existing build environment uses the following layout:</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">V:/project/source/</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">V:/project/target/</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Currently I have CMakeList.txt in V:/project/source/, and within this I was trying to set CMAKE_BINARY_DIR via:</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">SET (CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/../target/${SYS_BTYPE})</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">It looks like CMake is getting confused by the presence of the &quot;..&quot;, 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).</FONT></P>

<P><FONT SIZE=2 FACE="Arial">I had to workaround this by striping the last directory and appending the argument via:</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">STRING(REGEX REPLACE &quot;(.*/)[^/]+&quot; &quot;</FONT><A HREF="file://\\1"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">\\1</FONT></U></A><FONT SIZE=2 FACE="Arial">&quot; CMAKE_BINARY_DIR &quot;${CMAKE_SOURCE_DIR}&quot;)</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Arial">SET (CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}target/${SYS_BTYPE})</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">Does anyone have any advice on building out of source, I see numerous references to this, but haven't stumbled across any examples, especially:</FONT></P>

<P><FONT SIZE=2 FACE="Arial">1) where should you place the top level CMakeList.txt? (one level above the project, or in it?)</FONT>

<BR><FONT SIZE=2 FACE="Arial">2) how do you invoke CMake (do you pass arguments for the build types and output directory, do you prebuild a cache file?)</FONT></P>

<P><FONT SIZE=2 FACE="Arial">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).</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Any tips or pointers to good URLs gratefully received.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">&nbsp;- TrevK</FONT>
</P>
<BR>

</BODY>
</HTML>