FindICU.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the ICU unicode library
  18. # Once done this will define
  19. #
  20. # ICU_FOUND - system has the ICU library
  21. # ICU_INCLUDE_DIR - the ICU include directory
  22. # ICU_LIBRARIES - The libraries needed to use ICU
  23. IF (NOT ICU_FOUND)
  24. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  25. IF (UNIX)
  26. IF (${ARCH64BIT} EQUAL 1)
  27. SET (osdir "linux64_gcc4.1.1")
  28. ELSE()
  29. SET (osdir "linux32_gcc4.1.1")
  30. ENDIF()
  31. ELSEIF(WIN32)
  32. SET (osdir )
  33. ELSE()
  34. SET (osdir "unknown")
  35. ENDIF()
  36. IF (NOT ("${osdir}" STREQUAL "unknown"))
  37. FIND_PATH (ICU_INCLUDE_DIR NAMES unicode/uchar.h PATHS "${EXTERNALS_DIRECTORY}/icu/include" NO_DEFAULT_PATH)
  38. FIND_LIBRARY (ICU_LIBRARIES NAMES icuuc PATHS "${EXTERNALS_DIRECTORY}/icu/lib/${osdir}" NO_DEFAULT_PATH)
  39. ENDIF()
  40. ENDIF()
  41. if (USE_NATIVE_LIBRARIES)
  42. # if we didn't find in externals, look in system include path
  43. FIND_PATH (ICU_INCLUDE_DIR NAMES unicode/uchar.h)
  44. FIND_LIBRARY (ICU_LIBRARIES NAMES icuuc)
  45. endif()
  46. include(FindPackageHandleStandardArgs)
  47. find_package_handle_standard_args(ICU DEFAULT_MSG
  48. ICU_LIBRARIES
  49. ICU_INCLUDE_DIR
  50. )
  51. IF (ICU_FOUND)
  52. IF (UNIX)
  53. STRING(REPLACE "icuuc" "icui18n" ICU_EXTRA1 "${ICU_LIBRARIES}")
  54. STRING(REPLACE "icuuc" "icudata" ICU_EXTRA2 "${ICU_LIBRARIES}")
  55. ELSE()
  56. STRING(REPLACE "icuuc" "icuin" ICU_EXTRA1 "${ICU_LIBRARIES}")
  57. ENDIF()
  58. set (ICU_LIBRARIES ${ICU_LIBRARIES} ${ICU_EXTRA1} ${ICU_EXTRA2} )
  59. ENDIF()
  60. MARK_AS_ADVANCED(ICU_INCLUDE_DIR ICU_LIBRARIES)
  61. ENDIF()