changeset 1381:0d9812893262

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 29 May 2015 13:57:54 +0200
parents 31b884468b05
children 1cd2e09cb0e5
files Resources/CMake/Compiler.cmake Resources/Patches/glog-port-h-v2.diff
diffstat 2 files changed, 35 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/Compiler.cmake	Fri May 29 13:23:54 2015 +0200
+++ b/Resources/CMake/Compiler.cmake	Fri May 29 13:57:54 2015 +0200
@@ -71,9 +71,15 @@
     # This is a patch for MinGW64
     SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++")
 
-    # This line is necessary to compile with recent versions of MinGW,
-    # otherwise "libwinpthread-1.dll" is not statically linked.
-    SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic")
+    CHECK_LIBRARY_EXISTS(winpthread pthread_create "" HAVE_WIN_PTHREAD)
+    if (HAVE_WIN_PTHREAD)
+      # This line is necessary to compile with recent versions of MinGW,
+      # otherwise "libwinpthread-1.dll" is not statically linked.
+      SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic")
+      add_definitions(-DHAVE_WIN_PTHREAD=1)
+    else()
+      add_definitions(-DHAVE_WIN_PTHREAD=0)
+    endif()
   endif()
 
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
--- a/Resources/Patches/glog-port-h-v2.diff	Fri May 29 13:23:54 2015 +0200
+++ b/Resources/Patches/glog-port-h-v2.diff	Fri May 29 13:57:54 2015 +0200
@@ -1,4 +1,13 @@
-124a125,149
+124,130c124,146
+< // ----------------------------------- THREADS
+< typedef DWORD pthread_t;
+< typedef DWORD pthread_key_t;
+< typedef LONG pthread_once_t;
+< enum { PTHREAD_ONCE_INIT = 0 };   // important that this be 0! for SpinLock
+< #define pthread_self  GetCurrentThreadId
+< #define pthread_equal(pthread_t_1, pthread_t_2)  ((pthread_t_1)==(pthread_t_2))
+---
+> // ----------------------------------- SECURE STRINGS
 > 
 > #if HAVE_SECURE_STRING_EXTENSIONS == 0
 > // Emulation of "localtime_s" and "strerror_s" for old versions of MinGW
@@ -21,9 +30,23 @@
 >   return strncpy(buf, str, buflen - 1);
 > }
 > #endif
-> 
+131a148,149
 > 
 > #if !defined(__MINGW32__) || HAVE_SECURE_STRING_EXTENSIONS == 0
-135a161,162
+135a154,155
 > #endif
 > 
+140a161,173
+> 
+> 
+> // ----------------------------------- THREADS
+> 
+> #if !defined(__MINGW32__) || HAVE_WIN_PTHREAD == 0
+> typedef DWORD pthread_t;
+> typedef DWORD pthread_key_t;
+> typedef LONG pthread_once_t;
+> enum { PTHREAD_ONCE_INIT = 0 };   // important that this be 0! for SpinLock
+> #define pthread_self  GetCurrentThreadId
+> #define pthread_equal(pthread_t_1, pthread_t_2)  ((pthread_t_1)==(pthread_t_2))
+> #endif
+>