MantisBT - CMake
View Issue Details
0014532CMakeCMakepublic2013-10-31 11:102014-06-02 08:37
Steve Wolak 
Brad King 
normalcrashalways
closedfixed 
WindowsWindows7 x64
CMake 2.8.12 
CMake 2.8.12.1CMake 2.8.12.1 
0014532: CMake internal error: cmTarget::GetOutputInfo
I created an object library and then attempted to reference the target in a custom command using $<TARGET_FILE:tgt>. This caused the following:

cmTarget::GetOutputInfo called for my_obj which has type OBJECT_LIBRARY



This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
System error 768.
Using CMake for Win32 on Windows 7 x64

Create an object target:

add_library(my_obj OBJECT my_src.cpp)

Use the object target in a shared library:

add_library(my_lib SHARED $<TARGET_OBJECTS:sc_lo_obj> my_lib.rc)

Attempt to copy the object target using a custom command (a post build command on the library):

add_custom_command (TARGET my_lib
                POST_BUILD
                COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:my_obj> ${OUTPUT_DIR}/my_obj_renamed.obj
                )
I was looking for a way to copy an object file from the intermediate directory to a directory of our choosing. Seeing the OBJECT library option, I figured I'd give this a shot to see what would happen.

No tags attached.
Issue History
2013-10-31 11:10Steve WolakNew Issue
2013-11-01 10:30Brad KingNote Added: 0034304
2013-11-01 10:30Brad KingAssigned To => Brad King
2013-11-01 10:30Brad KingStatusnew => resolved
2013-11-01 10:30Brad KingResolutionopen => fixed
2013-11-01 10:30Brad KingFixed in Version => CMake 3.0
2013-11-01 10:30Brad KingTarget Version => CMake 3.0
2013-11-05 07:45Brad KingFixed in VersionCMake 3.0 => CMake 2.8.12.1
2013-11-05 07:45Brad KingTarget VersionCMake 3.0 => CMake 2.8.12.1
2014-06-02 08:37Robert MaynardNote Added: 0036002
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0034304)
Brad King   
2013-11-01 10:30   
Thanks for the report.

Crash replaced with error message and test case added:

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

The $<TARGET_FILE:...> generator expression does not make sense for object libraries because there is no "library" file and there can be many object files.

As for your original objective, to copy an object file, that will require a new CMake feature to do portably. It may be tricky when it comes features like CMAKE_OSX_ARCHITECTURES that end up with more than one object file per source file (one per architecture per source). Currently object files are not first-class objects in IDE build tools (VS, Xcode) so it is hard to make them first-class objects for CMake. Anyway, this feature is beyond the scope of this issue tracker entry.
(0036002)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.