[CMake] Creating static executables

Bill Hoffman bill.hoffman at kitware.com
Sun Jun 10 10:20:34 EDT 2007


Alan W. Irwin wrote:
> On 2007-06-09 10:22+0400 Nikita V. Borodikhin wrote:
>
>>> I frankly don't understand why that failed to work.  Completely static
>>> executables are possible with cmake. I know this because I made one 
>>> several
>>> months ago as a temporary experiment.
>>
>> They _were_ possible but on cmake >= 2.4.4 they are no longer possible
>> without setting some variables in CMakeLists.txt (not command line!).
>>
>> Details: http://www.cmake.org/Bug/bug.php?op=show&bugid=5087&pos=13
>
> Ouch!  That issue is perhaps not something that most Linux users will run
> into every day (very few build static executables any more), but static
> builds are really fundamental.  Therefore, for the reputation of CMake, I
> hope a CMake developer will be able to fix bug 5087 before 2.4.7.  
> This should
> not take much time since it looks like Nikita has pinpointed where the
> error occurs in his bug report.
So, there is a new work around for this problem.  If you set this variable:

CMAKE_EXE_LINK_DYNAMIC_C_FLAGS "-Wl,-Bstatic"
That should causes a static link.   For all exe in the project.  As a new
feature a LINK_STATIC property should be supported in exe targets,
but this work around should be good enough for 2.4.7.

-Bill



More information about the CMake mailing list