Convert System.Globalization.Native to use a configure.cmake and .h.in files.
authorEric Erhardt <eric.erhardt@microsoft.com>
Thu, 7 Jan 2016 22:14:16 +0000 (16:14 -0600)
committerEric Erhardt <eric.erhardt@microsoft.com>
Fri, 8 Jan 2016 19:19:00 +0000 (13:19 -0600)
src/corefx/System.Globalization.Native/CMakeLists.txt
src/corefx/System.Globalization.Native/calendarData.cpp
src/corefx/System.Globalization.Native/config.h.in [new file with mode: 0644]
src/corefx/System.Globalization.Native/configure.cmake [new file with mode: 0644]

index 71b5c039d21e636ec00db7a345750539a2de817a..0b4e402106335155ccaa20e67975e142b4f0ad4e 100644 (file)
@@ -1,6 +1,5 @@
 
 project(System.Globalization.Native)
-include(CheckCXXSourceCompiles)
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
@@ -29,28 +28,16 @@ if(NOT CLR_CMAKE_PLATFORM_DARWIN)
     endif()
 
     set(CMAKE_REQUIRED_INCLUDES ${ICU_HOMEBREW_INC_PATH})
-    CHECK_CXX_SOURCE_COMPILES("
-     #include <unicode/udat.h>
-     int main() { UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
-    " HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
-
-    if(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
-        add_definitions(-DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS=1)
-    endif(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
-
 else()
-
     find_library(ICUCORE icucore)
     if(ICUI18N STREQUAL ICUCORE-NOTFOUND)
         message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.")
         return()
     endif()
-
-    # libicucore supports UDAT_STANDALONE_SHORTER_WEEKDAYS
-    add_definitions(-DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS=1)
-
 endif()
 
+include(configure.cmake)
+
 add_compile_options(-fPIC)
 
 set(NATIVEGLOBALIZATION_SOURCES
index f223e6836ddc52fb69b602720d7509456320a72a..3bb6dfedac86b85dfb89cd8ecd9746a64737a4e6 100644 (file)
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <vector>
 
+#include "config.h"
 #include "locale.hpp"
 #include "holders.h"
 
@@ -577,8 +578,7 @@ extern "C" int32_t EnumCalendarInfo(EnumCalendarInfoCallback callback,
         case SuperShortDayNames:
             // UDAT_STANDALONE_SHORTER_WEEKDAYS was added in ICU 51, and CentOS 7 currently uses ICU 50.
             // fallback to UDAT_STANDALONE_NARROW_WEEKDAYS in that case.
-
-#ifdef HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
+#if HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
             return EnumSymbols(locale, calendarId, UDAT_STANDALONE_SHORTER_WEEKDAYS, 1, callback, context);
 #else
             return EnumSymbols(locale, calendarId, UDAT_STANDALONE_NARROW_WEEKDAYS, 1, callback, context);
diff --git a/src/corefx/System.Globalization.Native/config.h.in b/src/corefx/System.Globalization.Native/config.h.in
new file mode 100644 (file)
index 0000000..c8e097f
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+#cmakedefine01 HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
diff --git a/src/corefx/System.Globalization.Native/configure.cmake b/src/corefx/System.Globalization.Native/configure.cmake
new file mode 100644 (file)
index 0000000..f1cc9c6
--- /dev/null
@@ -0,0 +1,10 @@
+include(CheckCXXSourceCompiles)
+
+CHECK_CXX_SOURCE_COMPILES("
+    #include <unicode/udat.h>
+    int main() { UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
+" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
+
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+    ${CMAKE_CURRENT_BINARY_DIR}/config.h)