MantisBT - CMake
View Issue Details
0013047CMakeCMakepublic2012-03-17 08:112013-01-04 08:47
Petr Pospíšil 
Brad King 
normalmajoralways
closedfixed 
Windows
CMake 2.8.7 
CMake 2.8.8CMake 2.8.8 
0013047: Visual Studio 2010 Generator and "PROPERTIES GENERATED 1" adds .obj as "not part of this build" to projects
When you add .obj files that already exist and want to add them
to the executable or library sources, the Visual Studio 2010 Generator
add the file to the Project but it is marked as "not part of this build"
and not linked with the executable or library.

If you look in the .vxproj file is says..:
...
  <ItemGroup>
    <None Include="C:/Users/PETR2/Desktop/bug/build/aaaa.obj" />
  </ItemGroup>
...

Instead it should read:
  <ItemGroup>
    <Object Include="C:/Users/PETR2/Desktop/bug/build/aaaa.obj" />
  </ItemGroup>
1) Use the following CMakeLists.txt:
------------------------------------
cmake_minimum_required(VERSION 2.8)
project(bug CXX)

set( obj_file aaaa.obj )
set_source_files_properties( ${obj_file} PROPERTIES GENERATED 1)
add_executable(main main.cpp ${obj_file})
-------------------------------------

with simple main.cpp and any .obj file,

2) run cmake with Visual Studio 2010 Generator
3) Open solution -> stack.obj is added as "Not part of this build"
   and the object file is not linked with the executable or library
No tags attached.
related to 0011147closed David Cole VC10 error "item ... already exists under the filter" 
related to 0011891closed Bill Hoffman Visual Studio 2010 Generator adds .obj as "not part of this build" to projects 
related to 0013831closed Brad King VS 2012 generator doesn't always respect the EXTERNAL_OBJECT propery 
Issue History
2012-03-17 08:11Petr PospíšilNew Issue
2012-03-19 08:47Brad KingRelationship addedrelated to 0011147
2012-03-19 08:47Brad KingRelationship addedrelated to 0011891
2012-03-19 08:49Brad KingNote Added: 0028933
2012-03-19 08:50Brad KingAssigned To => Brad King
2012-03-19 08:50Brad KingStatusnew => assigned
2012-03-19 11:50Petr PospíšilNote Added: 0028937
2012-03-19 11:59Brad KingNote Added: 0028938
2012-03-20 09:46Brad KingNote Added: 0028942
2012-03-20 09:46Brad KingStatusassigned => resolved
2012-03-20 09:46Brad KingFixed in Version => CMake 2.8.8
2012-03-20 09:46Brad KingResolutionopen => fixed
2012-04-19 15:54David ColeTarget Version => CMake 2.8.8
2012-09-03 16:02David ColeNote Added: 0030887
2012-09-03 16:02David ColeStatusresolved => closed
2013-01-04 08:47Brad KingRelationship addedrelated to 0013831

Notes
(0028933)
Brad King   
2012-03-19 08:49   
Some .obj support was added here:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cde56dd [^]

and later updated here:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9a6ff950 [^]

The latter introduces this problem by assuming that if an object is marked GENERATED then it means it is generated in the current target. If it is generated by a custom command in the current target then VS includes it in the build automatically. The bug is when it is generated elsewhere.
(0028937)
Petr Pospíšil   
2012-03-19 11:50   
Thats right, the program uses some object files generated by NASM compiler as add_custom_target.
(0028938)
Brad King   
2012-03-19 11:59   
I actually encountered this problem last week while working on some other changes related to object files. That work refactors some of the relevant code. I had a topic branch set aside to address this problem which I'll rebase on the other work when it is finished. Then I'll report back here.
(0028942)
Brad King   
2012-03-20 09:46   
Fixed and test added:
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=328c0f6 [^]
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b291d9e [^]
(0030887)
David Cole   
2012-09-03 16:02   
Closing resolved issues that have not been updated in more than 4 months.