[CMake] Multiple source directory scenario and cdt generator

Alexander Neundorf a.neundorf-work at gmx.net
Sat Nov 12 06:04:00 EST 2011


On Saturday 12 November 2011, Dan Kegel wrote:
> In http://www.cmake.org/pipermail/cmake/2011-November/047250.html
> I wrote
> 
> "I can't reorganize the source tree on the developers,
> so I'm making do by putting the enclosing CMakeLists.txt next to all
> the projects:
>    toplevel/trunk/CMakeLists.txt
> which is checked out to
>    toplevel/CMakeLists.txt
> It does
>    add_subdirectory(../libfoo libfoo)
>    add_subdirectory(../libbar libbar)
>    add_subdirectory(../baz baz)
> This has the possible advantage that one can have multiple
> "top levels" (say, one for server code, and one for client).
> I don't know how many shops suffer from this svn layout, but I'll probably
> add an example covering it anyway for completeness once I'm sure
> it doesn't explode in practice."
> 
> Right, well, I found out where it explodes in practice.  Here's an example:
> http://code.google.com/p/winezeug/source/browse/trunk/cmake_examples/ex7/
> 
> The problem comes when using the cdt generator.  We can't use
> -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE
> since there are more than one source project, but the
> source project that generates is really trivial, so I generate
> one for each source directory myself with a bit of shell:
> 
> for dir in demo libsrc
> do
>     sed "s/PROJNAME/_$dir/" < ../skeleton.project > ../$dir/.project
> done
> 
> before or after running cmake.
> 
> It all works great, the source projects all show up, the project builds...
> BUT when you edit a source file and tell eclipse to rebuild, it just
> sits there.  It doesn't know that the source projects are related to
> the build project.
> 
> It looks like adding a link does the trick:
> 
> --- .project.old	2011-11-11 22:51:56.797674441 +0000
> +++ .project	2011-11-11 22:52:25.380913484 +0000
> @@ -113,5 +113,11 @@
>  			<type>2</type>
>  			<location>/home/dank/winezeug/cmake_examples/ex7/demo</location>
>  		</link>
> +		<link>
> +			<name>[Source directory 2]</name>
> +			<type>2</type>
> +			
<location>/home/dank/winezeug/cmake_examples/ex7/libsrc</location>
> +		</link>
> +
>  	</linkedResources>
>  </projectDescription>
> 
> After I add those lines to the .project, saved changes in libsrc do seem
> to cause a rebuild the next time you click "build project".
> 
> So, I guess to support this style of project, the cdt generator
> should call cmExtraEclipseCDT4Generator::AppendLinkedResource()
> once for each call in my outer CMakeLists.txt like
> add_subdirectory(../libsrc libsrc).

Ok. So two things:
* please give current cmake master a try, it has several improvements.
* please create a ticket in the cmake bug tracker for this, improved source-
project generator for Eclipse, or something like this.

My goal is to have no open bugs for Eclipse when 2.8.7 wil be released.

Alex


More information about the CMake mailing list