在add_executable()之前增加:
set(CMAKE_CXX_FLAGS -pthread) message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")