This is an automated email from the ASF dual-hosted git repository.

yangzhg pushed a commit to branch libhdfs3
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git

commit 0709cbbf64fafb9d483f799a452ea8d1be489a7d
Author: yangzhg <yangz...@gmail.com>
AuthorDate: Wed Jun 8 10:45:15 2022 +0800

    add option to disable or enable build shared/static libs
---
 CMake/Options.cmake |   2 +
 bootstrap           |  13 ++++-
 src/CMakeLists.txt  | 140 +++++++++++++++++++++++++++++++---------------------
 3 files changed, 99 insertions(+), 56 deletions(-)

diff --git a/CMake/Options.cmake b/CMake/Options.cmake
index 9f0922e..033be14 100644
--- a/CMake/Options.cmake
+++ b/CMake/Options.cmake
@@ -5,6 +5,8 @@ OPTION(ENABLE_FRAME_POINTER "enable frame pointer on 64bit 
system with flag -fno
 OPTION(ENABLE_LIBCPP "using libc++ instead of libstdc++, only valid for clang 
compiler" OFF)
 OPTION(ENABLE_BOOST "using boost instead of native compiler c++0x support" OFF)
 OPTION(BUILD_TEST "build test files" OFF)
+OPTION(BUILD_SHARED_LIBS "build the shared lib" ON)
+OPTION(BUILD_STATIC_LIBS "build the static lib" ON)
 
 INCLUDE (CheckFunctionExists)
 CHECK_FUNCTION_EXISTS(dladdr HAVE_DLADDR)
diff --git a/bootstrap b/bootstrap
index 5020f55..673f24a 100755
--- a/bootstrap
+++ b/bootstrap
@@ -54,7 +54,11 @@ Configuration:
     --enable-coverage               enable build with code coverage support
     --enable-libc++                 using libc++ instead of libstdc++, only 
valid for clang compiler
     --with-test                     enable build with test
-    
+    --disable-shared                disable shared library
+    --disable-static                disable static library
+    --enable-shared                 enable shared library
+    --enable-static                 enable static library
+
 Dependencies:
     c/c++ compiler
     GNU make
@@ -85,6 +89,8 @@ enable_coverage="OFF"
 enable_clang_lib="OFF"
 enable_sse="ON"
 build_test="OFF"
+build_shared="ON"
+build_static="ON"
 while test $# != 0; do
     case "$1" in
     --prefix=*) dir=`arg "$1"`
@@ -96,6 +102,10 @@ while test $# != 0; do
     --enable-coverage) enable_coverage="ON";;
     --enable-libc++) enable_clang_lib="ON";;
     --with-test) build_test="ON";;
+    --disable-shared) build_shared="OFF";;
+    --disable-static) build_static="OFF";;
+    --enable-shared) build_shared="ON";;
+    --enable-static) build_static="ON";;
     --help) usage ;;
     *) die "Unknown option: $1" ;;
     esac
@@ -140,6 +150,7 @@ ${cmake} -DENABLE_DEBUG=${enable_build} 
-DCMAKE_INSTALL_PREFIX=${prefix_dirs} \
     -DCMAKE_PREFIX_PATH=${dependency_dir} -DENABLE_BOOST=${enable_boost} \
     -DENABLE_COVERAGE=${enable_coverage} -DENABLE_LIBCPP=${enable_clang_lib} \
     -DENABLE_SSE=${enable_sse} ${source_dir} -DBUILD_TEST=${build_test} \
+    -DBUILD_SHARED_LIBS=${build_shared} -DBUILD_STATIC_LIBS=${build_static} \
     || die "failed to configure the project"
 
 echo 'bootstrap success. Run "make" to build.'
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ca6b702..0e8b174 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -45,38 +45,6 @@ SET(HEADER
     common/Exception.h
     common/XmlConfig.h)
 
-ADD_LIBRARY(libhdfs3-static STATIC ${libhdfs3_SOURCES} 
${libhdfs3_PROTO_SOURCES} ${libhdfs3_PROTO_HEADERS})
-ADD_LIBRARY(libhdfs3-shared SHARED ${libhdfs3_SOURCES} 
${libhdfs3_PROTO_SOURCES} ${libhdfs3_PROTO_HEADERS})
-
-ADD_CUSTOM_COMMAND(
-    TARGET libhdfs3-shared libhdfs3-static
-    PRE_BUILD
-    COMMAND echo ${libhdfs3_VERSION_STRING} > version
-    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-)
-
-TARGET_LINK_LIBRARIES(libhdfs3-static pthread)
-TARGET_LINK_LIBRARIES(libhdfs3-shared pthread)
-       
-IF(NEED_BOOST)
-    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_thread)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_chrono)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_system)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_atomic)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_iostreams)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_thread)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_chrono)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_system)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_atomic)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_iostreams)
-ENDIF(NEED_BOOST)
-
-IF(NEED_GCCEH)
-    TARGET_LINK_LIBRARIES(libhdfs3-static gcc_eh)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared gcc_eh)
-ENDIF(NEED_GCCEH)
-
 INCLUDE_DIRECTORIES(${libhdfs3_ROOT_SOURCES_DIR})
 INCLUDE_DIRECTORIES(${libhdfs3_COMMON_SOURCES_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
@@ -86,31 +54,93 @@ INCLUDE_DIRECTORIES(${KERBEROS_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES(${GSASL_INCLUDE_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/mock)
 
-TARGET_LINK_LIBRARIES(libhdfs3-static ${PROTOBUF_LIBRARIES})
-TARGET_LINK_LIBRARIES(libhdfs3-static ${LIBXML2_LIBRARIES})
-TARGET_LINK_LIBRARIES(libhdfs3-static ${KERBEROS_LIBRARIES})
-TARGET_LINK_LIBRARIES(libhdfs3-static ${GSASL_LIBRARIES})
-
-TARGET_LINK_LIBRARIES(libhdfs3-shared ${PROTOBUF_LIBRARIES})
-TARGET_LINK_LIBRARIES(libhdfs3-shared ${LIBXML2_LIBRARIES})
-TARGET_LINK_LIBRARIES(libhdfs3-shared ${KERBEROS_LIBRARIES})
-TARGET_LINK_LIBRARIES(libhdfs3-shared ${GSASL_LIBRARIES})
-
-SET_TARGET_PROPERTIES(libhdfs3-static PROPERTIES OUTPUT_NAME "hdfs3")
-SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES OUTPUT_NAME "hdfs3")
-
-IF(NEED_BOOST)
-    SET_TARGET_PROPERTIES(libhdfs3-shared libhdfs3-static PROPERTIES 
LINK_FLAGS "-L${Boost_LIBRARY_DIRS}")
-ENDIF(NEED_BOOST)
+IF(BUILD_STATIC_LIBS)
+    ADD_LIBRARY(libhdfs3-static STATIC ${libhdfs3_SOURCES} 
${libhdfs3_PROTO_SOURCES} ${libhdfs3_PROTO_HEADERS})
+    ADD_CUSTOM_COMMAND(
+        TARGET libhdfs3-static
+        PRE_BUILD
+        COMMAND echo ${libhdfs3_VERSION_STRING} > version
+        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    )
+
+    TARGET_LINK_LIBRARIES(libhdfs3-static pthread)
+        
+    IF(NEED_BOOST)
+        INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_thread)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_chrono)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_system)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_atomic)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_iostreams)
+    ENDIF(NEED_BOOST)
+
+    IF(NEED_GCCEH)
+        TARGET_LINK_LIBRARIES(libhdfs3-static gcc_eh)
+    ENDIF(NEED_GCCEH)
+
+    TARGET_LINK_LIBRARIES(libhdfs3-static ${PROTOBUF_LIBRARIES})
+    TARGET_LINK_LIBRARIES(libhdfs3-static ${LIBXML2_LIBRARIES})
+    TARGET_LINK_LIBRARIES(libhdfs3-static ${KERBEROS_LIBRARIES})
+    TARGET_LINK_LIBRARIES(libhdfs3-static ${GSASL_LIBRARIES})
+
+    SET_TARGET_PROPERTIES(libhdfs3-static PROPERTIES OUTPUT_NAME "hdfs3")
+
+    IF(NEED_BOOST)
+        SET_TARGET_PROPERTIES(libhdfs3-static PROPERTIES LINK_FLAGS 
"-L${Boost_LIBRARY_DIRS}")
+    ENDIF(NEED_BOOST)
+
+    INSTALL(TARGETS libhdfs3-static
+            RUNTIME DESTINATION bin
+            LIBRARY DESTINATION lib
+            ARCHIVE DESTINATION lib)
+ENDIF(BUILD_STATIC_LIBS)
+
+IF(BUILD_SHARED_LIBS) 
+    ADD_LIBRARY(libhdfs3-shared SHARED ${libhdfs3_SOURCES} 
${libhdfs3_PROTO_SOURCES} ${libhdfs3_PROTO_HEADERS})
+    ADD_CUSTOM_COMMAND(
+        TARGET libhdfs3-shared
+        PRE_BUILD
+        COMMAND echo ${libhdfs3_VERSION_STRING} > version
+        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    )
+
+    TARGET_LINK_LIBRARIES(libhdfs3-shared pthread)
+        
+    IF(NEED_BOOST)
+        INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_thread)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_chrono)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_system)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_atomic)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_iostreams)
+    ENDIF(NEED_BOOST)
+
+    IF(NEED_GCCEH)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared gcc_eh)
+    ENDIF(NEED_GCCEH)
+
+    TARGET_LINK_LIBRARIES(libhdfs3-shared ${PROTOBUF_LIBRARIES})
+    TARGET_LINK_LIBRARIES(libhdfs3-shared ${LIBXML2_LIBRARIES})
+    TARGET_LINK_LIBRARIES(libhdfs3-shared ${KERBEROS_LIBRARIES})
+    TARGET_LINK_LIBRARIES(libhdfs3-shared ${GSASL_LIBRARIES})
+
+    SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES OUTPUT_NAME "hdfs3")
+
+    IF(NEED_BOOST)
+        SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES LINK_FLAGS 
"-L${Boost_LIBRARY_DIRS}")
+    ENDIF(NEED_BOOST)
+
+    SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES 
+        VERSION 
${libhdfs3_VERSION_MAJOR}.${libhdfs3_VERSION_MINOR}.${libhdfs3_VERSION_PATCH} 
+        SOVERSION ${libhdfs3_VERSION_API})
+
+    INSTALL(TARGETS libhdfs3-shared
+            RUNTIME DESTINATION bin
+            LIBRARY DESTINATION lib
+            ARCHIVE DESTINATION lib)
+ENDIF(BUILD_SHARED_LIBS)
 
-SET_TARGET_PROPERTIES(libhdfs3-shared PROPERTIES 
-    VERSION 
${libhdfs3_VERSION_MAJOR}.${libhdfs3_VERSION_MINOR}.${libhdfs3_VERSION_PATCH} 
-    SOVERSION ${libhdfs3_VERSION_API})
 
-INSTALL(TARGETS libhdfs3-static libhdfs3-shared
-        RUNTIME DESTINATION bin
-        LIBRARY DESTINATION lib
-        ARCHIVE DESTINATION lib)
 INSTALL(FILES ${HEADER} DESTINATION include/hdfs)
 INSTALL(FILES libhdfs3.pc DESTINATION lib/pkgconfig)
             


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to