Debian Codegraph @

Modules/ThirdParty/HDF5/src/itkhdf5/config/cmake/FindHDFS.cmake

raw
1
2 # DerivedFrom: https://github.com/cloudera/Impala/blob/cdh5-trunk/cmake_modules/FindHDFS.cmake
3 # - Find HDFS (hdfs.h and libhdfs.so)
4 # This module defines
5 # Hadoop_VERSION, version string of ant if found
6 # HDFS_INCLUDE_DIR, directory containing hdfs.h
7 # HDFS_LIBRARIES, location of libhdfs.so
8 # HDFS_FOUND, whether HDFS is found.
9
10 exec_program($ENV{HADOOP_HOME}/bin/hadoop ARGS version OUTPUT_VARIABLE Hadoop_VERSION
11 RETURN_VALUE Hadoop_RETURN)
12
13 # currently only looking in HADOOP_HOME
14 find_path(HDFS_INCLUDE_DIR hdfs.h PATHS
15 $ENV{HADOOP_HOME}/include/
16 # make sure we don't accidentally pick up a different version
17 NO_DEFAULT_PATH
18 )
19
20 if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
21 set(arch_hint "x64")
22 elseif ("$ENV{LIB}" MATCHES "(amd64|ia64)")
23 set(arch_hint "x64")
24 else ()
25 set(arch_hint "x86")
26 endif()
27
28 message(STATUS "Architecture: ${arch_hint}")
29
30 if ("${arch_hint}" STREQUAL "x64")
31 set(HDFS_LIB_PATHS $ENV{HADOOP_HOME}/lib/native)
32 else ()
33 set(HDFS_LIB_PATHS $ENV{HADOOP_HOME}/lib/native)
34 endif ()
35
36 message(STATUS "HDFS_LIB_PATHS: ${HDFS_LIB_PATHS}")
37
38 find_library(HDFS_LIB NAMES hdfs PATHS
39 ${HDFS_LIB_PATHS}
40 # make sure we don't accidentally pick up a different version
41 NO_DEFAULT_PATH
42 )
43
44 if (HDFS_LIB)
45 set(HDFS_FOUND TRUE)
46 set(HDFS_LIBRARIES ${HDFS_LIB})
47 set(HDFS_STATIC_LIB ${HDFS_LIB_PATHS}/${CMAKE_STATIC_LIBRARY_PREFIX}hdfs${CMAKE_STATIC_LIBRARY_SUFFIX})
48
49 add_library(hdfs_static STATIC IMPORTED)
50 set_target_properties(hdfs_static PROPERTIES IMPORTED_LOCATION ${HDFS_STATIC_LIB})
51 else ()
52 set(HDFS_FOUND FALSE)
53 endif ()
54
55 if (HDFS_FOUND)
56 if (NOT HDFS_FIND_QUIETLY)
57 message(STATUS "${Hadoop_VERSION}")
58 message(STATUS "HDFS_INCLUDE_DIR: ${HDFS_INCLUDE_DIR}")
59 message(STATUS "HDFS_LIBRARIES: ${HDFS_LIBRARIES}")
60 message(STATUS "hdfs_static: ${HDFS_STATIC_LIB}")
61 endif ()
62 else ()
63 message(FATAL_ERROR "HDFS includes and libraries NOT found."
64 "(${HDFS_INCLUDE_DIR}, ${HDFS_LIB})")
65 endif ()
66
67 mark_as_advanced(
68 HDFS_LIBRARIES
69 HDFS_INCLUDE_DIR
70 )