diff --git a/CMakeLists.txt b/CMakeLists.txt index d08ad7f..7f56398 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,16 @@ else() set(_populate PUBLIC) endif() +if(NOT WIN32) + set(THREADS_PREFER_PTHREAD_FLAG 1) + find_package(Threads REQUIRED) + target_link_libraries(boost_container PUBLIC Threads::Threads) + if(EMSCRIPTEN) + # Boost config needs `-pthread` to see `_POSIX_THREADS`, + # but FindTheads.cmake finishes with `CMAKE_HAVE_LIBC_PTHREAD`. + target_compile_options(boost_container PUBLIC -pthread) + endif() +endif() add_library(Boost::container ALIAS boost_container)