Skip to content

Commit

Permalink
CMake: use find_package for enabling threading library. (#52)
Browse files Browse the repository at this point in the history
Resolves #6
  • Loading branch information
tamaskenez authored and vincentlaucsb committed Sep 6, 2019
1 parent bdfb5cf commit 6eb439f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion include/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ target_sources(csv
row_buffer.cpp
)

set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(csv PRIVATE Threads::Threads)

0 comments on commit 6eb439f

Please sign in to comment.