]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Correct multithread logic, fixing 'unsupported parameter' error 1207/head
authoroleid <oleid@users.noreply.github.com>
Tue, 26 Jun 2018 06:36:41 +0000 (08:36 +0200)
committerGitHub <noreply@github.com>
Tue, 26 Jun 2018 06:36:41 +0000 (08:36 +0200)
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.

build/cmake/lib/CMakeLists.txt

index ade946daf419842c5fbc6ab77060dd4d80e67c66..c4c2f81e6b9f29f0b470a04c95ad79000e0ce8a8 100644 (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)