MantisBT - CMake
View Issue Details
0012223CMakeCMakepublic2011-05-25 03:462011-10-23 09:07
wAy 
Alex Neundorf 
normalfeaturealways
closedfixed 
anyanyany
CMake 2.8.3 
 
0012223: Support of linked resources in Eclipse/CDT (single files, not folders)
When you´d like to add a single file that is placed outside the regular source folder, you can use the "linked resource" function of Eclipse/CDT.
Using this you will get a link to a single file within your project, that can be edited, compiled, etc. as if it was in your source folder.

At the moment it (seems that it(?)) isn´t possible to create links when using CMake to create a Eclipse project. The files will be compiled, as they should, but you won´t be able to see them in the Eclipse project explorer.
e.g. add_library( foo A_FILE_OUTSIDE_OF_THE_REGULAR_SOURCE_FOLDER)

cmake -G "Eclipse CDT4 - Unix Makefiles"

File->Import->Existing Projects into Workspace
CDT, Eclipse, linked resource
related to 0012417closed Alex Neundorf CDT4 generator: source path configured incorrectly 
has duplicate 0012294closed Alex Neundorf Sources outside of source directory aren't included in Eclipse Project view 
related to 0012213closed Alex Neundorf Eclipse CDT4 Generator: Incompleted <linkedResources> 
related to 0012479closed Alex Neundorf Generated Eclipse CDT files only valid for >= Helios (3.6) 
related to 0011723closed Alex Neundorf Eclipse: "Build project" and "Clean project" do not work 
related to 0012392closed Alex Neundorf CMakeFindEclipseCDT4.cmake ignores CMAKE_CXX_COMPILER_ARG1 in compiler invocation 
related to 0012579closed Alex Neundorf Improve project generator for eclipse to handle multiple top level directories 
Issue History
2011-05-25 03:46wAyNew Issue
2011-05-25 03:47wAyTag Attached: CDT
2011-05-25 03:47wAyTag Attached: Eclipse
2011-05-25 03:47wAyTag Attached: linked resource
2011-05-25 15:30Alex NeundorfAssigned To => Alex Neundorf
2011-05-25 15:30Alex NeundorfStatusnew => assigned
2011-05-25 15:36Alex NeundorfNote Added: 0026577
2011-05-26 02:51wAyNote Added: 0026613
2011-05-26 02:52wAyNote Edited: 0026613bug_revision_view_page.php?bugnote_id=26613#r340
2011-09-30 14:54Alex NeundorfRelationship addedrelated to 0012213
2011-09-30 14:54Alex NeundorfRelationship addedrelated to 0012417
2011-09-30 14:56Alex NeundorfRelationship addedhas duplicate 0012294
2011-09-30 15:17Alex NeundorfRelationship addedrelated to 0012479
2011-09-30 15:20Alex NeundorfRelationship addedrelated to 0011723
2011-09-30 15:20Alex NeundorfRelationship addedrelated to 0012392
2011-10-23 09:07Alex NeundorfNote Added: 0027627
2011-10-23 09:07Alex NeundorfStatusassigned => closed
2011-10-23 09:07Alex NeundorfResolutionopen => fixed
2011-11-15 11:48Alex NeundorfRelationship addedrelated to 0012579

Notes
(0026577)
Alex Neundorf   
2011-05-25 15:36   
Indeed.
How should this be done ?
I could add special variables like CMAKE_ECLIPSE_LINKED_FOLDERS, which you could set to a list of folders for which linked resources are created.
Or more general a list of files or directories for which linked resources are created.

But maybe we can reuse something which already exists in cmake.
How about using the source_group() command for this in Eclipse ?
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:source_group [^]

So you could say
source_group(MyFavouriteFiles FILES abc.c foo.c bar.c)

and it would create a virtual folder named "MyFavouriteFiles" which contains links to the listed files.

What do you think ?

Alex
(0026613)
wAy   
2011-05-26 02:51   
(edited on: 2011-05-26 02:52)
Well,

at the moment our linked files look like this in the .project file:

<linkedResources>
    <link>
    <name>Foobar.cpp</name>
        <type>1</type>
    <location>../foo/Foobar.cpp</location>
    </link>
    <link>
        ...
    </link>
</linkedResources>

So, there are no extra folders for the linked files. However, I think that there are many people, who prefer to have those files grouped also.

So what about something like:
CMAKE_ECLIPSE_LINKED_FILES where you may list all files:
set( CMAKE_ECLIPSE_LINKED_FILES ../foo1/bar1.cpp ../foo2/bar2.cpp ../foo2/bar3.cpp)

and a second one CMAKE_ECLIPSE_LINKED_FILES_FOLDER:
set( CMAKE_ECLIPSE_LINKED_FOLDERS folder_for_my_linked_files )

This one could create those linked resources at top level if not set and otherwise a folder, where the linked files will be found in?

Grouped folders won´t work, because if there are files in the same folder, that don´t belong to the project, you will see them within your project. At least, you can something similar to this with out-of-source-builds already.

I don´t know if this is acceptable for you or fits to the concept cmake follows, but if so, I would prefer something that works in this way.

Anyway, I would be happy about everything that makes it possible to link single files and see them in the eclipse project explorer. :-)

Regards,
wAy

(0027627)
Alex Neundorf   
2011-10-23 09:07   
The generated project now contains a virtual folder [Targets], where each target is again a sub-virtual folder, which contains links to all its source files, no matter where they are located.

This is now in the "next" branch of cmake.
Please give it a try and let me know if something doesn't work.