Blame cmake/compat_3.7.0/FindICU.cmake

Packit Service fa4841
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
Packit Service fa4841
# file Copyright.txt or https://cmake.org/licensing for details.
Packit Service fa4841
Packit Service fa4841
#.rst:
Packit Service fa4841
# FindICU
Packit Service fa4841
# -------
Packit Service fa4841
#
Packit Service fa4841
# Find the International Components for Unicode (ICU) libraries and
Packit Service fa4841
# programs.
Packit Service fa4841
#
Packit Service fa4841
# This module supports multiple components.
Packit Service fa4841
# Components can include any of: ``data``, ``i18n``, ``io``, ``le``,
Packit Service fa4841
# ``lx``, ``test``, ``tu`` and ``uc``.
Packit Service fa4841
#
Packit Service fa4841
# Note that on Windows ``data`` is named ``dt`` and ``i18n`` is named
Packit Service fa4841
# ``in``; any of the names may be used, and the appropriate
Packit Service fa4841
# platform-specific library name will be automatically selected.
Packit Service fa4841
#
Packit Service fa4841
# This module reports information about the ICU installation in
Packit Service fa4841
# several variables.  General variables::
Packit Service fa4841
#
Packit Service fa4841
#   ICU_VERSION - ICU release version
Packit Service fa4841
#   ICU_FOUND - true if the main programs and libraries were found
Packit Service fa4841
#   ICU_LIBRARIES - component libraries to be linked
Packit Service fa4841
#   ICU_INCLUDE_DIRS - the directories containing the ICU headers
Packit Service fa4841
#
Packit Service fa4841
# Imported targets::
Packit Service fa4841
#
Packit Service fa4841
#   ICU::<C>
Packit Service fa4841
#
Packit Service fa4841
# Where ``<C>`` is the name of an ICU component, for example
Packit Service fa4841
# ``ICU::i18n``.
Packit Service fa4841
#
Packit Service fa4841
# ICU programs are reported in::
Packit Service fa4841
#
Packit Service fa4841
#   ICU_GENCNVAL_EXECUTABLE - path to gencnval executable
Packit Service fa4841
#   ICU_ICUINFO_EXECUTABLE - path to icuinfo executable
Packit Service fa4841
#   ICU_GENBRK_EXECUTABLE - path to genbrk executable
Packit Service fa4841
#   ICU_ICU-CONFIG_EXECUTABLE - path to icu-config executable
Packit Service fa4841
#   ICU_GENRB_EXECUTABLE - path to genrb executable
Packit Service fa4841
#   ICU_GENDICT_EXECUTABLE - path to gendict executable
Packit Service fa4841
#   ICU_DERB_EXECUTABLE - path to derb executable
Packit Service fa4841
#   ICU_PKGDATA_EXECUTABLE - path to pkgdata executable
Packit Service fa4841
#   ICU_UCONV_EXECUTABLE - path to uconv executable
Packit Service fa4841
#   ICU_GENCFU_EXECUTABLE - path to gencfu executable
Packit Service fa4841
#   ICU_MAKECONV_EXECUTABLE - path to makeconv executable
Packit Service fa4841
#   ICU_GENNORM2_EXECUTABLE - path to gennorm2 executable
Packit Service fa4841
#   ICU_GENCCODE_EXECUTABLE - path to genccode executable
Packit Service fa4841
#   ICU_GENSPREP_EXECUTABLE - path to gensprep executable
Packit Service fa4841
#   ICU_ICUPKG_EXECUTABLE - path to icupkg executable
Packit Service fa4841
#   ICU_GENCMN_EXECUTABLE - path to gencmn executable
Packit Service fa4841
#
Packit Service fa4841
# ICU component libraries are reported in::
Packit Service fa4841
#
Packit Service fa4841
#   ICU_<C>_FOUND - ON if component was found
Packit Service fa4841
#   ICU_<C>_LIBRARIES - libraries for component
Packit Service fa4841
#
Packit Service fa4841
# Note that ``<C>`` is the uppercased name of the component.
Packit Service fa4841
#
Packit Service fa4841
# This module reads hints about search results from::
Packit Service fa4841
#
Packit Service fa4841
#   ICU_ROOT - the root of the ICU installation
Packit Service fa4841
#
Packit Service fa4841
# The environment variable ``ICU_ROOT`` may also be used; the
Packit Service fa4841
# ICU_ROOT variable takes precedence.
Packit Service fa4841
#
Packit Service fa4841
# The following cache variables may also be set::
Packit Service fa4841
#
Packit Service fa4841
#   ICU_

_EXECUTABLE - the path to executable

Packit Service fa4841
#   ICU_INCLUDE_DIR - the directory containing the ICU headers
Packit Service fa4841
#   ICU_<C>_LIBRARY - the library for component <C>
Packit Service fa4841
#
Packit Service fa4841
# .. note::
Packit Service fa4841
#
Packit Service fa4841
#   In most cases none of the above variables will require setting,
Packit Service fa4841
#   unless multiple ICU versions are available and a specific version
Packit Service fa4841
#   is required.
Packit Service fa4841
#
Packit Service fa4841
# Other variables one may set to control this module are::
Packit Service fa4841
#
Packit Service fa4841
#   ICU_DEBUG - Set to ON to enable debug output from FindICU.
Packit Service fa4841
Packit Service fa4841
# Written by Roger Leigh <rleigh@codelibre.net>
Packit Service fa4841
Packit Service fa4841
set(icu_programs
Packit Service fa4841
  gencnval
Packit Service fa4841
  icuinfo
Packit Service fa4841
  genbrk
Packit Service fa4841
  icu-config
Packit Service fa4841
  genrb
Packit Service fa4841
  gendict
Packit Service fa4841
  derb
Packit Service fa4841
  pkgdata
Packit Service fa4841
  uconv
Packit Service fa4841
  gencfu
Packit Service fa4841
  makeconv
Packit Service fa4841
  gennorm2
Packit Service fa4841
  genccode
Packit Service fa4841
  gensprep
Packit Service fa4841
  icupkg
Packit Service fa4841
  gencmn)
Packit Service fa4841
Packit Service fa4841
# The ICU checks are contained in a function due to the large number
Packit Service fa4841
# of temporary variables needed.
Packit Service fa4841
function(_ICU_FIND)
Packit Service fa4841
  # Set up search paths, taking compiler into account.  Search ICU_ROOT,
Packit Service fa4841
  # with ICU_ROOT in the environment as a fallback if unset.
Packit Service fa4841
  if(ICU_ROOT)
Packit Service fa4841
    list(APPEND icu_roots "${ICU_ROOT}")
Packit Service fa4841
  else()
Packit Service fa4841
    if(NOT "$ENV{ICU_ROOT}" STREQUAL "")
Packit Service fa4841
      file(TO_CMAKE_PATH "$ENV{ICU_ROOT}" NATIVE_PATH)
Packit Service fa4841
      list(APPEND icu_roots "${NATIVE_PATH}")
Packit Service fa4841
      set(ICU_ROOT "${NATIVE_PATH}"
Packit Service fa4841
          CACHE PATH "Location of the ICU installation" FORCE)
Packit Service fa4841
    endif()
Packit Service fa4841
  endif()
Packit Service fa4841
Packit Service fa4841
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
Packit Service fa4841
    # 64-bit binary directory
Packit Service fa4841
    set(_bin64 "bin64")
Packit Service fa4841
    # 64-bit library directory
Packit Service fa4841
    set(_lib64 "lib64")
Packit Service fa4841
  endif()
Packit Service fa4841
Packit Service fa4841
  # Generic 64-bit and 32-bit directories
Packit Service fa4841
  list(APPEND icu_binary_suffixes "${_bin64}" "bin")
Packit Service fa4841
  list(APPEND icu_library_suffixes "${_lib64}" "lib")
Packit Service fa4841
Packit Service fa4841
  # Find all ICU programs
Packit Service fa4841
  foreach(program ${icu_programs})
Packit Service fa4841
    string(TOUPPER "${program}" program_upcase)
Packit Service fa4841
    set(cache_var "ICU_${program_upcase}_EXECUTABLE")
Packit Service fa4841
    set(program_var "ICU_${program_upcase}_EXECUTABLE")
Packit Service fa4841
    find_program("${cache_var}" "${program}"
Packit Service fa4841
      HINTS ${icu_roots}
Packit Service fa4841
      PATH_SUFFIXES ${icu_binary_suffixes}
Packit Service fa4841
      DOC "ICU ${program} executable")
Packit Service fa4841
    mark_as_advanced(cache_var)
Packit Service fa4841
    set("${program_var}" "${${cache_var}}" PARENT_SCOPE)
Packit Service fa4841
  endforeach()
Packit Service fa4841
Packit Service fa4841
  # Find include directory
Packit Service fa4841
  find_path(ICU_INCLUDE_DIR
Packit Service fa4841
            NAMES "unicode/utypes.h"
Packit Service fa4841
            HINTS ${icu_roots}
Packit Service fa4841
            PATH_SUFFIXES ${icu_include_suffixes}
Packit Service fa4841
            DOC "ICU include directory")
Packit Service fa4841
  set(ICU_INCLUDE_DIR "${ICU_INCLUDE_DIR}" PARENT_SCOPE)
Packit Service fa4841
Packit Service fa4841
  # Get version
Packit Service fa4841
  if(ICU_INCLUDE_DIR AND EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h")
Packit Service fa4841
    file(STRINGS "${ICU_INCLUDE_DIR}/unicode/uvernum.h" icu_header_str
Packit Service fa4841
      REGEX "^#define[\t ]+U_ICU_VERSION[\t ]+\".*\".*")
Packit Service fa4841
Packit Service fa4841
    string(REGEX REPLACE "^#define[\t ]+U_ICU_VERSION[\t ]+\"([^ \\n]*)\".*"
Packit Service fa4841
      "\\1" icu_version_string "${icu_header_str}")
Packit Service fa4841
    set(ICU_VERSION "${icu_version_string}" PARENT_SCOPE)
Packit Service fa4841
    unset(icu_header_str)
Packit Service fa4841
    unset(icu_version_string)
Packit Service fa4841
  endif()
Packit Service fa4841
Packit Service fa4841
  # Find all ICU libraries
Packit Service fa4841
  set(ICU_REQUIRED_LIBS_FOUND ON)
Packit Service fa4841
  foreach(component ${ICU_FIND_COMPONENTS})
Packit Service fa4841
    string(TOUPPER "${component}" component_upcase)
Packit Service fa4841
    set(component_cache "ICU_${component_upcase}_LIBRARY")
Packit Service fa4841
    set(component_cache_release "${component_cache}_RELEASE")
Packit Service fa4841
    set(component_cache_debug "${component_cache}_DEBUG")
Packit Service fa4841
    set(component_found "${component_upcase}_FOUND")
Packit Service fa4841
    set(component_libnames "icu${component}")
Packit Service fa4841
    set(component_debug_libnames "icu${component}d")
Packit Service fa4841
Packit Service fa4841
    # Special case deliberate library naming mismatches between Unix
Packit Service fa4841
    # and Windows builds
Packit Service fa4841
    unset(component_libnames)
Packit Service fa4841
    unset(component_debug_libnames)
Packit Service fa4841
    list(APPEND component_libnames "icu${component}")
Packit Service fa4841
    list(APPEND component_debug_libnames "icu${component}d")
Packit Service fa4841
    if(component STREQUAL "data")
Packit Service fa4841
      list(APPEND component_libnames "icudt")
Packit Service fa4841
      # Note there is no debug variant at present
Packit Service fa4841
      list(APPEND component_debug_libnames "icudtd")
Packit Service fa4841
    endif()
Packit Service fa4841
    if(component STREQUAL "dt")
Packit Service fa4841
      list(APPEND component_libnames "icudata")
Packit Service fa4841
      # Note there is no debug variant at present
Packit Service fa4841
      list(APPEND component_debug_libnames "icudatad")
Packit Service fa4841
    endif()
Packit Service fa4841
    if(component STREQUAL "i18n")
Packit Service fa4841
      list(APPEND component_libnames "icuin")
Packit Service fa4841
      list(APPEND component_debug_libnames "icuind")
Packit Service fa4841
    endif()
Packit Service fa4841
    if(component STREQUAL "in")
Packit Service fa4841
      list(APPEND component_libnames "icui18n")
Packit Service fa4841
      list(APPEND component_debug_libnames "icui18nd")
Packit Service fa4841
    endif()
Packit Service fa4841
Packit Service fa4841
    find_library("${component_cache_release}" ${component_libnames}
Packit Service fa4841
      HINTS ${icu_roots}
Packit Service fa4841
      PATH_SUFFIXES ${icu_library_suffixes}
Packit Service fa4841
      DOC "ICU ${component} library (release)")
Packit Service fa4841
    find_library("${component_cache_debug}" ${component_debug_libnames}
Packit Service fa4841
      HINTS ${icu_roots}
Packit Service fa4841
      PATH_SUFFIXES ${icu_library_suffixes}
Packit Service fa4841
      DOC "ICU ${component} library (debug)")
Packit Service fa4841
    include(SelectLibraryConfigurations)
Packit Service fa4841
    select_library_configurations(ICU_${component_upcase})
Packit Service fa4841
    mark_as_advanced("${component_cache_release}" "${component_cache_debug}")
Packit Service fa4841
    if(${component_cache})
Packit Service fa4841
      set("${component_found}" ON)
Packit Service fa4841
      list(APPEND ICU_LIBRARY "${${component_cache}}")
Packit Service fa4841
    endif()
Packit Service fa4841
    mark_as_advanced("${component_found}")
Packit Service fa4841
    set("${component_cache}" "${${component_cache}}" PARENT_SCOPE)
Packit Service fa4841
    set("${component_found}" "${${component_found}}" PARENT_SCOPE)
Packit Service fa4841
    if(${component_found})
Packit Service fa4841
      if (ICU_FIND_REQUIRED_${component})
Packit Service fa4841
        list(APPEND ICU_LIBS_FOUND "${component} (required)")
Packit Service fa4841
      else()
Packit Service fa4841
        list(APPEND ICU_LIBS_FOUND "${component} (optional)")
Packit Service fa4841
      endif()
Packit Service fa4841
    else()
Packit Service fa4841
      if (ICU_FIND_REQUIRED_${component})
Packit Service fa4841
        set(ICU_REQUIRED_LIBS_FOUND OFF)
Packit Service fa4841
        list(APPEND ICU_LIBS_NOTFOUND "${component} (required)")
Packit Service fa4841
      else()
Packit Service fa4841
        list(APPEND ICU_LIBS_NOTFOUND "${component} (optional)")
Packit Service fa4841
      endif()
Packit Service fa4841
    endif()
Packit Service fa4841
  endforeach()
Packit Service fa4841
  set(_ICU_REQUIRED_LIBS_FOUND "${ICU_REQUIRED_LIBS_FOUND}" PARENT_SCOPE)
Packit Service fa4841
  set(ICU_LIBRARY "${ICU_LIBRARY}" PARENT_SCOPE)
Packit Service fa4841
Packit Service fa4841
  if(NOT ICU_FIND_QUIETLY)
Packit Service fa4841
    if(ICU_LIBS_FOUND)
Packit Service fa4841
      message(STATUS "Found the following ICU libraries:")
Packit Service fa4841
      foreach(found ${ICU_LIBS_FOUND})
Packit Service fa4841
        message(STATUS "  ${found}")
Packit Service fa4841
      endforeach()
Packit Service fa4841
    endif()
Packit Service fa4841
    if(ICU_LIBS_NOTFOUND)
Packit Service fa4841
      message(STATUS "The following ICU libraries were not found:")
Packit Service fa4841
      foreach(notfound ${ICU_LIBS_NOTFOUND})
Packit Service fa4841
        message(STATUS "  ${notfound}")
Packit Service fa4841
      endforeach()
Packit Service fa4841
    endif()
Packit Service fa4841
  endif()
Packit Service fa4841
Packit Service fa4841
  if(ICU_DEBUG)
Packit Service fa4841
    message(STATUS "--------FindICU.cmake search debug--------")
Packit Service fa4841
    message(STATUS "ICU binary path search order: ${icu_roots}")
Packit Service fa4841
    message(STATUS "ICU include path search order: ${icu_roots}")
Packit Service fa4841
    message(STATUS "ICU library path search order: ${icu_roots}")
Packit Service fa4841
    message(STATUS "----------------")
Packit Service fa4841
  endif()
Packit Service fa4841
endfunction()
Packit Service fa4841
Packit Service fa4841
_ICU_FIND()
Packit Service fa4841
Packit Service fa4841
include(FindPackageHandleStandardArgs)
Packit Service fa4841
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICU
Packit Service fa4841
                                  FOUND_VAR ICU_FOUND
Packit Service fa4841
                                  REQUIRED_VARS ICU_INCLUDE_DIR
Packit Service fa4841
                                                ICU_LIBRARY
Packit Service fa4841
                                                _ICU_REQUIRED_LIBS_FOUND
Packit Service fa4841
                                  VERSION_VAR ICU_VERSION
Packit Service fa4841
                                  FAIL_MESSAGE "Failed to find all ICU components")
Packit Service fa4841
Packit Service fa4841
unset(_ICU_REQUIRED_LIBS_FOUND)
Packit Service fa4841
Packit Service fa4841
if(ICU_FOUND)
Packit Service fa4841
  set(ICU_INCLUDE_DIRS "${ICU_INCLUDE_DIR}")
Packit Service fa4841
  set(ICU_LIBRARIES "${ICU_LIBRARY}")
Packit Service fa4841
  foreach(_ICU_component ${ICU_FIND_COMPONENTS})
Packit Service fa4841
    string(TOUPPER "${_ICU_component}" _ICU_component_upcase)
Packit Service fa4841
    set(_ICU_component_cache "ICU_${_ICU_component_upcase}_LIBRARY")
Packit Service fa4841
    set(_ICU_component_cache_release "ICU_${_ICU_component_upcase}_LIBRARY_RELEASE")
Packit Service fa4841
    set(_ICU_component_cache_debug "ICU_${_ICU_component_upcase}_LIBRARY_DEBUG")
Packit Service fa4841
    set(_ICU_component_lib "ICU_${_ICU_component_upcase}_LIBRARIES")
Packit Service fa4841
    set(_ICU_component_found "${_ICU_component_upcase}_FOUND")
Packit Service fa4841
    set(_ICU_imported_target "ICU::${_ICU_component}")
Packit Service fa4841
    if(${_ICU_component_found})
Packit Service fa4841
      set("${_ICU_component_lib}" "${${_ICU_component_cache}}")
Packit Service fa4841
      if(NOT TARGET ${_ICU_imported_target})
Packit Service fa4841
        add_library(${_ICU_imported_target} UNKNOWN IMPORTED)
Packit Service fa4841
        if(ICU_INCLUDE_DIR)
Packit Service fa4841
          set_target_properties(${_ICU_imported_target} PROPERTIES
Packit Service fa4841
            INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIR}")
Packit Service fa4841
        endif()
Packit Service fa4841
        if(EXISTS "${${_ICU_component_cache}}")
Packit Service fa4841
          set_target_properties(${_ICU_imported_target} PROPERTIES
Packit Service fa4841
            IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
Packit Service fa4841
            IMPORTED_LOCATION "${${_ICU_component_cache}}")
Packit Service fa4841
        endif()
Packit Service fa4841
        if(EXISTS "${${_ICU_component_cache_release}}")
Packit Service fa4841
          set_property(TARGET ${_ICU_imported_target} APPEND PROPERTY
Packit Service fa4841
            IMPORTED_CONFIGURATIONS RELEASE)
Packit Service fa4841
          set_target_properties(${_ICU_imported_target} PROPERTIES
Packit Service fa4841
            IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
Packit Service fa4841
            IMPORTED_LOCATION_RELEASE "${${_ICU_component_cache_release}}")
Packit Service fa4841
        endif()
Packit Service fa4841
        if(EXISTS "${${_ICU_component_cache_debug}}")
Packit Service fa4841
          set_property(TARGET ${_ICU_imported_target} APPEND PROPERTY
Packit Service fa4841
            IMPORTED_CONFIGURATIONS DEBUG)
Packit Service fa4841
          set_target_properties(${_ICU_imported_target} PROPERTIES
Packit Service fa4841
            IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
Packit Service fa4841
            IMPORTED_LOCATION_DEBUG "${${_ICU_component_cache_debug}}")
Packit Service fa4841
        endif()
Packit Service fa4841
      endif()
Packit Service fa4841
    endif()
Packit Service fa4841
    unset(_ICU_component_upcase)
Packit Service fa4841
    unset(_ICU_component_cache)
Packit Service fa4841
    unset(_ICU_component_lib)
Packit Service fa4841
    unset(_ICU_component_found)
Packit Service fa4841
    unset(_ICU_imported_target)
Packit Service fa4841
  endforeach()
Packit Service fa4841
endif()
Packit Service fa4841
Packit Service fa4841
if(ICU_DEBUG)
Packit Service fa4841
  message(STATUS "--------FindICU.cmake results debug--------")
Packit Service fa4841
  message(STATUS "ICU found: ${ICU_FOUND}")
Packit Service fa4841
  message(STATUS "ICU_VERSION number: ${ICU_VERSION}")
Packit Service fa4841
  message(STATUS "ICU_ROOT directory: ${ICU_ROOT}")
Packit Service fa4841
  message(STATUS "ICU_INCLUDE_DIR directory: ${ICU_INCLUDE_DIR}")
Packit Service fa4841
  message(STATUS "ICU_LIBRARIES: ${ICU_LIBRARIES}")
Packit Service fa4841
Packit Service fa4841
  foreach(program IN LISTS icu_programs)
Packit Service fa4841
    string(TOUPPER "${program}" program_upcase)
Packit Service fa4841
    set(program_lib "ICU_${program_upcase}_EXECUTABLE")
Packit Service fa4841
    message(STATUS "${program} program: ${${program_lib}}")
Packit Service fa4841
    unset(program_upcase)
Packit Service fa4841
    unset(program_lib)
Packit Service fa4841
  endforeach()
Packit Service fa4841
Packit Service fa4841
  foreach(component IN LISTS ICU_FIND_COMPONENTS)
Packit Service fa4841
    string(TOUPPER "${component}" component_upcase)
Packit Service fa4841
    set(component_lib "ICU_${component_upcase}_LIBRARIES")
Packit Service fa4841
    set(component_found "${component_upcase}_FOUND")
Packit Service fa4841
    message(STATUS "${component} library found: ${${component_found}}")
Packit Service fa4841
    message(STATUS "${component} library: ${${component_lib}}")
Packit Service fa4841
    unset(component_upcase)
Packit Service fa4841
    unset(component_lib)
Packit Service fa4841
    unset(component_found)
Packit Service fa4841
  endforeach()
Packit Service fa4841
  message(STATUS "----------------")
Packit Service fa4841
endif()
Packit Service fa4841
Packit Service fa4841
unset(icu_programs)