diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index bc60d00d86d764f83247fd5e5f586e94d1f6a577..8b5e2257d9789f8c01057a57a4c3e719aa12efb4 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -99,6 +99,7 @@ ROOT_BUILD_OPTION(cefweb OFF "Chromium Embedded Framework web-based display") ROOT_BUILD_OPTION(chirp OFF "Chirp support (Condor remote I/O), requires libchirp_client") ROOT_BUILD_OPTION(cling ON "Enable new CLING C++ interpreter") ROOT_BUILD_OPTION(cocoa OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)") +set(compression_default "lz4" CACHE STRING "ROOT compression algorithm used as a default, default option is lz4. Can be lz4, zlib, or lzma") ROOT_BUILD_OPTION(cuda OFF "Use CUDA if it is found in the system") ROOT_BUILD_OPTION(cxx11 ON "Build using C++11 compatible mode, requires gcc > 4.7.x or clang") ROOT_BUILD_OPTION(cxx14 OFF "Build using C++14 compatible mode, requires gcc > 4.9.x or clang") @@ -128,7 +129,6 @@ ROOT_BUILD_OPTION(jemalloc OFF "Using the jemalloc allocator") ROOT_BUILD_OPTION(krb5 OFF "Kerberos5 support, requires Kerberos libs") ROOT_BUILD_OPTION(ldap OFF "LDAP support, requires (Open)LDAP libs") ROOT_BUILD_OPTION(libcxx OFF "Build using libc++, requires cxx11 option (MacOS X only, for the time being)") -ROOT_BUILD_OPTION(lz4 ON "LZ4 compression algorithm as a default, requires liblz4") ROOT_BUILD_OPTION(macos_native OFF "Disable looking for libraries, includes and binaries in locations other than a native installation (MacOS only)") ROOT_BUILD_OPTION(mathmore ON "Build the new libMathMore extended math library, requires GSL (vers. >= 1.8)") ROOT_BUILD_OPTION(memory_termination OFF "Free internal ROOT memory before process termination (experimental, used for leak checking)") @@ -187,6 +187,15 @@ option(roottest "Include roottest, if roottest exists in root or if it is a sibl option(rootbench "Include rootbench, if rootbench exists in root or if it is a sibling directory." OFF) option(clingtest "Include cling tests. NOTE that this makes llvm/clang symbols visible in libCling." OFF) +#--- Compression algorithms in ROOT------------------------------------------------------------- +if(NOT compression_default MATCHES "zlib|lz4|lzma") + message(STATUS "Not supported compression algorithm, ROOT compression algorithms are zlib, lzma and lz4. + ROOT will fall back to default algorithm setting: lz4") + set(compression_default "lz4" CACHE STRING) +else() + message(STATUS "ROOT default compression algorithm is " ${compression_default}) +endif() + #--- Minor chnages in defaults due to platform-------------------------------------------------- if(WIN32) set(x11_defvalue OFF) diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 6195af959d647c8d78d242b5913e05180de490aa..6dfa6985b18493f2da6b1469214243c952acc279 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -495,6 +495,19 @@ if(cxx17) else() set(usec++17 undef) endif() +if(compression_default STREQUAL "lz4") + set(uselz4 define) + set(usezlib undef) + set(uselzma undef) +elseif(compression_default STREQUAL "zlib") + set(uselz4 undef) + set(usezlib define) + set(uselzma undef) +elseif(compression_default STREQUAL "lzma") + set(uselz4 undef) + set(usezlib undef) + set(uselzma define) +endif() if(runtime_cxxmodules) set(usecxxmodules define) else() diff --git a/config/RConfigure.in b/config/RConfigure.in index 859c7913826271e8c977151190a7c20c31f5e20e..ad8934e61646db7597f34078a8b7aaa8f4ad0c55 100644 --- a/config/RConfigure.in +++ b/config/RConfigure.in @@ -49,6 +49,9 @@ #endif #endif -#@haslz4compression@ R__HAS_LZ4 /**/ +#@uselz4@ R__HAS_DEFAULT_LZ4 /**/ +#@usezlib@ R__HAS_DEFAULT_ZLIB /**/ +#@uselzma@ R__HAS_DEFAULT_LZMA /**/ -#endif + +#endif \ No newline at end of file diff --git a/core/zip/src/RZip.cxx b/core/zip/src/RZip.cxx index 23b3d0fc153af3d06dfbe1f9a8125b2e91695813..d66d1723ab5e9ee6e1be414738dc2b7827ecceac 100644 --- a/core/zip/src/RZip.cxx +++ b/core/zip/src/RZip.cxx @@ -47,7 +47,7 @@ static void R__unzipZLIB(int *srcsize, unsigned char *src, int *tgtsize, unsigne is done. LZ4 typically has the worst compression ratios, but much faster decompression speeds - sometimes by an order of magnitude. */ -#ifdef R__HAS_LZ4 +#ifdef R__HAS_DEFAULT_LZ4 enum ROOT::ECompressionAlgorithm R__ZipMode = ROOT::ECompressionAlgorithm::kLZ4; #else enum ROOT::ECompressionAlgorithm R__ZipMode = ROOT::ECompressionAlgorithm::kZLIB; diff --git a/test/MainEvent.cxx b/test/MainEvent.cxx index 77cfec6dd62f3884728750ceac43e1fccb05a027..7e3fc8f94d1a41db400c91f66d87a068f2047aaf 100644 --- a/test/MainEvent.cxx +++ b/test/MainEvent.cxx @@ -121,7 +121,7 @@ int main(int argc, char **argv) Int_t arg4 = 1; Int_t arg5 = 600; //default number of tracks per event Int_t enable_imt = 0; // Whether to enable IMT mode. -#ifdef R__HAS_LZ4 +#ifdef R__HAS_DEFAULT_LZ4 Int_t compAlg = 4; // Allow user to specify underlying compression algorithm. #else Int_t compAlg = 1; diff --git a/test/stress.cxx b/test/stress.cxx index 7df763321b120ca7998ff2acbe60149868439de6..9e5d317e7e74402e654b1f607dd6bb17c9722dec 100644 --- a/test/stress.cxx +++ b/test/stress.cxx @@ -356,7 +356,7 @@ void stress2() //Long64_t lastgood = 12383; //9428; //Long64_t lastgood = 9789; // changes for new TFormula //Long64_t lastgood = 9797; // changes for TH1 v8 ROOT-9173 on 32-bits -#ifdef R__HAS_LZ4 +#ifdef R__HAS_DEFAULT_LZ4 Long64_t lastgood = 11579; if (last < lastgood - 200 || last > lastgood + 200 || comp < 1.5 || comp > 2.1) OK = kFALSE; @@ -396,7 +396,7 @@ void stress3() Bool_t OK = kTRUE; constexpr Long64_t lastgood = 51886; constexpr Long64_t tolerance = 100; -#ifdef R__HAS_LZ4 +#ifdef R__HAS_DEFAULT_LZ4 constexpr Long64_t difflastgoodlz4 = 5500; if (last < lastgood - tolerance || last > lastgood + difflastgoodlz4 + tolerance || comp < 1.5 || comp > 2.1) OK = kFALSE; @@ -407,7 +407,7 @@ void stress3() if (OK) printf("OK\n"); else { printf("FAILED\n"); -#ifdef R__HAS_LZ4 +#ifdef R__HAS_DEFAULT_LZ4 printf("%-8s LZ4 file size= %lld (expected %lld +/- %lld)\n" "%-8s Comp Fact= %3.2f (expected 1.8 +/- 0.3)\n", " ", last, lastgood + difflastgoodlz4, tolerance, " ", comp);