]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: use ENABLE_SHARED instead of BUILD_SHARED_LIBS 9446/head
authorKefu Chai <kchai@redhat.com>
Sat, 4 Jun 2016 01:50:00 +0000 (09:50 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 4 Jun 2016 04:57:19 +0000 (12:57 +0800)
we decided to drop the static libraries from the *-dev debian packages.
so no more tricky changes for supporting creating both libraries.

* partially revert 1dbfb26: s/BUILD_SHARED_LIBS/ENABLE_SHARED/
 - add_library() command use BUILD_SHARED_LIBS as the default library
   type, and all intermediate libraries should static ones. it would
   cause unnecessary confusion if some developer uses add_library() without
   specifying the library type, and ends up with a .so. so we use our
   own setting variables for specifying the type of user facing libraries.
* revert ac47440
 - the BUILD_SHARED_LIBS setting is also populated to the gmock libraries,
   which should be compiled as static ones. otherwise the unit tests will
   crash on exit.

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

index 26f4d17ff62ab9c7504edf10c1572a5b7f71d576..9956aa80cb83335b573c2edcfd4a1095c2b27cc0 100644 (file)
@@ -150,6 +150,13 @@ CHECK_CXX_SOURCE_COMPILES("
 
 set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).")
 
+option(ENABLE_SHARED "build shared libraries" ON)
+if(ENABLE_SHARED)
+  set(CEPH_SHARED SHARED)
+else(ENABLE_SHARED)
+  set(CEPH_SHARED STATIC)
+endif(ENABLE_SHARED)
+
 option(BUILD_SHARED_LIBS "Build shared libraries" ON)
 
 find_package(execinfo)
@@ -347,11 +354,11 @@ option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF)
 
 add_definitions(-D__linux__)
 
-if(BUILD_SHARED_LIBS)
+if(ENABLE_SHARED)
   set(Boost_USE_STATIC_LIBS   OFF)
-else(BUILD_SHARED_LIBS)
+else(ENABLE_SHARED)
   set(Boost_USE_STATIC_LIBS   ON)
-endif(BUILD_SHARED_LIBS)
+endif(ENABLE_SHARED)
 
 set(Boost_USE_MULTITHREADED ON)
 find_package(Boost COMPONENTS thread system regex random program_options date_time iostreams REQUIRED)
index 5b7606cf1681bf216b12b7d262b55b468bc27b8b..b62a479d8ea9f5b4ec2be4e7a42e109757151dd6 100644 (file)
@@ -508,10 +508,6 @@ target_link_libraries(global common ${CMAKE_THREAD_LIBS_INIT} ${CRYPTO_LIBS}
 if(${WITH_LTTNG})
   target_link_libraries(global lttng-ust dl)
 endif(${WITH_LTTNG})
-if(BUILD_SHARED_LIBS)
-  set_target_properties(global PROPERTIES
-    OUTPUT_NAME ceph-global VERSION "1.0.0" SOVERSION "1")
-endif(BUILD_SHARED_LIBS)
 
 # rados object classes
 add_subdirectory(cls)
@@ -533,7 +529,7 @@ set(librados_srcs
   librados/snap_set_diff.cc
   librados/RadosXattrIter.cc
   )
-add_library(librados ${librados_srcs}
+add_library(librados ${CEPH_SHARED} ${librados_srcs}
   $<TARGET_OBJECTS:cls_references_objs>
   $<TARGET_OBJECTS:common_util_obj>)
 add_dependencies(librados osdc)
@@ -543,10 +539,10 @@ endif()
 # LINK_PRIVATE instead of PRIVATE is used to backward compatibility with cmake 2.8.11
 target_link_libraries(librados LINK_PRIVATE osdc osd os global common cls_lock_client
   ${BLKID_LIBRARIES} ${CRYPTO_LIBS} ${EXTRALIBS})
-if(BUILD_SHARED_LIBS)
+if(ENABLE_SHARED)
   set_target_properties(librados PROPERTIES OUTPUT_NAME rados VERSION 2.0.0
     SOVERSION 2)
-endif(BUILD_SHARED_LIBS)
+endif(ENABLE_SHARED)
 
 add_library(librados_api STATIC common/buffer.cc librados/librados.cc)
 
@@ -996,11 +992,7 @@ target_link_libraries(crushtool global)
 install(TARGETS crushtool DESTINATION bin)
 
 # Support/Tools
-# the static gtest/gmock libraries load correctly for us
-set(BUILD_SHARED_LIBS_saved ${BUILD_SHARED_LIBS})
-set(BUILD_SHARED_LIBS OFF)
 add_subdirectory(gmock)
-set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_saved})
 
 add_subdirectory(test)
 set(cephfs_srcs cephfs.cc)
@@ -1123,16 +1115,16 @@ if(WITH_LIBCEPHFS)
   add_library(client STATIC ${libclient_srcs})
   target_link_libraries(client osdc mds)
   set(libcephfs_srcs libcephfs.cc)
-  add_library(cephfs ${libcephfs_srcs}
+  add_library(cephfs ${CEPH_SHARED} ${libcephfs_srcs}
     $<TARGET_OBJECTS:cls_references_objs>
     $<TARGET_OBJECTS:common_util_obj>)
   target_link_libraries(cephfs LINK_PRIVATE client osdc osd os global common
     ${BLKID_LIBRARIES}
     ${CRYPTO_LIBS} ${EXTRALIBS})
-if(BUILD_SHARED_LIBS)
+if(ENABLE_SHARED)
   set_target_properties(cephfs PROPERTIES OUTPUT_NAME cephfs VERSION 1.0.0
     SOVERSION 1)
-endif(BUILD_SHARED_LIBS)
+endif(ENABLE_SHARED)
   install(TARGETS cephfs DESTINATION lib)
   install(DIRECTORY
     "${CMAKE_SOURCE_DIR}/src/include/cephfs"
index beb7ac2fe99712efc82d20272d52a993ead35bae..33055d8ca7bcec7b5da009937560b5c515792351 100644 (file)
@@ -68,7 +68,7 @@ if(WITH_LTTNG)
   add_dependencies(rbd_internal rbd-tp)
 endif()
 
-add_library(librbd
+add_library(librbd ${CEPH_SHARED}
   $<TARGET_OBJECTS:osdc_rbd_objs>
   $<TARGET_OBJECTS:common_util_obj>
   $<TARGET_OBJECTS:krbd_objs>
@@ -90,8 +90,8 @@ target_link_libraries(librbd LINK_PRIVATE
   keyutils
   ${CMAKE_DL_LIBS}
   ${EXTRALIBS})
-if(BUILD_SHARED_LIBS)
+if(ENABLE_SHARED)
   set_target_properties(librbd PROPERTIES VERSION "1.0.0" SOVERSION "1"
     OUTPUT_NAME rbd)
-endif(BUILD_SHARED_LIBS)
+endif(ENABLE_SHARED)
 install(TARGETS librbd DESTINATION lib)