MantisBT - CMake
View Issue Details
0011891CMakeCMakepublic2011-02-24 03:212013-01-04 08:54
jfbos2 
Bill Hoffman 
normalmajoralways
closedfixed 
Windows
CMake 2.8.4 
CMake 2.8.5CMake 2.8.5 
0011891: Visual Studio 2010 Generator 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/Test/Projects/CMake2010Bug/stack.obj" />
  </ItemGroup>
...

Instead it should read:
  <ItemGroup>
    <Object Include="C:/Users/Test/Projects/CMake2010Bug/stack.obj" />
  </ItemGroup>
1) Use the following CMakeLists.txt:
------------------------------------
cmake_minimum_required(VERSION 2.6)
project(testProj CXX)
add_executable(test main.cpp stack.obj)
# the following doesn't seem to affect anything, at least with VS2010 Generator
set_source_files_properties( stack.obj PROPERTIES EXTERNAL_OBJECT TRUE )
-------------------------------------

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
visual studio 2010
duplicate of 0011896closed Bill Hoffman ".obj" or ".o" listed in ADD_LIBRARY does not get included in Visual Studio project, NMake build works 
related to 0013047closed Brad King Visual Studio 2010 Generator and "PROPERTIES GENERATED 1" 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 
txt CMakeLists.txt (272) 2011-02-24 03:21
https://public.kitware.com/Bug/file/3725/CMakeLists.txt
Issue History
2011-02-24 03:21jfbos2New Issue
2011-02-24 03:21jfbos2File Added: CMakeLists.txt
2011-02-24 03:26jfbos2Tag Attached: visual studio 2010
2011-03-31 18:06Bill HoffmanRelationship addedduplicate of 0011896
2011-03-31 18:08Bill HoffmanNote Added: 0026002
2011-04-04 17:28Bill HoffmanNote Added: 0026088
2011-04-04 17:28Bill HoffmanStatusnew => closed
2011-04-04 17:28Bill HoffmanAssigned To => Bill Hoffman
2011-04-04 17:28Bill HoffmanResolutionopen => fixed
2011-04-14 14:39David ColeFixed in Version => CMake 2.8.5
2011-04-14 14:39David ColeTarget Version => CMake 2.8.5
2012-03-19 08:47Brad KingRelationship addedrelated to 0013047
2013-01-04 08:54Brad KingRelationship addedrelated to 0013831

Notes
(0026002)
Bill Hoffman   
2011-03-31 18:08   
The odd thing is that our test for this is passing. Something must be wrong with the test... It is called ExternalObj, it builds a .o with a try-compile, then uses that as part of the main project. For some reason it works. But the example in the bug that is a duplicate of this one does not...
(0026088)
Bill Hoffman   
2011-04-04 17:28   
This if fixed in git next.