Skip to content

Commit

Permalink
FindBlosc.cmake: Threads
Browse files Browse the repository at this point in the history
Blosc depends unconditionally on threads.
If we are not using the config package, we need to re-add the
pthreads flags or we will get linker errors.

We are sometimes lucky at the moment that in some build configs
pthread flags land in the right order on the commands line, but
generally we should declare this dependency.
  • Loading branch information
ax3l committed Jun 18, 2021
1 parent 63bacf0 commit 0eecc07
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmake/FindBlosc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ if(NOT BLOSC_FOUND)
endif()
endif()

# Blosc depends on pthreads
# https://github.com/Blosc/c-blosc/blob/master/blosc/CMakeLists.txt
# https://github.com/Blosc/c-blosc/pull/318
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
if(WIN32)
# try to use the system library
find_package(Threads)
if(NOT Threads_FOUND)
message(STATUS "Blosc: used the internal pthread library for win32 systems.")
set(BLOSC_LIBRARIES)
else()
set(BLOSC_LIBRARIES Threads::Threads)
endif()
else()
find_package(Threads REQUIRED)
set(BLOSC_LIBRARIES Threads::Threads)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Blosc
FOUND_VAR BLOSC_FOUND
Expand All @@ -68,6 +86,7 @@ if(NOT BLOSC_FOUND)
set_target_properties(Blosc::Blosc PROPERTIES
IMPORTED_LOCATION "${BLOSC_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${BLOSC_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${BLOSC_LIBRARIES}"
)
endif()
endif()
Expand Down

0 comments on commit 0eecc07

Please sign in to comment.