changeset 1379:d0bb3dd34e2d

find build on old versions of MinGW
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 29 May 2015 12:59:43 +0200
parents 5dabfaf6034b
children 31b884468b05
files Resources/CMake/GoogleLogConfiguration.cmake Resources/Patches/glog-port-h-v2.diff
diffstat 2 files changed, 35 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/GoogleLogConfiguration.cmake	Fri May 29 11:57:53 2015 +0200
+++ b/Resources/CMake/GoogleLogConfiguration.cmake	Fri May 29 12:59:43 2015 +0200
@@ -166,3 +166,11 @@
 
   link_libraries(glog)
 endif()
+
+
+CHECK_INCLUDE_FILES(sec_api/string_s.h HAVE_SECURE_STRING_EXTENSIONS)
+if (HAVE_SECURE_STRING_EXTENSIONS)
+  add_definitions(-DHAVE_SECURE_STRING_EXTENSIONS=1)
+else()
+  add_definitions(-DHAVE_SECURE_STRING_EXTENSIONS=0)
+endif()
--- a/Resources/Patches/glog-port-h-v2.diff	Fri May 29 11:57:53 2015 +0200
+++ b/Resources/Patches/glog-port-h-v2.diff	Fri May 29 12:59:43 2015 +0200
@@ -1,4 +1,29 @@
-124a125
+124a125,149
+> 
+> #if HAVE_SECURE_STRING_EXTENSIONS == 0
+> // Emulation of "localtime_s" and "strerror_s" for old versions of MinGW
+> inline int localtime_s(tm * _tm, const time_t * time)
+> {
+>   tm * posix_local_time_struct = localtime(time);
+>   if (posix_local_time_struct == NULL) 
+>   {
+>     return 1;
+>   }
+> 
+>   *_tm = *posix_local_time_struct;
+> 
+>   return 0;
+> }
+> 
+> inline char* strerror_s(char* buf, size_t buflen, int errnum) 
+> {
+>   const char* str = strerror(errnum);
+>   return strncpy(buf, str, buflen - 1);
+> }
+> #endif
+> 
+> 
 > #if !defined(__MINGW32__)
-135a137
+135a161,162
 > #endif
+>