CMakeLists.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
  19. list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../hadoop-common-project/hadoop-common)
  20. include(HadoopCommon)
  21. find_package(OpenSSL REQUIRED)
  22. find_package(PkgConfig QUIET)
  23. pkg_check_modules(LIBTIRPC libtirpc)
  24. find_path(RPC_INCLUDE_DIRS NAMES rpc/rpc.h)
  25. if (NOT RPC_INCLUDE_DIRS)
  26. find_path(TIRPC_INCLUDE_DIRS
  27. NAMES netconfig.h
  28. PATH_SUFFIXES tirpc
  29. HINTS ${LIBTIRPC_INCLUDE_DIRS}
  30. )
  31. find_library(TIRPC_LIBRARIES
  32. NAMES tirpc
  33. HINTS ${LIBTIRPC_LIBRARY_DIRS}
  34. )
  35. include_directories(${TIRPC_INCLUDE_DIRS})
  36. endif()
  37. include_directories(
  38. main/native/utils/api
  39. main/native/pipes/api
  40. ${CMAKE_CURRENT_SOURCE_DIR}
  41. ${OPENSSL_INCLUDE_DIR}
  42. )
  43. # Example programs
  44. add_executable(wordcount-simple main/native/examples/impl/wordcount-simple.cc)
  45. target_link_libraries(wordcount-simple hadooppipes hadooputils)
  46. hadoop_output_directory(wordcount-simple examples)
  47. add_executable(wordcount-part main/native/examples/impl/wordcount-part.cc)
  48. target_link_libraries(wordcount-part hadooppipes hadooputils)
  49. hadoop_output_directory(wordcount-part examples)
  50. add_executable(wordcount-nopipe main/native/examples/impl/wordcount-nopipe.cc)
  51. target_link_libraries(wordcount-nopipe hadooppipes hadooputils)
  52. hadoop_output_directory(wordcount-nopipe examples)
  53. add_executable(pipes-sort main/native/examples/impl/sort.cc)
  54. target_link_libraries(pipes-sort hadooppipes hadooputils)
  55. hadoop_output_directory(pipes-sort examples)
  56. add_library(hadooputils STATIC
  57. main/native/utils/impl/StringUtils.cc
  58. main/native/utils/impl/SerialUtils.cc
  59. )
  60. if (NOT RPC_INCLUDE_DIRS AND LIBTIRPC_FOUND)
  61. target_link_libraries(hadooputils tirpc)
  62. endif()
  63. add_library(hadooppipes STATIC
  64. main/native/pipes/impl/HadoopPipes.cc
  65. )
  66. include(CheckLibraryExists)
  67. check_library_exists(dl dlopen "" NEED_LINK_DL)
  68. if(NEED_LINK_DL)
  69. set(LIB_DL "dl")
  70. endif()
  71. if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
  72. exec_program("uname" ARGS "-r" OUTPUT_VARIABLE OS_VERSION)
  73. if(OS_VERSION VERSION_LESS "5.12")
  74. set(LIB_NET "socket" "nsl")
  75. endif()
  76. endif()
  77. target_link_libraries(hadooppipes
  78. ${OPENSSL_LIBRARIES}
  79. ${LIB_DL}
  80. ${LIB_NET}
  81. )