CMake: Use static libstdc++ for static builds

This enables static linking of libstdc++ by default when building using
`WITH_STATIC_LIBS`. This makes builds more portable for anyone making
static builds (in particular for older systems).

Reviewed By: brecht, campbellbarton, sergey

Differential Revision: https://developer.blender.org/D4393
This commit is contained in:
Luca Rood
2019-03-02 02:53:09 +01:00
parent 490a385c81
commit d5c2be7031
4 changed files with 7 additions and 3 deletions

View File

@@ -39,6 +39,10 @@ if(EXISTS ${LIBDIR})
set(WITH_OPENMP_STATIC ON) set(WITH_OPENMP_STATIC ON)
endif() endif()
if(WITH_STATIC_LIBS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
endif()
# Wrapper to prefer static libraries # Wrapper to prefer static libraries
macro(find_package_wrapper) macro(find_package_wrapper)
if(WITH_STATIC_LIBS) if(WITH_STATIC_LIBS)