[CMake] Howto compile static executable?

Eric Noulard eric.noulard at gmail.com
Tue Sep 28 12:57:40 EDT 2010


Hi All,

I have project which (cross-)compile some simple C applications
with some bare CMake statement like this:

add_executable(myapp myapp.c)

no target_link_libraries, no dep,  etc...

I want to build fully static executable (even for libc etc...)
Currently I do:

set_target_properties(myapp PROPERTIES LINK_FLAGS_DEBUG "-static")

is there a better and portable way to require "static" executable?

I am aware of the BUILD_SHARED_LIBS var for globally controlling
static vs dynamic libs but how can I do for executable?

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list