view Resources/CMake/LibIcuConfiguration.cmake @ 3254:e89e378e71e4

masm not working
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 16 Feb 2019 15:46:53 +0100
parents 759cc438886e
children d4141f5f7fe2
line wrap: on
line source


# Check out: ../ThirdParty/icu/README.txt

# http://userguide.icu-project.org/packaging
# http://userguide.icu-project.org/howtouseicu

message("Using libicu")

if (STATIC_BUILD OR NOT USE_SYSTEM_LIBICU)
  include(${CMAKE_CURRENT_LIST_DIR}/../ThirdParty/icu/Version.cmake)
  DownloadPackage(${LIBICU_MD5} ${LIBICU_URL} "${LIBICU_SOURCES_DIR}")

  if (OFF)
    # In Visual Studio 2015, we get the following error if using plain
    # C: "icudt58l_dat.c(1638339): fatal error C1060: compiler is out
    # of heap space" => use Microsoft Assembler to circumvent this issue
    DownloadCompressedFile(${LIBICU_MASM_MD5} ${LIBICU_MASM_URL} ${LIBICU_MASM})

    enable_language(ASM_MASM)
    set(LIBICU_SOURCES
      ${CMAKE_BINARY_DIR}/${LIBICU_MASM}
      )
  else()
    # Use plain C data library
    DownloadCompressedFile(${LIBICU_DATA_MD5} ${LIBICU_DATA_URL} ${LIBICU_DATA})

    set_source_files_properties(
      ${CMAKE_BINARY_DIR}/${LIBICU_DATA}
      PROPERTIES COMPILE_DEFINITIONS "char16_t=uint16_t"
      )

    set(LIBICU_SOURCES
      ${CMAKE_BINARY_DIR}/${LIBICU_DATA}
      )
  endif()
  
  include_directories(BEFORE
    ${LIBICU_SOURCES_DIR}/source/common
    ${LIBICU_SOURCES_DIR}/source/i18n
    )

  aux_source_directory(${LIBICU_SOURCES_DIR}/source/common LIBICU_SOURCES)
  aux_source_directory(${LIBICU_SOURCES_DIR}/source/i18n LIBICU_SOURCES)

  add_definitions(
    #-DU_COMBINED_IMPLEMENTATION
    #-DU_DEF_ICUDATA_ENTRY_POINT=icudt63l_dat
    #-DU_LIB_SUFFIX_C_NAME=l

    #-DUCONFIG_NO_SERVICE=1
    -DU_COMMON_IMPLEMENTATION
    -DU_ENABLE_DYLOAD=0
    -DU_HAVE_STD_STRING=1
    -DU_I18N_IMPLEMENTATION
    -DU_IO_IMPLEMENTATION
    -DU_STATIC_IMPLEMENTATION=1
    #-DU_CHARSET_IS_UTF8
    -DUNISTR_FROM_STRING_EXPLICIT=
    )

  if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
    set_source_files_properties(
      ${LIBICU_SOURCES_DIR}/source/common/locmap.c
      PROPERTIES COMPILE_DEFINITIONS "LOCALE_SNAME=0x0000005c"
      )
  endif()

  source_group(ThirdParty\\libicu REGULAR_EXPRESSION ${LIBICU_SOURCES_DIR}/.*)

else() 
  CHECK_INCLUDE_FILE_CXX(unicode/uvernum.h HAVE_ICU_H)
  if (NOT HAVE_ICU_H)
    message(FATAL_ERROR "Please install the libicu-dev package")
  endif()

  find_library(LIBICU_PATH_1 NAMES icuuc)
  find_library(LIBICU_PATH_2 NAMES icui18n)

  if (NOT LIBICU_PATH_1 OR 
      NOT LIBICU_PATH_2)
    message(FATAL_ERROR "Please install the libicu-dev package")
  else()
    link_libraries(icuuc icui18n)
  endif()
endif()