On 09/12/2013 04:57 PM, James Bigler wrote:
> This seems kind of confusing when the default for all the other VS
> generators is to link in the output of the custom command.  Does
> that not seem like a problem?

The goal is to link all .obj files listed in the target exactly once.
According to Tests/ExternalOBJ/CMakeLists.txt this is tested and
works everywhere:

------------------------------------------------------------------------
 # Test creation of external objects by custom commands.
 set(CUSTOM_OBJECT
   ${CMAKE_CURRENT_BINARY_DIR}/custom_object${CMAKE_C_OUTPUT_EXTENSION})
 add_custom_command(
   OUTPUT ${CUSTOM_OBJECT}
   COMMAND ${CMAKE_COMMAND} -E copy ${EXTERNAL_OBJECT} ${CUSTOM_OBJECT}
   DEPENDS ${EXTERNAL_OBJECT}
   )

 message("${EXTERNAL_OBJECT}")
 # Build an executable using the external object file.
 add_executable(ExternalOBJ executable.cxx ${CUSTOM_OBJECT})
 # A bug showed up in VS2010 where an object file that was
 # part of a custom commad output worked, but ones that were
 # not didn't work.  So, repeat the executable using the object
 # directly and not from the output of the copy.
 add_executable(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT})
------------------------------------------------------------------------

Special changes were needed to work around VS 10 and 11 behavior of
automatically linking custom command outputs that are objects.
I do not think that happens with VS < 10.  In VS 10 we let it link
the custom command output and reference the .obj as <None>.  In
VS 11 we set LinkObjects to false in the custom command and refer
to the .obj with <Object>.  This is all tested as shown above.

I do not see how MAIN_DEPENDENCY can influence this.  It only affects
where the custom command is attached.

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to