Maratyszcza / pthreadpool

Portable (POSIX/Windows/Emscripten) thread pool for C/C++
BSD 2-Clause "Simplified" License
342 stars 132 forks source link

Build on IOS platform using XCode generator #2

Closed panic-milan closed 6 years ago

panic-milan commented 6 years ago

Hi, on iOS platform CMake with XCode generator breaks on find_package(THREADS)

This is general issue with cmake and this generator, you can take a look at: https://gitlab.kitware.com/cmake/cmake/issues/16695

Could you include following patch in master code?

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b2affe4..2d66c07 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,7 +94,9 @@ PTHREADPOOL_TARGET_ENABLE_C99(pthreadpool)
 TARGET_LINK_LIBRARIES(pthreadpool PUBLIC pthreadpool_interface)
 IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
   SET(CMAKE_THREAD_PREFER_PTHREAD TRUE)
-  FIND_PACKAGE(Threads REQUIRED)
+  IF(NOT CMAKE_GENERATOR STREQUAL "Xcode")
+    FIND_PACKAGE(Threads REQUIRED)
+  ENDIF()
   IF(CMAKE_USE_PTHREADS_INIT)
     IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
       TARGET_COMPILE_OPTIONS(pthreadpool PUBLIC -pthread)

If needed I can create pull request? Regards, Milan