2 find_package(Threads REQUIRED) 3 if(THREADS_HAVE_PTHREAD_ARG) 4 set_property(TARGET fork PROPERTY COMPILE_OPTIONS "-pthread") 5 set_property(TARGET fork PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") 6 endif() 7 if(CMAKE_THREAD_LIBS_INIT) 8 target_link_libraries(fork "${CMAKE_THREAD_LIBS_INIT}") 9 endif()
在对应的CMakeLists.txt文件夹下添加以上内容