]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: add WITH_STATIC_LIBSTDCXX option
authorKefu Chai <kchai@redhat.com>
Sat, 9 Dec 2017 11:27:03 +0000 (19:27 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 11 Dec 2017 16:26:52 +0000 (00:26 +0800)
to link libceph-common with libstdc++ if it is enabled.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
src/CMakeLists.txt

index b08365481b7b149046701ba76bee6d0bf08c7a3e..576525db6cc971ef0fab6775f195e80c89b68027 100644 (file)
@@ -169,6 +169,13 @@ else(ENABLE_SHARED)
 endif(ENABLE_SHARED)
 set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED})
 
+option(WITH_STATIC_LIBSTDCXX "Link against libstdc++ statically" OFF)
+if(WITH_STATIC_LIBSTDCXX)
+  if(NOT CMAKE_COMPILER_IS_GNUCXX)
+    message(FATAL_ERROR "Please use GCC to enable WITH_STATIC_LIBSTDCXX")
+  endif()
+endif()
+
 option(WITH_RDMA "Enable RDMA in async messenger" ON)
 if(WITH_RDMA)
   find_package(rdma REQUIRED)
index c835525f917383ab95cb34cd39f5f6a17382e9fe..7179a9919ce18bd1e99fd586a8241b1c777d9b29 100644 (file)
@@ -690,6 +690,10 @@ target_link_libraries(ceph-common ${ceph_common_deps})
 set_target_properties(ceph-common PROPERTIES
   SOVERSION 0
   INSTALL_RPATH "")
+if(WITH_STATIC_LIBSTDCXX)
+  set_target_properties(ceph-common PROPERTIES
+    LINK_FLAGS "-static-libstdc++ -static-libgcc")
+endif()
 install(TARGETS ceph-common DESTINATION ${CMAKE_INSTALL_PKGLIBDIR})
 
 add_library(common_utf8 STATIC common/utf8.c)