From 6eb439f2696c02d4c4cfbc6dd99069b33b2e37a5 Mon Sep 17 00:00:00 2001 From: Tamas Kenez Date: Fri, 6 Sep 2019 23:03:04 +0200 Subject: [PATCH] CMake: use find_package for enabling threading library. (#52) Resolves #6 --- CMakeLists.txt | 5 ++++- include/internal/CMakeLists.txt | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65603650..77e34053 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ message("Building CSV library using C++${CMAKE_CXX_STANDARD}") # Defines CSV_HAS_CXX17 in compatibility.hpp add_compile_definitions(CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads QUIET REQUIRED) + if(MSVC) # Make Visual Studio report accurate C++ version # See: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ @@ -23,7 +26,7 @@ if(MSVC) endif() else() # Ignore Visual Studio pragma regions - set(CMAKE_CXX_FLAGS "-pthread -Wno-unknown-pragmas") + set(CMAKE_CXX_FLAGS "-Wno-unknown-pragmas") if(CMAKE_BUILD_TYPE MATCHES Debug) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") else() diff --git a/include/internal/CMakeLists.txt b/include/internal/CMakeLists.txt index 9a37fb17..bf9c9add 100644 --- a/include/internal/CMakeLists.txt +++ b/include/internal/CMakeLists.txt @@ -22,4 +22,5 @@ target_sources(csv row_buffer.cpp ) -set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX) \ No newline at end of file +set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX) +target_link_libraries(csv PRIVATE Threads::Threads)