From f61ffcc4496e6f61b7678721a54e73bfbcb4357c Mon Sep 17 00:00:00 2001 From: Mehul Raj Date: Fri, 3 Apr 2026 23:45:52 +0530 Subject: [PATCH] Cmake for all system --- CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 958fb15..e78e8c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,20 +4,28 @@ project(ThreadsafeQueueLib) set(CMAKE_CXX_STANDARD 17) enable_testing() +find_package(Threads REQUIRED) find_package(GTest REQUIRED) include_directories(include) +option(ENABLE_TSAN "Enable ThreadSanitizer" OFF) + +if(ENABLE_TSAN) + add_compile_options(-fsanitize=thread -g -O1) + add_link_options(-fsanitize=thread) +endif() + # SPSC tests add_executable(test_spsc tests/test_spsc.cpp) -target_link_libraries(test_spsc GTest::GTest GTest::Main pthread) +target_link_libraries(test_spsc GTest::GTest GTest::Main Threads::Threads) # MPSC tests add_executable(test_mpsc tests/test_mpsc.cpp) -target_link_libraries(test_mpsc GTest::GTest GTest::Main pthread) +target_link_libraries(test_mpsc GTest::GTest GTest::Main Threads::Threads) # MPMC tests add_executable(test_mpmc tests/test_mpmc.cpp) -target_link_libraries(test_mpmc GTest::GTest GTest::Main pthread) +target_link_libraries(test_mpmc GTest::GTest GTest::Main Threads::Threads) # Register tests add_test(NAME SPSC COMMAND test_spsc)