changeset 3266:25df9eae8891

fixing Visual Studio 2015 64bit with ICU
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Feb 2019 14:39:27 +0100
parents 59a184cbb596
children 9b87beefbeb1
files Resources/CMake/LibIcuConfiguration.cmake Resources/ThirdParty/icu/CMakeLists.txt Resources/ThirdParty/icu/Version.cmake
diffstat 3 files changed, 49 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/LibIcuConfiguration.cmake	Wed Feb 20 14:17:52 2019 +0100
+++ b/Resources/CMake/LibIcuConfiguration.cmake	Wed Feb 20 14:39:27 2019 +0100
@@ -10,15 +10,16 @@
   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})
+  if (MSVC AND
+      CMAKE_SIZEOF_VOID_P EQUAL 8)
+    # In Visual Studio 2015 64bit, we get the following error if using
+    # the plain C version of the ICU data: "icudt58l_dat.c(1638339):
+    # fatal error C1060: compiler is out of heap space" => we use a
+    # precompiled binary generated using MinGW on Linux
+    DownloadCompressedFile(${LIBICU_DATA_WIN64_MD5} ${LIBICU_DATA_WIN64_URL} ${LIBICU_DATA_WIN64})
 
-    enable_language(ASM_MASM)
     set(LIBICU_SOURCES
-      ${CMAKE_BINARY_DIR}/${LIBICU_MASM}
+      ${CMAKE_BINARY_DIR}/${LIBICU_DATA_WIN64}
       )
   else()
     # Use plain C data library
--- a/Resources/ThirdParty/icu/CMakeLists.txt	Wed Feb 20 14:17:52 2019 +0100
+++ b/Resources/ThirdParty/icu/CMakeLists.txt	Wed Feb 20 14:39:27 2019 +0100
@@ -58,12 +58,6 @@
   DEPENDS  IcuCodeGeneration
   )
 
-add_custom_command(
-  OUTPUT   ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat.S
-  COMMAND  IcuCodeGeneration ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}.dat --assembly masm
-  DEPENDS  IcuCodeGeneration
-  )
-
 # "--no-name" is necessary for 7-zip on Windows to behave similarly to gunzip
 add_custom_command(
   OUTPUT   ${CMAKE_BINARY_DIR}/${LIBICU_DATA}.gz
@@ -71,21 +65,51 @@
   DEPENDS  ${LIBICU_DATA}
   )
 
-add_custom_command(
-  OUTPUT   ${CMAKE_BINARY_DIR}/${LIBICU_MASM}.gz
-  COMMAND  gzip ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat.S --no-name -c > ${CMAKE_BINARY_DIR}/${LIBICU_MASM}.gz
-  DEPENDS  ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat.S
-  )
+
+if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+  # Generate a precompiled version for Visual Studio 64bit
+  set(TMP_ASSEMBLER      ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat.S)
+  set(TMP_OBJECT         ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat-x86_64-mingw32.o)
+  set(TMP_LIBRARY        ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat-x86_64-mingw32.a)
+  set(PRECOMPILED_WIN64  ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}_dat-x86_64-mingw32.a.gz)
+  
+  add_custom_command(
+    OUTPUT   ${TMP_ASSEMBLER}
+    COMMAND  IcuCodeGeneration ${CMAKE_BINARY_DIR}/${LIBICU_DATA_VERSION}.dat --assembly gcc-mingw64
+    DEPENDS  IcuCodeGeneration
+    )
+
+  add_custom_command(
+    OUTPUT   ${TMP_OBJECT}
+    COMMAND  x86_64-w64-mingw32-gcc -c ${TMP_ASSEMBLER} -o ${TMP_OBJECT}
+    DEPENDS  ${TMP_ASSEMBLER}
+    )
+
+  add_custom_command(
+    OUTPUT   ${TMP_LIBRARY}
+    COMMAND  x86_64-w64-mingw32-ar qc ${TMP_LIBRARY} ${TMP_OBJECT}
+    COMMAND  x86_64-w64-mingw32-ranlib ${TMP_LIBRARY}
+    DEPENDS  ${TMP_OBJECT}
+    )
+
+  # "--no-name" is necessary for 7-zip on Windows to behave similarly to gunzip
+  add_custom_command(
+    OUTPUT   ${PRECOMPILED_WIN64}
+    COMMAND  gzip ${TMP_LIBRARY} --no-name -c > ${PRECOMPILED_WIN64}
+    DEPENDS  ${TMP_LIBRARY}
+    )
+endif()
+
 
 add_custom_target(Final ALL DEPENDS
   ${CMAKE_BINARY_DIR}/${LIBICU_DATA}.gz
-  ${CMAKE_BINARY_DIR}/${LIBICU_MASM}.gz
+  ${PRECOMPILED_WIN64}
   )
 
 install(
   FILES
   ${CMAKE_BINARY_DIR}/${LIBICU_DATA}.gz
-  ${CMAKE_BINARY_DIR}/${LIBICU_MASM}.gz
+  ${PRECOMPILED_WIN64}
   DESTINATION ${CMAKE_SOURCE_DIR}/../../../ThirdPartyDownloads
   )
 
--- a/Resources/ThirdParty/icu/Version.cmake	Wed Feb 20 14:17:52 2019 +0100
+++ b/Resources/ThirdParty/icu/Version.cmake	Wed Feb 20 14:39:27 2019 +0100
@@ -20,19 +20,18 @@
   set(LIBICU_MD5 "fac212b32b7ec7ab007a12dff1f3aea1")
   set(LIBICU_DATA_VERSION "icudt58")
   set(LIBICU_DATA_MD5 "ce2c7791ab637898553c121633155fb6")
-  set(LIBICU_MASM_MD5 "8593ff014574adce0e5119762b428dc5")
+  set(LIBICU_DATA_WIN64_MD5 "8f7edfce3bff7edb0e5714cb66f891cb")
 else()
   set(LIBICU_URL "${LIBICU_BASE_URL}/icu4c-63_1-src.tgz")
   set(LIBICU_MD5 "9e40f6055294284df958200e308bce50")
   set(LIBICU_DATA_VERSION "icudt63")
   set(LIBICU_DATA_MD5 "92b5c73a1accd8ecf8c20c89bc6925a9")
-  set(LIBICU_MASM_MD5 "016c28245796502194e4d81d5d1255e4")
+  set(LIBICU_DATA_WIN64_MD5 "edc00315f042c802547d8e4bd95b09f7")
 endif()
 
 set(LIBICU_SOURCES_DIR ${CMAKE_BINARY_DIR}/icu)
 set(LIBICU_DATA "${LIBICU_DATA_VERSION}${LIBICU_SUFFIX}_dat.c")
 set(LIBICU_DATA_URL "${LIBICU_BASE_URL}/${LIBICU_DATA}.gz")
 
-# For Microsoft assembler (masm). This is necessarily little-endian.
-set(LIBICU_MASM "${LIBICU_DATA_VERSION}_dat.asm")
-set(LIBICU_MASM_URL "${LIBICU_BASE_URL}/${LIBICU_MASM}.gz")
+set(LIBICU_DATA_WIN64 "${LIBICU_DATA_VERSION}${LIBICU_SUFFIX}_dat-w86_64-mingw32.a")
+set(LIBICU_DATA_WIN64_URL "${LIBICU_BASE_URL}/${LIBICU_DATA_WIN64}.gz")