[CMake] Patch for Eclipse generator

Pau Garcia i Quiles pgquiles at elpauer.org
Sat Oct 20 18:48:18 EDT 2007


Quoting a.neundorf-work at gmx.net:

> Hi,
>
> On Friday 19 October 2007 01:18, Pau Garcia i Quiles wrote:
>> Hello,
>>
>> As I told yesterday, here comes a patch for the Eclipse CDT4 generator
>> available in the current CVS version of CMake.
>>
>> Although I have not extensively tested it, the works fine. In addition
>> to the in-tree build which has always worked, this patch allows you to
>> have 'myapp' and 'myapp/build' or 'myapp' and 'myapp-build' at the
>> same level:
>>
>> mydir/myapp
>> mydir/myapp/build
>>
>> or
>>
>> mydir/myapp
>> mydir/myapp-build
>>
>> The patch breaks the CMake way of doing thing, as it writes the
>> Eclipse project files (.project and .cproject) in the source directory
>> even in an out-of-tree build.
>>
>> Tomorrow I'll try to implement a new property, or look at the value of
>> a variable, to make it possible to use the pure-CMake style (.project
>> and .cproject in the generated-files directory) or the
>> Eclipse-required style (.project and .cproject in the source directory).
>>
>> Please try it and send your comments to the list or to me.
>
> Just to make sure I understand:
> with this patch the two eclipse project files are always created in   
> the source tree, right ?

Right.

> What happens if you try to create two buildtrees for one source tree, which
> problems may appear ?

With my current patch, it's not possible due to Eclipse limitations.

The only way I can think to fix this is to create soft links to the  
files and folders in the source tree, then create the .project and  
.cproject in that folder. It'd be something like this:

myhelloapp/CMakeLists.txt
myhelloapp/src/CMakeLists.txt
myhelloapp/src/hello.cpp
myhelloapp-build/.project
myhelloapp-build/.cproject
myhelloapp-build/src -> myhelloapp/src/hello.cpp
myhelloapp-build2/.project
myhelloapp-build2/.cproject
myhelloapp-build2/src -> myhelloapp/src/hello.cpp

where "->" means that's a symlink.

This would probably work fine on Unix platforms and probably Windows  
2000 and 2003 (using linkd for the symlinks). I'd have to test this,  
though.

If this approach is more acceptable to Kitware, as it is more  
CMake-ish, I'll do some research. Just tell me.

>
> This makes cvs/svn work directly on the files in this project tree, right ?

Yes, again due to Eclipse limitations. But I guess this is what users  
expect: when I use Eclipse, I want to have my source files, resource  
files and CMakeLists.txt in Subversion, not my build tree.

Using the symlinks approach I just devised, it might be possible to  
have different Subversion repositories for different build trees but,  
is that any useful? Does it make sense at all?

> Are still linked resources created ?

Do you mean linked resources to the build tree? Yes, it's the first  
and only one. I removed the creation of the other linked resources  
that were created as they interfered and didn't look any useful for me  
(but I that might be wrong)

> Can the build tree be anywhere in the system or does it have to be  
> one of the two locations named above ? What happens if it is  
> somewhere else ?

Anywhere you like it to be. It works everywhere, all three scenarios  
(out-of-tree, in-tree or in a subdirectory in-tree) work fine, at  
least for me.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)



More information about the CMake mailing list