Correct multithread logic, fixing 'unsupported parameter' error

The original conditions only worked, when both, static and shared variants where built, resulting in an inconsistency between programs and library. The program was built with MT support enabled, the library not. That lead to error 11 'unsupported parameter' when compressing anything with the command line tool.

When changing the AND condition to `ZSTD_MULTITHREAD_SUPPORT AND (ZSTD_BUILD_SHARED OR ZSTD_BUILD_SHARED)`, cmake stopps complaining one of the targets wasn't built. This commit works for any case.
dev
oleid 2018-06-26 08:36:41 +02:00 committed by GitHub
parent b426bcc097
commit 4e196b2ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 11 deletions

View File

@ -108,9 +108,21 @@ ENDIF (MSVC)
# Split project to static and shared libraries build
IF (ZSTD_BUILD_SHARED)
ADD_LIBRARY(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
IF (ZSTD_MULTITHREAD_SUPPORT)
SET_PROPERTY(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
IF (UNIX)
TARGET_LINK_LIBRARIES(libzstd_shared ${THREADS_LIBS})
ENDIF ()
ENDIF()
ENDIF (ZSTD_BUILD_SHARED)
IF (ZSTD_BUILD_STATIC)
ADD_LIBRARY(libzstd_static STATIC ${Sources} ${Headers})
IF (ZSTD_MULTITHREAD_SUPPORT)
SET_PROPERTY(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
IF (UNIX)
TARGET_LINK_LIBRARIES(libzstd_static ${THREADS_LIBS})
ENDIF ()
ENDIF ()
ENDIF (ZSTD_BUILD_STATIC)
# Add specific compile definitions for MSVC project
@ -123,17 +135,6 @@ IF (MSVC)
ENDIF (ZSTD_BUILD_STATIC)
ENDIF (MSVC)
# Add multi-threading support definitions
IF (ZSTD_MULTITHREAD_SUPPORT AND ZSTD_BUILD_SHARED AND ZSTD_BUILD_STATIC)
SET_PROPERTY(TARGET libzstd_shared libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
IF (UNIX)
TARGET_LINK_LIBRARIES(libzstd_shared ${THREADS_LIBS})
TARGET_LINK_LIBRARIES(libzstd_static ${THREADS_LIBS})
ENDIF ()
ENDIF (ZSTD_MULTITHREAD_SUPPORT AND ZSTD_BUILD_SHARED AND ZSTD_BUILD_STATIC)
# With MSVC static library needs to be renamed to avoid conflict with import library
IF (MSVC)
SET(STATIC_LIBRARY_BASE_NAME zstd_static)