cmake: Could NOT find Threads (missing: Threads_FOUND) 解决办法

When compiling the project, I encountered the following problems:

-- Looking for pthread.h - not found
CMake Error at /usr/local/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/usr/local/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.10/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
src/lib/third_party/glfw/CMakeLists.txt:70 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/ec2-user/libraries/geogram/build/Linux64-gcc-dynamic-Release/CMakeFiles/CMakeOutput.log".
See also "/home/ec2-user/libraries/geogram/build/Linux64-gcc-dynamic-Release/CMakeFiles/CMakeError.log".

Add the following statement at the top of CMakeLists.txt:

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)

Recompile, you can compile and pass.

Reference link: https://github.com/alicevision/geogram/issues/2

Guess you like

Origin blog.csdn.net/hongge_smile/article/details/108789449