Skip to content

Commit

Permalink
CMake 3.1+: Prefer Threads::Threads Target
Browse files Browse the repository at this point in the history
This target does potentially contain CXX flags and linker flags
and shoulds thus be preferred.

It should also address the already work-arounded pthread linker
issue in one of the tests.
  • Loading branch information
ax3l committed Jun 16, 2021
1 parent 353979b commit 94234af
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions blosc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,19 @@ if(WIN32)
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 @@ -187,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 94234af

Please sign in to comment.