pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ivankelly commented on a change in pull request #3488: Build static lib with bundled dependencies
Date Thu, 31 Jan 2019 15:09:26 GMT
ivankelly commented on a change in pull request #3488: Build static lib with bundled dependencies
URL: https://github.com/apache/pulsar/pull/3488#discussion_r252705032
 
 

 ##########
 File path: pulsar-client-cpp/lib/CMakeLists.txt
 ##########
 @@ -31,21 +31,41 @@ ADD_CUSTOM_COMMAND(
          ../../pulsar-common/src/main/proto/PulsarApi.proto
          WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 
-add_library(pulsarStatic STATIC ${PULSAR_SOURCES} PulsarApi.pb.h PulsarApi.pb.cc)
-add_library(pulsarShared SHARED ${PULSAR_SOURCES} PulsarApi.pb.h PulsarApi.pb.cc)
-
 set(LIBRARY_VERSION $ENV{PULSAR_LIBRARY_VERSION})
 if (NOT LIBRARY_VERSION)
     set(LIBRARY_VERSION ${PV})
 endif(NOT LIBRARY_VERSION)
 
-set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})
-set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})
 
-target_link_libraries(pulsarStatic ${COMMON_LIBS})
+add_library(pulsarShared SHARED ${PULSAR_SOURCES} PulsarApi.pb.h PulsarApi.pb.cc)
+set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})
 target_link_libraries(pulsarShared ${COMMON_LIBS})
 
-install(TARGETS pulsarStatic DESTINATION lib)
-install(TARGETS pulsarShared DESTINATION lib)
+add_library(pulsarStatic STATIC ${PULSAR_SOURCES} PulsarApi.pb.h PulsarApi.pb.cc)
+set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION})
 
+# When linking statically, install a libpulsar.a that contains all the
+# required dependencies
+if (LINK_STATIC)
+    # Build a list of the requird .a libs to merge
+    SET(STATIC_LIBS "")
+    foreach (LIB IN LISTS COMMON_LIBS)
+        if (${LIB} MATCHES ".+\\.a")
+            set(STATIC_LIBS "${STATIC_LIBS} ${LIB}")
+        endif()
+    endforeach()
+
+    add_custom_target(pulsarStaticWithDeps
+            ALL
+            BYPRODUCTS merged-library
+            COMMAND ./build-support/merge_archives.sh libpulsar.a $<TARGET_FILE:pulsarStatic>
${STATIC_LIBS}
+            DEPENDS pulsarStatic
+            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
 
 Review comment:
   Would be good to do it inside a directory that's ignored by git since it's creating a directory.
Or maybe delete the directory after the run.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message