[linux] statically link the C++ standard library

Most of the STL is header-only anyway, and statically linking it only has a small overhead. On the other hand, it allows us to build more portable executables.
This commit is contained in:
Konstantin Käfer
2018-05-29 12:28:14 +02:00
parent be66de6fcd
commit 0b305aca7d
2 changed files with 9 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4)
project(mbgl LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 14)
option(WITH_CXX11ABI "Use cxx11abi mason packages" OFF)
option(WITH_CXX11ABI "Use the C++11 ABI" OFF)
option(WITH_COVERAGE "Enable coverage reports" OFF)
option(WITH_OSMESA "Use OSMesa headless backend" OFF)
option(WITH_EGL "Use EGL backend" OFF)

View File

@@ -99,6 +99,14 @@ macro(mbgl_platform_core)
target_link_libraries(mbgl-core
PUBLIC -lz
)
if(WITH_CXX11ABI)
# Statically link libstdc++ when we're using the new STL ABI
target_link_libraries(mbgl-core
PUBLIC -static-libstdc++
PUBLIC -Wl,-Bsymbolic-functions
)
endif()
endmacro()