On 07/25/2012 02:12 PM, J Decker wrote:
> target_link_libraries(  playcard --whole-archive
> eltanin_sdl_deadstart_end --no-whole-archive ${COMMON_LIBRARIES} )
> (the output link line looks like .....  libplaycard.a --whole-archive
> eltanin_sdl_deadstart_end.a libcommon.a --no-whole-archive )

The only ordering guarantee is that the target being linked
(final executable or shared library) has its own sequence
first as specified by target_link_libraries.  Transitive
dependencies of the libraries named at the first level will
all appear in order but may have other things inserted.

The only reliable place to put flags is in the top-level call
to target_link_libraries for the target getting linked.  For
example:

 add_executable(foo foo.c)
 target_link_libraries(foo ${libs}
   --whole-archive ${special} --no-whole-archive)

will result in

 -o foo ${libs} --whole-archive ${special} --no-whole-archive ${depends}


Alternatively, using CMake 2.8.8 you can also use an object library:

 add_library(eltanin_sdl_deadstart_end OBJECT src.c)
 add_executable(foo foo.c $<TARGET_OBJECTS:eltanin_sdl_deadstart_end>)
 target_link_libraries(foo ${libs})

That will ensure the desired objects end up in the executable.
They will be listed explicitly on the link line as ".o" files.

-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