diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -46,6 +46,7 @@ option(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." ON) option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) +option(LIBCXXABI_ENABLE_PIC "Build Position-Independent Code, even in static library" ON) option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF) diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -176,6 +176,10 @@ cxxabi_object_library(cxxabi_static_objects) endif() +if(LIBCXXABI_ENABLE_PIC) + set_target_properties(cxxabi_static_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) +endif() + cxxabi_object_library(cxxabi_shared_objects POSITION_INDEPENDENT_CODE ON) set(cxxabi_static_sources $) set(cxxabi_shared_sources $)