[cmake-developers] CMAKE_<lang>_LINK_EXECUTABLE and BG/Q

Brad King brad.king at kitware.com
Mon Apr 14 09:19:44 EDT 2014


On 04/12/2014 06:49 PM, Todd Gamblin wrote:
> What would it take to give CMake some way to mark an executable
> as static or dynamic?  How is this done on other platforms?
> Do people typically just set extra linker flags on an exe when
> they want it to be static? Or is there a target property that
> controls this?

CMake currently has no first-class interface to request linking
that is fully static (i.e. against the language runtime libraries).
There is no fundamental reason for this, it just has not been added.
Currently people doing static builds just set up the flags locally,
such as in CMAKE_EXE_LINKER_FLAGS.

However, implementing it in general is not a trivial transition from
current behavior.  On some platforms, such as MS tools on Windows,
the compiler flags need to be different when the object files will
be linked against a static runtime library.  Currently those flags
are in CMAKE_<LANG>_FLAGS_<CONFIG> and projects just replace them
for local builds when static linking is required.  Any solution
to static linking would have to end up as a compile-time property
that propagates through all objects in all targets involved in the
link.  This is why it is basically in the global flags right now.

There is also a thread on this list a while back:

 push of LinkOptionsCommand topic branch
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/9203

discussing a LINK_OPTIONS build property and INTERFACE_LINK_OPTIONS
usage requirement property that may end up being useful to a full
solution to this problem.

-Brad




More information about the cmake-developers mailing list