CMake on Mac: Could NOT find Threads (missing: Threads_FOUND)
Asked Answered
A

1

18

I'm trying to compile LibPD and I am receiving a CMake error message. I have scourged the net for solutions dealing with this problem on Mac, but have found none that are from the past 10 years. I am receiving this error on both my MacBook Pro and my Mac tower desktop. :

I type:

cmake .. -GXcode

I get:

CMake Error at /Applications/CMake.app/Contents/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.13/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:317 (find_package)

Thanks for the help.

Autophyte answered 8/2, 2019 at 6:28 Comment(0)
R
35

Although I did not get this error on mojave, one way to deal with threads on mac is to tell cmake threads are built in.

# assume built-in pthreads on MacOS
IF(APPLE)
    set(CMAKE_THREAD_LIBS_INIT "-lpthread")
    set(CMAKE_HAVE_THREADS_LIBRARY 1)
    set(CMAKE_USE_WIN32_THREADS_INIT 0)
    set(CMAKE_USE_PTHREADS_INIT 1)
    set(THREADS_PREFER_PTHREAD_FLAG ON)
ENDIF()
Rossini answered 9/2, 2019 at 13:18 Comment(3)
Just had to refer to my own answer from three years ago.Rossini
I pasted this into the CMakeLists.txt file and it worked.Collative
Works for me in Ubuntu Bionic as wellSalmon

© 2022 - 2024 — McMap. All rights reserved.