From c5e7a69523f4bce0f09c7afe423452c36213a072 Mon Sep 17 00:00:00 2001 From: James Clampffer Date: Tue, 20 Jun 2017 15:17:58 -0400 Subject: [PATCH] HDFS-11971: libhdfs++: [Fix] a few portability issues. Contributed by Anatoli Schein --- .../src/main/native/libhdfspp/CMakeLists.txt | 12 +++-- .../libhdfspp/examples/c/cat/CMakeLists.txt | 10 +---- .../examples/c/connect_cancel/CMakeLists.txt | 10 +---- .../libhdfspp/examples/cc/cat/CMakeLists.txt | 12 +---- .../examples/cc/connect_cancel/CMakeLists.txt | 2 +- .../libhdfspp/examples/cc/find/CMakeLists.txt | 12 +---- .../examples/cc/gendirs/CMakeLists.txt | 12 +---- .../libhdfspp/lib/common/configuration.h | 2 +- .../native/libhdfspp/tools/CMakeLists.txt | 44 +++++++++---------- 9 files changed, 40 insertions(+), 76 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt index a5c77e0ab3..dc7cd30809 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/CMakeLists.txt @@ -176,6 +176,7 @@ include_directories( SYSTEM third_party/uriparser2 ${OPENSSL_INCLUDE_DIR} ${SASL_INCLUDE_DIR} + ${PROTOBUF_INCLUDE_DIRS} ) @@ -206,6 +207,7 @@ if (HADOOP_BUILD) ${PROTOBUF_LIBRARY} ${OPENSSL_LIBRARIES} ${SASL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} ) else (HADOOP_BUILD) add_library(hdfspp_static STATIC ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS}) @@ -214,6 +216,7 @@ else (HADOOP_BUILD) ${PROTOBUF_LIBRARY} ${OPENSSL_LIBRARIES} ${SASL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} ) add_library(hdfspp SHARED ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS}) target_link_libraries(hdfspp_static @@ -221,6 +224,7 @@ else (HADOOP_BUILD) ${PROTOBUF_LIBRARY} ${OPENSSL_LIBRARIES} ${SASL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} ) endif (HADOOP_BUILD) set(LIBHDFSPP_VERSION "0.1.0") @@ -231,11 +235,11 @@ set_target_properties(hdfspp PROPERTIES # Can be installed to a particular location via "make DESTDIR=... install" file(GLOB_RECURSE LIBHDFSPP_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/include/*.h*") file(GLOB_RECURSE LIBHDFS_HEADER_FILES "${HADOOP_IMPORT_DIR}/include/*.h*") -install(FILES ${LIBHDFSPP_HEADER_FILES} DESTINATION /include/hdfspp) -install(FILES ${LIBHDFS_HEADER_FILES} DESTINATION /include/hdfs) +install(FILES ${LIBHDFSPP_HEADER_FILES} DESTINATION include/hdfspp) +install(FILES ${LIBHDFS_HEADER_FILES} DESTINATION include/hdfs) -install(TARGETS hdfspp_static ARCHIVE DESTINATION /lib) -install(TARGETS hdfspp LIBRARY DESTINATION /lib) +install(TARGETS hdfspp_static ARCHIVE DESTINATION lib) +install(TARGETS hdfspp LIBRARY DESTINATION lib) add_custom_target( InstallToBuildDirectory diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/cat/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/cat/CMakeLists.txt index 1319293dcf..41a9ee87fd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/cat/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/cat/CMakeLists.txt @@ -24,12 +24,4 @@ include_directories( ${LIBHDFSPP_DIR}/include ) link_directories( ${LIBHDFSPP_DIR}/lib ) add_executable(cat_c cat.c) -target_link_libraries(cat_c hdfspp uriparser2) - -# Several examples in different languages need to produce executables with -# same names. To allow executables with same names we keep their CMake -# names different, but specify their executable names as follows: -set_target_properties( cat_c - PROPERTIES - OUTPUT_NAME "cat" -) +target_link_libraries(cat_c hdfspp_static uriparser2) \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/connect_cancel/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/connect_cancel/CMakeLists.txt index 56aeeea70e..6276467f5f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/connect_cancel/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/c/connect_cancel/CMakeLists.txt @@ -24,12 +24,4 @@ include_directories( ${LIBHDFSPP_DIR}/include ) link_directories( ${LIBHDFSPP_DIR}/lib ) add_executable(connect_cancel_c connect_cancel.c) -target_link_libraries(connect_cancel_c hdfspp uriparser2) - -# Several examples in different languages need to produce executables with -# same names. To allow executables with same names we keep their CMake -# names different, but specify their executable names as follows: -set_target_properties( connect_cancel_c - PROPERTIES - OUTPUT_NAME "connect_cancel_c" -) +target_link_libraries(connect_cancel_c hdfspp_static uriparser2) \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/cat/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/cat/CMakeLists.txt index 9ad919a496..479ff864a4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/cat/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/cat/CMakeLists.txt @@ -23,13 +23,5 @@ set(LIBHDFSPP_DIR CACHE STRING ${CMAKE_INSTALL_PREFIX}) include_directories( ${LIBHDFSPP_DIR}/include ) link_directories( ${LIBHDFSPP_DIR}/lib ) -add_executable(cat_cc cat.cc) -target_link_libraries(cat_cc hdfspp) - -# Several examples in different languages need to produce executables with -# same names. To allow executables with same names we keep their CMake -# names different, but specify their executable names as follows: -set_target_properties( cat_cc - PROPERTIES - OUTPUT_NAME "cat" -) +add_executable(cat cat.cc) +target_link_libraries(cat hdfspp_static) \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/connect_cancel/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/connect_cancel/CMakeLists.txt index 6ee44cccce..e3cc0b51e8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/connect_cancel/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/connect_cancel/CMakeLists.txt @@ -24,4 +24,4 @@ include_directories( ${LIBHDFSPP_DIR}/include ) link_directories( ${LIBHDFSPP_DIR}/lib ) add_executable(connect_cancel connect_cancel.cc) -target_link_libraries(connect_cancel hdfspp) +target_link_libraries(connect_cancel hdfspp_static) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/find/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/find/CMakeLists.txt index e894e58fd7..8210bb5a5f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/find/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/find/CMakeLists.txt @@ -23,13 +23,5 @@ set(LIBHDFSPP_DIR CACHE STRING ${CMAKE_INSTALL_PREFIX}) include_directories( ${LIBHDFSPP_DIR}/include ) link_directories( ${LIBHDFSPP_DIR}/lib ) -add_executable(find_cc find.cc) -target_link_libraries(find_cc hdfspp) - -# Several examples in different languages need to produce executables with -# same names. To allow executables with same names we keep their CMake -# names different, but specify their executable names as follows: -set_target_properties( find_cc - PROPERTIES - OUTPUT_NAME "find" -) +add_executable(find find.cc) +target_link_libraries(find hdfspp_static) \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/gendirs/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/gendirs/CMakeLists.txt index e25f4256d0..7fdc1b2c28 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/gendirs/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/examples/cc/gendirs/CMakeLists.txt @@ -23,13 +23,5 @@ set(LIBHDFSPP_DIR CACHE STRING ${CMAKE_INSTALL_PREFIX}) include_directories( ${LIBHDFSPP_DIR}/include ) link_directories( ${LIBHDFSPP_DIR}/lib ) -add_executable(gendirs_cc gendirs.cc) -target_link_libraries(gendirs_cc hdfspp) - -# Several examples in different languages need to produce executables with -# same names. To allow executables with same names we keep their CMake -# names different, but specify their executable names as follows: -set_target_properties( gendirs_cc - PROPERTIES - OUTPUT_NAME "gendirs" -) +add_executable(gendirs gendirs.cc) +target_link_libraries(gendirs hdfspp_static) \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/configuration.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/configuration.h index b6b968e7cc..ebfa90951a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/configuration.h +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/configuration.h @@ -98,7 +98,7 @@ protected: static std::string fixCase(const std::string &in) { std::string result(in); - for (auto & c: result) c = toupper(c); + for (auto & c: result) c = (char) toupper(c); return result; } }; diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tools/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tools/CMakeLists.txt index 4a46c7a871..dbcb97f7c0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tools/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tools/CMakeLists.txt @@ -27,67 +27,67 @@ add_library(tools_common_obj OBJECT tools_common.cc) add_library(tools_common $) add_executable(hdfs_cat hdfs_cat.cc) -target_link_libraries(hdfs_cat tools_common hdfspp) +target_link_libraries(hdfs_cat tools_common hdfspp_static) add_executable(hdfs_chgrp hdfs_chgrp.cc) -target_link_libraries(hdfs_chgrp tools_common hdfspp) +target_link_libraries(hdfs_chgrp tools_common hdfspp_static) add_executable(hdfs_chown hdfs_chown.cc) -target_link_libraries(hdfs_chown tools_common hdfspp) +target_link_libraries(hdfs_chown tools_common hdfspp_static) add_executable(hdfs_chmod hdfs_chmod.cc) -target_link_libraries(hdfs_chmod tools_common hdfspp) +target_link_libraries(hdfs_chmod tools_common hdfspp_static) add_executable(hdfs_find hdfs_find.cc) -target_link_libraries(hdfs_find tools_common hdfspp) +target_link_libraries(hdfs_find tools_common hdfspp_static) add_executable(hdfs_mkdir hdfs_mkdir.cc) -target_link_libraries(hdfs_mkdir tools_common hdfspp) +target_link_libraries(hdfs_mkdir tools_common hdfspp_static) add_executable(hdfs_rm hdfs_rm.cc) -target_link_libraries(hdfs_rm tools_common hdfspp) +target_link_libraries(hdfs_rm tools_common hdfspp_static) add_executable(hdfs_ls hdfs_ls.cc) -target_link_libraries(hdfs_ls tools_common hdfspp) +target_link_libraries(hdfs_ls tools_common hdfspp_static) add_executable(hdfs_stat hdfs_stat.cc) -target_link_libraries(hdfs_stat tools_common hdfspp) +target_link_libraries(hdfs_stat tools_common hdfspp_static) add_executable(hdfs_count hdfs_count.cc) -target_link_libraries(hdfs_count tools_common hdfspp) +target_link_libraries(hdfs_count tools_common hdfspp_static) add_executable(hdfs_df hdfs_df.cc) -target_link_libraries(hdfs_df tools_common hdfspp) +target_link_libraries(hdfs_df tools_common hdfspp_static) add_executable(hdfs_du hdfs_du.cc) -target_link_libraries(hdfs_du tools_common hdfspp) +target_link_libraries(hdfs_du tools_common hdfspp_static) add_executable(hdfs_get hdfs_get.cc) -target_link_libraries(hdfs_get tools_common hdfspp) +target_link_libraries(hdfs_get tools_common hdfspp_static) add_executable(hdfs_copyToLocal hdfs_copyToLocal.cc) -target_link_libraries(hdfs_copyToLocal tools_common hdfspp) +target_link_libraries(hdfs_copyToLocal tools_common hdfspp_static) add_executable(hdfs_moveToLocal hdfs_moveToLocal.cc) -target_link_libraries(hdfs_moveToLocal tools_common hdfspp) +target_link_libraries(hdfs_moveToLocal tools_common hdfspp_static) add_executable(hdfs_setrep hdfs_setrep.cc) -target_link_libraries(hdfs_setrep tools_common hdfspp) +target_link_libraries(hdfs_setrep tools_common hdfspp_static) add_executable(hdfs_allowSnapshot hdfs_allowSnapshot.cc) -target_link_libraries(hdfs_allowSnapshot tools_common hdfspp) +target_link_libraries(hdfs_allowSnapshot tools_common hdfspp_static) add_executable(hdfs_disallowSnapshot hdfs_disallowSnapshot.cc) -target_link_libraries(hdfs_disallowSnapshot tools_common hdfspp) +target_link_libraries(hdfs_disallowSnapshot tools_common hdfspp_static) add_executable(hdfs_createSnapshot hdfs_createSnapshot.cc) -target_link_libraries(hdfs_createSnapshot tools_common hdfspp) +target_link_libraries(hdfs_createSnapshot tools_common hdfspp_static) add_executable(hdfs_renameSnapshot hdfs_renameSnapshot.cc) -target_link_libraries(hdfs_renameSnapshot tools_common hdfspp) +target_link_libraries(hdfs_renameSnapshot tools_common hdfspp_static) add_executable(hdfs_deleteSnapshot hdfs_deleteSnapshot.cc) -target_link_libraries(hdfs_deleteSnapshot tools_common hdfspp) +target_link_libraries(hdfs_deleteSnapshot tools_common hdfspp_static) add_executable(hdfs_tail hdfs_tail.cc) -target_link_libraries(hdfs_tail tools_common hdfspp) \ No newline at end of file +target_link_libraries(hdfs_tail tools_common hdfspp_static) \ No newline at end of file