Skip to content

Commit

Permalink
Merge pull request #318 from ax3l/fix-cmakePthreadFlag
Browse files Browse the repository at this point in the history
CMake: Fix PThread Flag
  • Loading branch information
FrancescAlted authored Jun 22, 2021
2 parents 7435f28 + 94234af commit f4ef2f3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions blosc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,28 @@ set(SOURCES ${SOURCES} shuffle.c)
set(lib_dir lib${LIB_SUFFIX})
set(version_string ${BLOSC_VERSION_MAJOR}.${BLOSC_VERSION_MINOR}.${BLOSC_VERSION_PATCH})

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE) # pre 3.1
set(THREADS_PREFER_PTHREAD_FLAG TRUE) # CMake 3.1+
if(WIN32)
# try to use the system library
find_package(Threads)
if(NOT Threads_FOUND)
message(STATUS "using the internal pthread library for win32 systems.")
set(SOURCES ${SOURCES} win32/pthread.c)
else(NOT Threads_FOUND)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
if(CMAKE_VERSION VERSION_LESS 3.1)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
else()
set(LIBS ${LIBS} Threads::Threads)
endif()
endif(NOT Threads_FOUND)
else(WIN32)
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
if(CMAKE_VERSION VERSION_LESS 3.1)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
else()
set(LIBS ${LIBS} Threads::Threads)
endif()
endif(WIN32)

if(NOT DEACTIVATE_LZ4)
Expand Down Expand Up @@ -186,13 +195,6 @@ if (BUILD_TESTS)
set_property(
TARGET blosc_shared_testing
APPEND PROPERTY COMPILE_DEFINITIONS BLOSC_TESTING)
# TEMP : CMake doesn't automatically add -lpthread here like it does
# for the blosc_shared target. Force it for now.
if(UNIX)
set_property(
TARGET blosc_shared_testing
APPEND PROPERTY LINK_FLAGS "-lpthread")
endif()
endif()

if (BUILD_SHARED)
Expand Down

0 comments on commit f4ef2f3

Please sign in to comment.