[CMake] add_subdirectory and eclipse project

Andrea Galeazzi galeazzi at korg.it
Tue Feb 8 05:42:36 EST 2011


Il 18/01/2011 19.17, Alexander Neundorf ha scritto:
> On Tuesday 18 January 2011, Andrea Galeazzi wrote:
> ...
>> I just read that wiki page but what I didn't find is how can I see the
>> sources referenced by the add_subproject function in the layout  of
>> eclipse project.
> You mean add_subdirectory(), right ?
>
>> In other words, CMake generates an eclipse project with a folder named
>> [Source directory], containing just only the sources listed in the
>> CMakeLists.txt but it doesn't allow to see the sources included by
>> add_subproject.
> There should be subdirectories there which you should be able to open, which
> should show the files.
>
> Which exact version of cmake are you using ?
>
> Alex
>
> __________ Informazioni da ESET NOD32 Antivirus, versione del database delle firme digitali 5798 (20110118) __________
>
> Il messaggio و stato controllato da ESET NOD32 Antivirus.
>
> www.nod32.it
>
>
>
>
Yes I meant add_subdirectory and I'm using 2.8.3 version.
The point is that the path passed as argument to the add_subdirectory 
function isn't necessary a real filesystem subdirectory of the current 
CMakeLists.txt so, in this case, it cannot be browsed by the resource 
view of eclipse.
To be more specific don't you think it'd better to generate a .project 
containing more links than only [Source directory]?
i.e.:
<linkedResources>
<link>
<name>[Source directory]</name>
<type>2</type>
<location>/Project/Prj</location>
</link>
</linkedResources>

vs:
<linkedResources>
<link>
<name>Main Project</name>
<type>2</type>
<location>/Project/Prj</location>
</link>
<link>
<name>LibName</name>
<type>2</type>
<location>/Libs/Lib1</location>
</link>
</linkedResources>

where libName is the name declared in the project() statement of 
CMakeLists.txt of /Libs/Lib1.
This behavior should be more similar to the Visual Studio generator.
So far I made a workaround writing a script which parse a CMakeLists.txt 
and invokes CMake to generate one eclipse project for each 
add_subdirectory entry. Then I import all projects in a workspace.
I dislike a such solution but that's the only way to browse all sources 
that I found.
I  hope my suggestion will be taken into account for the next 
releases... and sorry for the late answer!
Andrea




More information about the CMake mailing list