Bladeren bron

Enable GCC/Clang support for multithreading with pthread library.

Yao Wei Tjong 姚伟忠 10 jaren geleden
bovenliggende
commit
d29d5f188e
1 gewijzigde bestanden met toevoegingen van 6 en 6 verwijderingen
  1. 6 6
      CMake/Modules/Urho3D-CMake-common.cmake

+ 6 - 6
CMake/Modules/Urho3D-CMake-common.cmake

@@ -499,6 +499,10 @@ else ()
             # Reduce GCC optimization level from -O3 to -O2 for stability in RELEASE build configuration
             set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
             set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
+        else ()
+            # Not Android and not Emscripten and not MinGW derivative
+            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")     # This will emit '-DREENTRANT' to compiler and '-lpthread' to linker on Linux and Mac OSX platform
+            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") # However, it may emit other equivalent compiler define and/or linker flag on other *nix platforms
         endif ()
         set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -D_DEBUG")
         set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -D_DEBUG")
@@ -1201,13 +1205,13 @@ macro (define_dependency_libs TARGET)
         if (WIN32)
             list (APPEND LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
         elseif (APPLE)
-            list (APPEND LIBS dl pthread)
+            list (APPEND LIBS dl)
         elseif (ANDROID)
             list (APPEND LIBS dl log android)
         else ()
             # Linux
             if (NOT EMSCRIPTEN)
-                list (APPEND LIBS dl pthread rt)
+                list (APPEND LIBS dl rt)
             endif ()
             if (RPI)
                 list (APPEND ABSOLUTE_PATH_LIBS ${BCM_VC_LIBRARIES})
@@ -1219,8 +1223,6 @@ macro (define_dependency_libs TARGET)
     if (${TARGET} MATCHES Civetweb|kNet|Urho3D)
         if (WIN32)
             list (APPEND LIBS ws2_32)
-        elseif (NOT ANDROID AND NOT EMSCRIPTEN)
-            list (APPEND LIBS pthread)
         endif ()
     endif ()
 
@@ -1239,8 +1241,6 @@ macro (define_dependency_libs TARGET)
             if (URHO3D_MINIDUMPS)
                 list (APPEND LIBS dbghelp)
             endif ()
-        elseif (NOT ANDROID AND NOT EMSCRIPTEN)
-            list (APPEND LIBS pthread)
         endif ()
 
         # Graphics