diff --git a/hadoop-common-project/hadoop-common/HadoopJNI.cmake b/hadoop-common-project/hadoop-common/HadoopJNI.cmake index 78d7ffda6f..bf0d73eb56 100644 --- a/hadoop-common-project/hadoop-common/HadoopJNI.cmake +++ b/hadoop-common-project/hadoop-common/HadoopJNI.cmake @@ -93,5 +93,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Otherwise, use the standard FindJNI module to locate the JNI components. # else() + find_package(Java REQUIRED) + include(UseJava) find_package(JNI REQUIRED) endif() diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml index 52d9257f95..ded1c0d402 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml @@ -200,27 +200,37 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + org.apache.hadoop + hadoop-maven-plugins + + + cmake-compile + compile + cmake-compile + + ${basedir}/src + + ${project.build.directory}/native/javah + ${sun.arch.data.model} + ${require.fuse} + ${require.valgrind} + 1 + ${require.libwebhdfs} + ${require.openssl} + ${openssl.prefix} + ${openssl.lib} + ${openssl.include} + + ${project.build.directory} + + + + org.apache.maven.plugins maven-antrun-plugin - - make - compile - run - - - - - - - - - - - - - native_tests test @@ -236,6 +246,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> + @@ -246,7 +257,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> - test-patch + native-clang false @@ -255,36 +266,41 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + org.apache.hadoop + hadoop-maven-plugins + + + cmake-compile-clang + compile + cmake-compile + + ${basedir}/src + + clang + clang++ + ${project.build.directory}/native/javah + ${sun.arch.data.model} + ${require.fuse} + ${require.valgrind} + 1 + ${require.libwebhdfs} + ${require.openssl} + ${openssl.prefix} + ${openssl.lib} + ${openssl.include} + + ${project.build.directory}/clang + + + + org.apache.maven.plugins maven-antrun-plugin - make_altern - compile - run - - - - - - - - - - - - - - - - - - - - - - native_tests_altern + native_tests_clang test run @@ -292,26 +308,17 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> - + - + + - - clean_altern - test - run - - - - - - diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt index a3f8f2d24a..1813ec134f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt @@ -88,6 +88,54 @@ function(link_libhdfs_test NAME LIBRARY) target_link_libraries("${NAME}_${LIBRARY}" ${LIBRARY} ${ARGN}) endfunction() + +set(STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +hadoop_set_find_shared_library_without_version() +set(OPENSSL_NAME "crypto") +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + SET(OPENSSL_NAME "eay32") +endif() +message("CUSTOM_OPENSSL_PREFIX = ${CUSTOM_OPENSSL_PREFIX}") +find_library(OPENSSL_LIBRARY + NAMES ${OPENSSL_NAME} + PATHS ${CUSTOM_OPENSSL_PREFIX} ${CUSTOM_OPENSSL_PREFIX}/lib + ${CUSTOM_OPENSSL_PREFIX}/lib64 ${CUSTOM_OPENSSL_LIB} NO_DEFAULT_PATH) +find_library(OPENSSL_LIBRARY NAMES ${OPENSSL_NAME}) +find_path(OPENSSL_INCLUDE_DIR + NAMES openssl/evp.h + PATHS ${CUSTOM_OPENSSL_PREFIX} ${CUSTOM_OPENSSL_PREFIX}/include + ${CUSTOM_OPENSSL_INCLUDE} NO_DEFAULT_PATH) +find_path(OPENSSL_INCLUDE_DIR NAMES openssl/evp.h) +set(CMAKE_FIND_LIBRARY_SUFFIXES ${STORED_CMAKE_FIND_LIBRARY_SUFFIXES}) +set(USABLE_OPENSSL 0) +if(OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR) + include(CheckCSourceCompiles) + set(OLD_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + check_c_source_compiles("#include \"${OPENSSL_INCLUDE_DIR}/openssl/evp.h\"\nint main(int argc, char **argv) { return !EVP_aes_256_ctr; }" HAS_NEW_ENOUGH_OPENSSL) + set(CMAKE_REQUIRED_INCLUDES ${OLD_CMAKE_REQUIRED_INCLUDES}) + if(NOT HAS_NEW_ENOUGH_OPENSSL) + message("The OpenSSL library installed at ${OPENSSL_LIBRARY} is too old. You need a version at least new enough to have EVP_aes_256_ctr.") + else() + SET(USABLE_OPENSSL 1) + endif() +endif() +if(USABLE_OPENSSL) + get_filename_component(HADOOP_OPENSSL_LIBRARY ${OPENSSL_LIBRARY} NAME) + set(OPENSSL_SOURCE_FILES + "${SRC}/crypto/OpensslCipher.c" + "${SRC}/crypto/random/OpensslSecureRandom.c") + set(REQUIRE_OPENSSL ${REQUIRE_OPENSSL}) # Stop warning about unused variable. +else() + message("Cannot find a usable OpenSSL library. OPENSSL_LIBRARY=${OPENSSL_LIBRARY}, OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}, CUSTOM_OPENSSL_LIB=${CUSTOM_OPENSSL_LIB}, CUSTOM_OPENSSL_PREFIX=${CUSTOM_OPENSSL_PREFIX}, CUSTOM_OPENSSL_INCLUDE=${CUSTOM_OPENSSL_INCLUDE}") + if(REQUIRE_OPENSSL) + message(FATAL_ERROR "Terminating build because require.openssl was specified.") + endif() + set(OPENSSL_LIBRARY "") + set(OPENSSL_INCLUDE_DIR "") + set(OPENSSL_SOURCE_FILES "") +endif() + add_subdirectory(main/native/libhdfs) add_subdirectory(main/native/libhdfs-tests) add_subdirectory(main/native/libhdfspp) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt index 2883585158..cac1335ae2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt @@ -74,9 +74,11 @@ endif() # introducing an abstraction layer over the sys/mman.h functions. if(NOT WIN32) build_libhdfs_test(test_libhdfs_vecsum hdfs vecsum.c) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) if(CMAKE_SYSTEM_NAME MATCHES "Darwin") - link_libhdfs_test(test_libhdfs_vecsum hdfs pthread) + link_libhdfs_test(test_libhdfs_vecsum hdfs ${CMAKE_THREAD_LIBS_INIT}) else() - link_libhdfs_test(test_libhdfs_vecsum hdfs pthread rt) + link_libhdfs_test(test_libhdfs_vecsum hdfs ${CMAKE_THREAD_LIBS_INIT} rt) endif() endif() diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/CMakeLists.txt index 6157902b91..59fdbf20a2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/CMakeLists.txt +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/CMakeLists.txt @@ -143,6 +143,10 @@ include_directories ( add_library(hdfspp_test_shim_static STATIC hdfs_shim.c libhdfs_wrapper.c libhdfspp_wrapper.cc ${LIBHDFSPP_BINDING_C}/hdfs.cc) add_library(hdfspp_test_static STATIC ${LIBHDFSPP_BINDING_C}/hdfs.cc) +# Add dependencies +add_dependencies(hdfspp_test_shim_static proto) +add_dependencies(hdfspp_test_static proto) + # TODO: get all of the mini dfs library bits here in one place # add_library(hdfspp_mini_cluster native_mini_dfs ${JAVA_JVM_LIBRARY} )