2 ms·
It's not that difficult to get CMake to build a static binary. SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") SET(BUILD_SHARED_LIBRARIES OFF) SET(CMAKE_EXE_LINKER
by colin_mccabe 12y ago
It's not that difficult to get CMake to build a static binary.
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
The bigger problems with building a static binary on Linux are that:
1. Most Linux distros don't install static versions of libraries. You can't link in a static library dependency that doesn't exist.
2. glibc can't "really" be linked statically because of the way it's designed. See here for the gory details: https://gcc.gnu.org/ml/gcc/1998-12/msg00083.html https://gcc.gnu.org/ml/gcc/1998-12/msg00083.html
Naturally, you have problems #1 and #2 with autotools or any other build system as well, since they aren't CMake problems.