diff --git a/blosc/CMakeLists.txt b/blosc/CMakeLists.txt index a3a7b7e2..96ab8b45 100644 --- a/blosc/CMakeLists.txt +++ b/blosc/CMakeLists.txt @@ -65,7 +65,8 @@ 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) @@ -73,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) @@ -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)