From 2ddf534a75b450478c853b027bf6b286f03a6b86 Mon Sep 17 00:00:00 2001 From: nouscow <1444879603@qq.com> Date: Fri, 31 Jul 2026 19:25:04 +0800 Subject: [PATCH 1/2] docs: add CMake build instructions and CMakeLists.txt --- .gitignore | 3 +++ CMakeLists.txt | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f654d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +.idea/ +cmake-build-debug/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e0306b7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(ThreadPoolDemo LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Threads REQUIRED) + +add_executable(tp_main example.cpp) +target_link_libraries(tp_main PRIVATE Threads::Threads) \ No newline at end of file From f52ced48b748c323a2d3f330e370b2afdf089710 Mon Sep 17 00:00:00 2001 From: nouscow <1444879603@qq.com> Date: Fri, 31 Jul 2026 19:38:08 +0800 Subject: [PATCH 2/2] docs: add Build with CMake section to README --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index be3d25a..404f37a 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,29 @@ auto result = pool.enqueue([](int answer) { return answer; }, 42); std::cout << result.get() << std::endl; ``` +## Build with CMake + +This project includes a `CMakeLists.txt` for easy cross-platform building. + +### Requirements + +- C++11 compatible compiler (GCC 5+, Clang 3.3+, MSVC 2015+) +- CMake 3.10 or higher + +### Build & Run + +```bash +mkdir build +cd build +cmake .. +cmake --build . +./tp_main +``` + +### Direct Compilation (Linux/macOS) + +```bash +g++ -std=c++11 -pthread example.cpp -o tp_main && ./tp_main +``` + +---