# #Find pthreads-win32 on Windows, use regular pthreads on any *NIX. #Defines a target Threads::Threads which can be passed to target_link_libraries(). # if (WIN32) #On WIN32, we rely on win32-pthreads include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_path (PTHREADS_INCLUDE_DIR NAMES pthread.h PATHS include ) find_library (PTHREAD_LIBRARY NAMES pthread pthreadVCE2 pthreadVSE2 pthreadVC2 PATHS lib ) find_package_handle_standard_args (Threads DEFAULT_MSG PTHREADS_INCLUDE_DIR PTHREAD_LIBRARY) if(Threads_FOUND) add_library(Threads::Threads INTERFACE IMPORTED) set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${PTHREAD_LIBRARY}") set_property(TARGET Threads::Threads PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${PTHREADS_INCLUDE_DIR}") endif() else() #Assume that all we need to do is to specify the -pthread option to the compiler add_library(Threads::Threads INTERFACE IMPORTED) set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") set (Threads_FOUND TRUE) endif()