[CMake] Building statically linked executables
Marcel Loose
loose at astron.nl
Wed Nov 4 05:04:00 EST 2009
Hi all,
I would like to be able to build statically linked executables. I
currently have the following statements in one of my initialization
macros:
if(BUILD_STATIC_EXECUTABLES)
set(CMAKE_EXE_LINKER_FLAGS -static)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
# Maybe this works as well, haven't tried yet.
# set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
endif(BUILD_STATIC_EXECUTABLES)
Does this cover all affected CMake variables, or am I still missing
some.
Note that this question is partly related to an earlier question of
mine, "Static linking and find_library()", which can be found at
http://www.mail-archive.com/cmake@cmake.org/msg21106.html
Best regards,
Marcel Loose.
More information about the CMake
mailing list