From: oleid Date: Tue, 26 Jun 2018 06:36:41 +0000 (+0200) Subject: Correct multithread logic, fixing 'unsupported parameter' error X-Git-Tag: v1.3.5~3^2~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e196b2ac3a21116b8b24597b294315e33825269;p=thirdparty%2Fzstd.git 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. --- diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index ade946daf..c4c2f81e6 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -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)