[cmake-developers] Some advice

Alexander Neundorf neundorf at kde.org
Fri Sep 16 07:11:53 EDT 2011


On Thursday, September 15, 2011 10:22:52 PM James Bigler wrote:
> On Mon, Sep 12, 2011 at 3:35 PM, James Bigler <jamesbigler at gmail.com> wrote:
> > I need some advice on how to fix a problem I'm having with files with the
> > same name.
> > 
> > I have two CUDA files with the same name in different directories:
> > 
> > CUDA_ADD_EXECUTABLE(test-conflict
> > 
> >   "path with spaces/conflict.cpp"
> >   "path with spaces/conflict.cu"
> >   "path with spaces/no-conflict.cpp"
> >   "path with spaces/no-conflict.cu"
> >   conflict-main.cpp
> >   conflict.cpp
> >   conflict.cu
> >   )
> > 
> > I notice that the cpp files get the following outputs:
> > 
> > path with spaces/no-conflict.cpp: test-conflict.dir\Debug
> > path with spaces/conflict.cpp:
> > "test-conflict.dir\Debug\/path_with_spaces/conflict.cpp.obj"
> > conflict.cpp: "test-conflict.dir\Debug\/conflict.cpp.obj"
> > 
> > This seems to work well and everyone is happy.
> > 
> > The FindCUDA code is a different story, and one I wish to get some more
> > input on.  The current implementation takes the basename and merges it in
> > with the target name like so (one example given):
> > 
> > 
> > "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${cuda_target}_generated
> > _${basename}${generated_extension}"
> > 
> > The problem is two files with the same basename can cause collisions in
> > the naming scheme.  I'm wondering if the best solution is to keep a per
> > target list of basenames as a directory property and when collisions
> > happen, create a new sub-directory to be used by the build script.  My
> > question at this point is what and how to compute the non-conflicting
> > directories.  Does anyone have any good suggestions for how to implement
> > this?
> > 
> > Thanks,
> > James
> 
> How about telling me where I can find how CMake does this for the C code? 
> I notice that it only puts sub directories when there's a conflict, so
> there's logic somewhere that determines this and then determines what the
> intermediate directories should be.

CMake creates a directory for every target, and inside that directory, it 
creates subdirectories for every subdirectory present in the input files.
To avoid clashes between foo.c and foo.cpp, the .o is simply appended, so we 
get foo.c.o and foo.cpp.o.

Alex



More information about the cmake-developers mailing list