On Fri, Sep 16, 2011 at 5:11 AM, Alexander Neundorf <span dir="ltr"><<a href="mailto:neundorf@kde.org">neundorf@kde.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5">On Thursday, September 15, 2011 10:22:52 PM James Bigler wrote:<br>
> On Mon, Sep 12, 2011 at 3:35 PM, James Bigler <<a href="mailto:jamesbigler@gmail.com">jamesbigler@gmail.com</a>> wrote:<br>
> > I need some advice on how to fix a problem I'm having with files with the<br>
> > same name.<br>
> ><br>
> > I have two CUDA files with the same name in different directories:<br>
> ><br>
> > CUDA_ADD_EXECUTABLE(test-conflict<br>
> ><br>
> >   "path with spaces/conflict.cpp"<br>
> >   "path with spaces/<a href="http://conflict.cu" target="_blank">conflict.cu</a>"<br>
> >   "path with spaces/no-conflict.cpp"<br>
> >   "path with spaces/<a href="http://no-conflict.cu" target="_blank">no-conflict.cu</a>"<br>
> >   conflict-main.cpp<br>
> >   conflict.cpp<br>
> >   <a href="http://conflict.cu" target="_blank">conflict.cu</a><br>
> >   )<br>
> ><br>
> > I notice that the cpp files get the following outputs:<br>
> ><br>
> > path with spaces/no-conflict.cpp: test-conflict.dir\Debug<br>
> > path with spaces/conflict.cpp:<br>
> > "test-conflict.dir\Debug\/path_with_spaces/conflict.cpp.obj"<br>
> > conflict.cpp: "test-conflict.dir\Debug\/conflict.cpp.obj"<br>
> ><br>
> > This seems to work well and everyone is happy.<br>
> ><br>
> > The FindCUDA code is a different story, and one I wish to get some more<br>
> > input on.  The current implementation takes the basename and merges it in<br>
> > with the target name like so (one example given):<br>
> ><br>
> ><br>
> > "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${cuda_target}_generated<br>
> > _${basename}${generated_extension}"<br>
> ><br>
> > The problem is two files with the same basename can cause collisions in<br>
> > the naming scheme.  I'm wondering if the best solution is to keep a per<br>
> > target list of basenames as a directory property and when collisions<br>
> > happen, create a new sub-directory to be used by the build script.  My<br>
> > question at this point is what and how to compute the non-conflicting<br>
> > directories.  Does anyone have any good suggestions for how to implement<br>
> > this?<br>
> ><br>
> > Thanks,<br>
> > James<br>
><br>
> How about telling me where I can find how CMake does this for the C code?<br>
> I notice that it only puts sub directories when there's a conflict, so<br>
> there's logic somewhere that determines this and then determines what the<br>
> intermediate directories should be.<br>
<br>
</div></div>CMake creates a directory for every target, and inside that directory, it<br>
creates subdirectories for every subdirectory present in the input files.<br>
To avoid clashes between foo.c and foo.cpp, the .o is simply appended, so we<br>
get foo.c.o and foo.cpp.o.<br>
<br>
Alex<br>
</blockquote></div><br>Thanks for the response Alex, but that's not quite it.  From my experiments, CMake only puts object files in sub directories (below the target sub-directory) when it detects the clash (see the original email).  I also have clashes on file names and not just extensions.<br>

<br>I'm trying to figure out how to best handle the partial paths.<br><br>If you had this then I can compute the relative path with respect to CMAKE_CURRENT_SOURCE_DIR.<br><br>dir1/file.cpp<br>dir2/file.cpp<br><br>What if I had this:<br>

<br>../dir1/file.cpp<br>../../dir2/file.cpp<br><br>What do I use as the sub directory?  I can't use ../ in the path as this will totally put things in the wrong directory (CMAKE_CURRENT_BINARY_DIR/CMakeFiles/target.dir/../dir1 would generally be a bad idea).<br>

<br>And what if I had an absolute file path?  What do I do then?<br><br>James<br>