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 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 +``` + +---