pzstd: fix linking for static builds

dev
Jonathan Ringer 2021-07-09 13:21:15 -07:00
parent b3e372c171
commit e1f85dbca3
No known key found for this signature in database
GPG Key ID: 5C841D3CFDFEC4E0
1 changed files with 7 additions and 1 deletions

View File

@ -21,10 +21,16 @@ add_executable(pzstd ${PROGRAMS_DIR}/util.c ${PZSTD_DIR}/main.cpp ${PZSTD_DIR}/O
set_property(TARGET pzstd APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG") set_property(TARGET pzstd APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG")
set_property(TARGET pzstd APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow") set_property(TARGET pzstd APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow")
if (ZSTD_BUILD_SHARED)
set(ZSTD_LIB libzstd_shared)
else()
set(ZSTD_LIB libzstd_static)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
if (CMAKE_USE_PTHREADS_INIT) if (CMAKE_USE_PTHREADS_INIT)
target_link_libraries(pzstd libzstd_shared ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pzstd ${ZSTD_LIB} ${CMAKE_THREAD_LIBS_INIT})
else() else()
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads") message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
endif() endif()