FindICU.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the ICU unicode library
  17. # Once done this will define
  18. #
  19. # ICU_FOUND - system has the ICU library
  20. # ICU_INCLUDE_DIR - the ICU include directory
  21. # ICU_LIBRARIES - The libraries needed to use ICU
  22. IF (NOT ICU_FOUND)
  23. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  24. IF (UNIX)
  25. IF (${ARCH64BIT} EQUAL 1)
  26. SET (libdir "lib/linux64_gcc4.1.1")
  27. ELSE()
  28. SET (libdir "lib/linux32_gcc4.1.1")
  29. ENDIF()
  30. ELSEIF(WIN32)
  31. IF (${ARCH64BIT} EQUAL 1)
  32. SET (libdir "lib64")
  33. ELSE()
  34. SET (libdir "lib")
  35. ENDIF()
  36. ELSE()
  37. SET (libdir "unknown")
  38. ENDIF()
  39. IF (NOT ("${libdir}" STREQUAL "unknown"))
  40. FIND_PATH (ICU_INCLUDE_DIR NAMES unicode/uchar.h PATHS "${EXTERNALS_DIRECTORY}/icu/include" NO_DEFAULT_PATH)
  41. FIND_LIBRARY (ICU_LIBRARIES NAMES icuuc PATHS "${EXTERNALS_DIRECTORY}/icu/${libdir}" NO_DEFAULT_PATH)
  42. ENDIF()
  43. ENDIF()
  44. if (USE_NATIVE_LIBRARIES)
  45. # if we didn't find in externals, look in system include path
  46. FIND_PATH (ICU_INCLUDE_DIR NAMES unicode/uchar.h)
  47. FIND_LIBRARY (ICU_LIBRARIES NAMES icuuc)
  48. endif()
  49. include(FindPackageHandleStandardArgs)
  50. find_package_handle_standard_args(ICU DEFAULT_MSG
  51. ICU_LIBRARIES
  52. ICU_INCLUDE_DIR
  53. )
  54. IF (ICU_FOUND)
  55. IF (UNIX)
  56. STRING(REPLACE "icuuc" "icui18n" ICU_EXTRA1 "${ICU_LIBRARIES}")
  57. STRING(REPLACE "icuuc" "icudata" ICU_EXTRA2 "${ICU_LIBRARIES}")
  58. ELSE()
  59. STRING(REPLACE "icuuc" "icuin" ICU_EXTRA1 "${ICU_LIBRARIES}")
  60. ENDIF()
  61. set (ICU_LIBRARIES ${ICU_LIBRARIES} ${ICU_EXTRA1} ${ICU_EXTRA2} )
  62. ENDIF()
  63. MARK_AS_ADVANCED(ICU_INCLUDE_DIR ICU_LIBRARIES)
  64. ENDIF()