From 9e867db90adeacd3f2e241c1f3d1097640c69c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 2 Jan 2017 10:14:35 +0100 Subject: cmake: Fix SOVERSION to match Makefiles Fix SOVERSION to use only major lz4 version, as Makefiles do. This ensure that CMake uses 'liblz.so.1' SONAME and creates 'liblz.so.1' symlink. --- contrib/cmake_unofficial/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt index de070d6..2380a0b 100644 --- a/contrib/cmake_unofficial/CMakeLists.txt +++ b/contrib/cmake_unofficial/CMakeLists.txt @@ -99,7 +99,7 @@ endif() # liblz4 add_library(lz4 ${LZ4_SOURCES}) set_target_properties(lz4 PROPERTIES - SOVERSION "${LZ4_VERSION_STRING}" + SOVERSION "${LZ4_VERSION_MAJOR}" VERSION "${LZ4_VERSION_STRING}" POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_CODE}) -- cgit v0.12 From 28db4acc90805c8bcc183b788900ac566b0346d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 2 Jan 2017 10:34:12 +0100 Subject: cmake: Support building shared & static libs simultaneously Add an additional BUILD_STATIC_LIBS option to control building static libraries independently of shared. This makes it possible (if both options are set to ON) to build both shared and static libraries simulataneously. A dependant option is used to preserve the current BUILD_SHARED_LIBS behavior, i.e. -DBUILD_SHARED_LIBS=ON -- shared lib only, -DBUILD_SHARED_LIBS=OFF -- static lib only. The targets used to build shared and static library are split now, and only relevant properties are passed to each of them. An alias is used to link programs to the preferred library. --- contrib/cmake_unofficial/CMakeLists.txt | 44 +++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt index 2380a0b..df16d46 100644 --- a/contrib/cmake_unofficial/CMakeLists.txt +++ b/contrib/cmake_unofficial/CMakeLists.txt @@ -65,6 +65,11 @@ endif(NOT LZ4_BUNDLED_MODE AND NOT CPack_CMake_INCLUDED) # which case we always use static libraries. include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON "NOT LZ4_BUNDLED_MODE" OFF) +CMAKE_DEPENDENT_OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF "BUILD_SHARED_LIBS" ON) + +if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) + message(FATAL_ERROR "Both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS have been disabled") +endif() set(LZ4_LIB_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/lib") set(LZ4_PROG_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/programs") @@ -90,28 +95,41 @@ set(LZ4_CLI_SOURCES # we're building a shared library this is ignored and PIC is always # used. option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ON) -if(LZ4_POSITION_INDEPENDENT_LIB OR BUILD_SHARED_LIBS) - set(LZ4_POSITION_INDEPENDENT_CODE TRUE) -else() - set(LZ4_POSITION_INDEPENDENT_CODE FALSE) -endif() # liblz4 -add_library(lz4 ${LZ4_SOURCES}) -set_target_properties(lz4 PROPERTIES - SOVERSION "${LZ4_VERSION_MAJOR}" - VERSION "${LZ4_VERSION_STRING}" - POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_CODE}) +set(LZ4_LIBRARIES_BUILT) +if(BUILD_SHARED_LIBS) + add_library(lz4_shared SHARED ${LZ4_SOURCES}) + set_target_properties(lz4_shared PROPERTIES + OUTPUT_NAME lz4 + SOVERSION "${LZ4_VERSION_MAJOR}" + VERSION "${LZ4_VERSION_STRING}") + list(APPEND LZ4_LIBRARIES_BUILT lz4_shared) +endif() +if(BUILD_STATIC_LIBS) + add_library(lz4_static STATIC ${LZ4_SOURCES}) + set_target_properties(lz4_static PROPERTIES + OUTPUT_NAME lz4 + POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB}) + list(APPEND LZ4_LIBRARIES_BUILT lz4_static) +endif() + +# link to shared whenever possible, to static otherwise +if(BUILD_SHARED_LIBS) + set(LZ4_LINK_LIBRARY lz4_shared) +else() + set(LZ4_LINK_LIBRARY lz4_static) +endif() # lz4 add_executable(lz4cli ${LZ4_CLI_SOURCES}) set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4) -target_link_libraries(lz4cli lz4) +target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY}) # lz4c add_executable(lz4c ${LZ4_CLI_SOURCES}) set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS") -target_link_libraries(lz4c lz4) +target_link_libraries(lz4c ${LZ4_LINK_LIBRARY}) # Extra warning flags include (CheckCCompilerFlag) @@ -149,7 +167,7 @@ if(NOT LZ4_BUNDLED_MODE) install(TARGETS lz4cli lz4c RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(TARGETS lz4 + install(TARGETS ${LZ4_LIBRARIES_BUILT} LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(FILES -- cgit v0.12 From 1380c33b7349507e1d51b505a2f4ee8ab126c587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 2 Jan 2017 15:33:15 +0100 Subject: cmake: Install lz4cat and unlz4 symlinks --- contrib/cmake_unofficial/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt index df16d46..38f3b00 100644 --- a/contrib/cmake_unofficial/CMakeLists.txt +++ b/contrib/cmake_unofficial/CMakeLists.txt @@ -177,6 +177,18 @@ if(NOT LZ4_BUNDLED_MODE) DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + + # install lz4cat and unlz4 symlinks on *nix + if(UNIX) + install(CODE " + foreach(f lz4cat unlz4) + set(dest \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/\${f}\") + message(STATUS \"Symlinking: \${dest} -> lz4\") + execute_process( + COMMAND \"${CMAKE_COMMAND}\" -E create_symlink lz4 \"\${dest}\") + endforeach() + ") + endif(UNIX) endif(NOT LZ4_BUNDLED_MODE) # pkg-config -- cgit v0.12 From d7969e49af22943a3f0062b8fe8abc04bb1dd6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Mon, 2 Jan 2017 15:57:49 +0100 Subject: cmake: Install manpages --- contrib/cmake_unofficial/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/cmake_unofficial/CMakeLists.txt b/contrib/cmake_unofficial/CMakeLists.txt index 38f3b00..9a0983d 100644 --- a/contrib/cmake_unofficial/CMakeLists.txt +++ b/contrib/cmake_unofficial/CMakeLists.txt @@ -175,6 +175,8 @@ if(NOT LZ4_BUNDLED_MODE) "${LZ4_LIB_SOURCE_DIR}/lz4frame.h" "${LZ4_LIB_SOURCE_DIR}/lz4hc.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install(FILES "${LZ4_PROG_SOURCE_DIR}/lz4.1" + DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") @@ -188,6 +190,13 @@ if(NOT LZ4_BUNDLED_MODE) COMMAND \"${CMAKE_COMMAND}\" -E create_symlink lz4 \"\${dest}\") endforeach() ") + + # create manpage aliases + foreach(f lz4cat unlz4) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${f}.1" ".so man1/lz4.1\n") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${f}.1" + DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") + endforeach() endif(UNIX) endif(NOT LZ4_BUNDLED_MODE) -- cgit v0.12 From 05e27ade68e8b0db8f0965d218199b024e6fb217 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 3 Jan 2017 03:59:27 +0100 Subject: updated NEWS --- NEWS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d149128..1d42954 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,11 @@ v1.7.5 -lz4hc : new high compression mode : levels 10-12 compress more and slower, by @inikep. +lz4hc : new high compression mode : levels 10-12 compress more and slower, by Przemyslaw Skibinski lz4cat : fix : works with relative path (#284) and stdin (#285) (reported by @beiDei8z) cli : fix minor notification when using -r recursive mode API : lz4frame : LZ4F_frameBound(0) gives upper bound of *flush() and *End() operations (#290, #280) doc : markdown version of man page, by Takayuki Matsuoka (#279) build : Makefile : fix make -jX lib+exe concurrency (#277) +build : cmake : improvements by Michał Górny (#296) v1.7.4.2 fix : Makefile : release build compatible with PIE and customized compilation directives provided through environment variables (#274, reported by Antoine Martin) -- cgit v0.12 From 9683a1ae874b2928490d675b66fb80e12c111990 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 5 Jan 2017 16:50:37 +0100 Subject: LZ4_MEMORY_USAGE can be modified from compilation command line --- NEWS | 3 +++ lib/lz4.h | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1d42954..8075947 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +v1.7.6 +build : LZ4_MEMORY_USAGE can be modified at compile time, through external define + v1.7.5 lz4hc : new high compression mode : levels 10-12 compress more and slower, by Przemyslaw Skibinski lz4cat : fix : works with relative path (#284) and stdin (#285) (reported by @beiDei8z) diff --git a/lib/lz4.h b/lib/lz4.h index 0aae19c..3dc115b 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -108,8 +108,9 @@ LZ4LIB_API const char* LZ4_versionString (void); * Reduced memory usage can improve speed, due to cache effect * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */ -#define LZ4_MEMORY_USAGE 14 - +#ifndef LZ4_MEMORY_USAGE +# define LZ4_MEMORY_USAGE 14 +#endif /*-************************************ * Simple Functions -- cgit v0.12 From 44f95e92ea74d4ee9d56d9d1c524c0a0c9b904d5 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 13 Jan 2017 00:36:24 +0800 Subject: Fix printf specifier --- programs/lz4cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/lz4cli.c b/programs/lz4cli.c index cf91a99..0578bde 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -510,7 +510,7 @@ int main(int argc, const char** argv) #ifdef _FILE_OFFSET_BITS DISPLAYLEVEL(4, "_FILE_OFFSET_BITS defined: %ldL\n", (long) _FILE_OFFSET_BITS); #endif - if ((mode == om_compress) || (mode == om_bench)) DISPLAYLEVEL(4, "Blocks size : %i KB\n", (U32)(blockSize>>10)); + if ((mode == om_compress) || (mode == om_bench)) DISPLAYLEVEL(4, "Blocks size : %u KB\n", (U32)(blockSize>>10)); if (multiple_inputs) { input_filename = inFileNames[0]; -- cgit v0.12 From db6f733ecc99f5bd08e9e2b1348387d7144d0424 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 13 Jan 2017 00:43:25 +0800 Subject: Use logical or instead of bitwise or --- programs/bench.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/bench.c b/programs/bench.c index 8311503..8625802 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -231,7 +231,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, UTIL_getTime(&coolTime); DISPLAYLEVEL(2, "\r%79s\r", ""); - while (!cCompleted | !dCompleted) { + while (!cCompleted || !dCompleted) { UTIL_time_t clockStart; U64 clockLoop = g_nbSeconds ? TIMELOOP_MICROSEC : 1; -- cgit v0.12