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 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
