-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads CMake Error at /usr/share/cmake/Modules/CheckLibraryExists.cmake:41 (try_compile): Only libraries may be used as try_compile IMPORTED LINK_LIBRARIES. Got pthreads of type EXECUTABLE. Call Stack (most recent call first): /usr/share/cmake/Modules/FindThreads.cmake:58 (CHECK_LIBRARY_EXISTS) tests/app_suite/CMakeLists.txt:58 (find_package)
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
我在fedora 18 64位。
find_package(Threads REQUIRED)
target_link_libraries(app_suite_tests ${CMAKE_THREAD_LIBS_INIT})
是创建它的代码。我该怎么做才能防止 CMake 在此处引发错误,或者如何让 CMake 通过可执行文件检查 pthreads 库?
谢谢。
附加信息:
if(NOT CMAKE_HAVE_THREADS_LIBRARY)
# Do we have -lpthreads
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
if(CMAKE_HAVE_PTHREADS_CREATE)
set(CMAKE_THREAD_LIBS_INIT "-lpthreads")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
endif()
来自 FindThreads.cmake,错误在 CHECK_LIBRARY_EXISTS 上抛出