[cmake-developers] GCC link options

Brad King brad.king at kitware.com
Thu Jul 26 10:21:36 EDT 2012


On 07/25/2012 04:57 PM, J Decker wrote:
> Is there a super simple way to get the current build command for say
> exectuable, string(replace) it, and then execute it in a custom
> target?

There is no hook into the final generation.  You can hack the
rule variable to add options at the end, though this is not
officially supported:

 set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} liblast.a")

> that is the behavior I observe, but, I don't understand why a library
> would be inserted in the middle of a set of libraries...

Static libraries do not themselves link.  The target_link_libraies
calls for them only specify their dependencies.  Those dependencies
are normally only other libraries, not flags.  The final link line
is computed only on targets that really link.  The method used to
compute it is documented in comments in the source here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmComputeLinkDepends.cxx;hb=v2.8.8#l25

-Brad



More information about the cmake-developers mailing list