MantisBT - CMake
View Issue Details
0009978CMakeCMakepublic2009-11-30 10:232010-02-13 11:10
SNiLD 
Alex Neundorf 
normalmajoralways
closedfixed 
CMake-2-8 
 
0009978: Eclipse CDT generator creates invalid build targets (see attached example project)
Eclipse CDT generator creates invalid build targets for subprojects that try to add an executable. If the subdirectory contains an additional subdirectory without any project calls then the bug will not appear.
To reproduce:
Create following directory structure:

CMakeBug\CMakeBug
CMakeBug\Build

Extract the zip to CMakeBug\CMakeBug

Run following command in the CMakeBug\Build directory:

cmake -G"Eclipse CDT4 - NMake Makefiles" -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_BUILD_TYPE:STRING="Debug" ../CMakeBug

Import the project to eclipse.

When you try to make the target "[exe] Module1" you will get a message "NMAKE : fatal error U1073: don't know how to make 'Module1'" but all other targets are buildable.
No tags attached.
zip CMakeBug.zip (2,913) 2009-11-30 10:23
https://public.kitware.com/Bug/file/2698/CMakeBug.zip
Issue History
2009-11-30 10:23SNiLDNew Issue
2009-11-30 10:23SNiLDFile Added: CMakeBug.zip
2009-11-30 10:30Bill HoffmanStatusnew => assigned
2009-11-30 10:30Bill HoffmanAssigned To => Alex Neundorf
2009-12-01 16:37Alex NeundorfNote Added: 0018631
2009-12-02 04:54SNiLDNote Added: 0018640
2010-02-13 11:10Alex NeundorfNote Added: 0019526
2010-02-13 11:10Alex NeundorfStatusassigned => closed
2010-02-13 11:10Alex NeundorfResolutionopen => fixed

Notes
(0018631)
Alex Neundorf   
2009-12-01 16:37   
Yes, I can reproduce the problem.

But I don't understand what's wrong in the generated project file.
This is what is there:
<target name="[exe] Module1" path="Module1" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
<buildCommand>/usr/bin/gmake</buildCommand>
<buildArguments/>
<buildTarget>Module1</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
</target>

The target has the correct name ("Module1") and the directory is correct (also "Module1").
From the command line I can build "Module1" both from the toplevel dir as well as from the Module1 subdir.

It starts working also in Eclipse if I rename the project() in Module1/CMakeLists.txt to something else than "Module1".
It seems the problem is that the subdir has the same name as the project ?
For every project there is a linked resource created, which points to the source dir.
So for the "Module1" project there is a linked resource created which points to the "srcdir/Module1". In that directory there is no Makefile, but it seems eclipse executes make then from that directory, which fails.


Can you verify that ?
This would mean that the Module1 starts working when you rename the project "Module1" to something else (verified here), and that the other targets stop working if you name the project the same as the directory in which they are.

Alex
(0018640)
SNiLD   
2009-12-02 04:54   
Yes this is exactly how it works for me as well. I can make the target from command-line and I can make the target from Eclipse if I rename the project to other name than the executable.
(0019526)
Alex Neundorf   
2010-02-13 11:10   
I changed the generator so that now only one linked resource named [Source directory] is created, instead of one for each project.
This should avoid the name clashes and IMO this looks also much less confusing.

It would be nice if you could try cmake cvs HEAD to give it a try.

Alex