Commit Graph

186 Commits

Author SHA1 Message Date
Lasse Collin a3d6eb797c CMake: Add autodetection for 32-bit x86 CRC assembly usage 2024-06-24 18:15:58 +03:00
Lasse Collin dbc14f213e CMake: Move option(XZ_ASM_I386) downwards a few lines 2024-06-23 23:09:14 +03:00
Lasse Collin 85b081f5d4 liblzma: Make 32-bit x86 CRC assembly co-exist with CLMUL
Now runtime detection of CLMUL support can pick between the CLMUL and
the generic assembly implementations. Whatever overhead this has for
builds that omit CLMUL completely isn't important because builds for
any non-ancient system is likely to include the CLMUL code too.

Handle the CRC tables in crcXX_fast.c files because now these files
are built even when assembly code is used.

If 32-bit x86 assembly is enabled then it will always be built even
if compiler flags were such that CLMUL would be allowed unconditionally.
That is, runtime detection will be used anyway. This keeps the build
rules simpler.

In LZ encoder, build and use lzma_lz_hash_table[256] if CLMUL CRC
is used without runtime detection. Previously this wasn't needed
because crc32_table.c included the lzma_crc32_table[][] in the build
unless encoder support had been disabled. Including an 8 KiB table
was silly when only 1 KiB is actually used. So now liblzma is 7 KiB
smaller if CLMUL is enabled without runtime detection.
2024-06-23 14:36:44 +03:00
Lasse Collin 1dca581ff2 CMake: Define HAVE_CRC_X86_ASM when 32-bit x86 CRC assembly is used 2024-06-23 14:36:44 +03:00
Lasse Collin 0232e66d5b CMake: Add XZ_EXTERNAL_SHA256 2024-06-20 21:53:07 +03:00
Lasse Collin 4535b80cae CMake: Move threading detection a few lines up
It feels clearer this way, and when support for external SHA-256
is added, this will keep the order of the library detection the
same as in configure.ac (check for pthreads before libmd) although
it shouldn't matter in practice.
2024-06-20 21:53:07 +03:00
Lasse Collin 94d062dbac CMake: Move the sandbox code out of the liblzma section
Sandboxing is for the command line tools, not liblzma.
No functional changes.
2024-06-20 21:53:07 +03:00
Lasse Collin 75ce4797d4 CMake: Keep existing options in LIBS when adding -lrt
This makes no difference yet because -lrt is currently the only option
that might be added to LIBS.
2024-06-20 21:53:07 +03:00
Lasse Collin 47aaa92516 CMake: Don't install scripts if the xz tool isn't built
The scripts need the xz tool.
2024-06-20 21:53:07 +03:00
Lasse Collin fb50c6ba1d CMake: Add XZ_TOOL_XZDEC and XZ_TOOL_LZMADEC 2024-06-20 21:53:07 +03:00
Lasse Collin def767f7d1 CMake: Add XZ_TOOL_LZMAINFO 2024-06-20 21:53:07 +03:00
Lasse Collin 5600e370fb CMake: Add XZ_TOOL_XZ 2024-06-20 21:53:07 +03:00
Lasse Collin 6a3c4aaa43 Windows: Drop Visual Studio 2013 support
This simplifies things a little. Building liblzma with VS2013 probably
still worked but building the command line tools was not supported.

Microsoft ended support for VS2013 on 2024-04.
2024-06-20 21:53:07 +03:00
Lasse Collin 5d5c92b262 CMake: Add XZ_TOOL_SCRIPTS 2024-06-20 21:53:07 +03:00
Lasse Collin d274a2bc00 CMake: Add XZ_DOC 2024-06-20 21:53:07 +03:00
Lasse Collin 188143a50a CMake: Refactor XZ_SYMBOL_VERSIONING to match configure.ac
Make the available options and their behavior match
--enable-symbol-versions in configure.ac.

Don't enable symbol versions on Linux if not using glibc. Previously
the generic variant was selected on Microblaze or if using NVHPC
without checking that libc is glibc.

Leave the cache variable to "auto" or "yes" if that was specified
instead of setting it to the autodetected value by default. A downside
is that one cannot easily see which variant the autodetection code
has selected. The same applies to XZ_SANDBOX and XZ_THREADS though.
2024-06-20 21:53:03 +03:00
Lasse Collin cc52ef8ed3 CMake: Use the same option list for XZ_THREADS as in configure.ac
Also clarify that "yes" will fail if no threading support is found.
If no threading is wanted, it has to be disabled manually.

configure.ac doesn't behave this way at the moment. Instead it
assumes pthreads to be present if not targeting Windows. If pthreads
actually are missing, the build fails later.
2024-06-20 15:12:19 +03:00
Lasse Collin 37f7af3452 CMake: Use the same option list for XZ_SANDBOX as in configure.ac
It's simpler to document this way.
2024-06-20 15:00:05 +03:00
Lasse Collin c715dec8e8 CMake: Fix indentation 2024-06-20 15:00:05 +03:00
Lasse Collin ea379f2f18 CMake: Add warning options for GCC and Clang
The list was copied from configure.ac and should be kept in sync.
(Pretend that the deleted comment in CMakeLists.txt didn't exist.)

There is no need to add equivalent of --enable-werror as CMake >= 3.24
supports -DCMAKE_COMPILE_WARNING_AS_ERROR=ON.
2024-06-20 15:00:05 +03:00
Lasse Collin 7422333819 CMake: Use \040 instead of \x20 for a space
This is for consistency with 4c81c9611f
where \040 has to be used because \0x20F gets interpret at three hex
digits. Octals escapes are never longer than three digits.
2024-06-20 15:00:05 +03:00
Lasse Collin e8854b6bdc CMake: Add XZ_ASSUME_RAM 2024-06-20 15:00:05 +03:00
Lasse Collin e1127e75cb CMake: Rename liblzma_INSTALL_CMAKEDIR to XZ_INSTALL_CMAKEDIR 2024-06-20 15:00:05 +03:00
Lasse Collin 96abfe98c1 CMake: Refactor ADDITIONAL_CHECK_TYPES to XZ_CHECKS
Now "crc32" is in the list too for completeness but it doesn't
actually have any effect. The description of the cache variable
says that "crc32 is always built" so it should be clear enough.
2024-06-20 15:00:05 +03:00
Lasse Collin 679500ffe0 CMake: Rename the cache variable POSIX_SHELL to XZ_POSIX_SHELL
We still need the variable POSIX_SHELL for configure_file()
but it doesn't need to be a cache variable.
2024-06-20 15:00:05 +03:00
Lasse Collin e5c0eb2e50 CMake: Rename ENCODERS and DECODERS to use XZ_ prefix 2024-06-20 15:00:05 +03:00
Lasse Collin e7785e2061 CMake: Rename MATCH_FINDERS to XZ_MATCH_FINDERS 2024-06-20 15:00:05 +03:00
Lasse Collin 63294806b4 CMake: Rename SYMBOL_VERSIONING to XZ_SYMBOL_VERSIONING 2024-06-20 15:00:05 +03:00
Lasse Collin ad245b1336 CMake: Rename ENABLE_THREADS to XZ_THREADS 2024-06-20 15:00:05 +03:00
Lasse Collin 4250d4de32 CMake: Rename ENABLE_SANDBOX to XZ_SANDBOX 2024-06-20 15:00:05 +03:00
Lasse Collin 0fdcd0c582 CMake: Rename ENABLE_X86_ASM to XZ_ASM_I386 2024-06-20 15:00:05 +03:00
Lasse Collin e017d5526e CMake: Rename CREATE_XZ_SYMLINKS to XZ_TOOL_SYMLINKS
This only affects the names unxz and xzcat. The xz-prefixed script
symlinks (xzfgrep and such) are always created if scripts are enabled.
2024-06-20 15:00:05 +03:00
Lasse Collin 04cac14fcb CMake: Rename CREATE_LZMA_SYMLINKS to XZ_TOOL_LZMA_SYMLINKS
Update the description too.

It affects creation of not only the legacy lzma, unlzma, lzcat symlinks
but also lzgrep and other legacy names for the scripts. The last
LZMA Utils release was made in 2008 but these names are still used
in some places to handle .lzma files.
2024-06-20 15:00:05 +03:00
Lasse Collin 612ccebf88 CMake: Rename ALLOW_ARM64_CRC32 to XZ_ARM64_CRC32
Update description too.
2024-06-20 15:00:05 +03:00
Lasse Collin 3dcc12290d CMake: Rename ALLOW_CLMUL_CRC to XZ_CLMUL_CRC
Update description too.
2024-06-20 15:00:05 +03:00
Lasse Collin 4b8faa7244 CMake: Rename ENABLE_DOXYGEN to XZ_DOXYGEN 2024-06-20 15:00:05 +03:00
Lasse Collin b56273ae57 CMake: Rename LZIP_DECODER to XZ_LZIP_DECODER 2024-06-20 15:00:05 +03:00
Lasse Collin 2343992fcb CMake: Rename MICROLZMA_ENCODER/DECODER to XZ_MICROLZMA_ENCODER/DECODER 2024-06-20 15:00:05 +03:00
Lasse Collin 96f0a6632c CMake: Rename ENABLE_SMALL to XZ_SMALL 2024-06-20 15:00:05 +03:00
Lasse Collin 29f77c7b70 CMake: Rename ENABLE_NLS to XZ_NLS
Also update the description to mention that this affects installation
of translated man pages too.

Prefixing the cache variables with the project name helps if
the package is used as a subproject in another package.
It also makes the package-specific options group more nicely
in ccmake and cmake-gui.
2024-06-20 14:59:33 +03:00
Lasse Collin ac05f1b0d7 CMake: Link Threads::Threads as PRIVATE to liblzma
This way pthread options aren't passed to the linker when linking
against shared liblzma but they are still passed when linking against
static liblzma. (Also, one never needs the include path of the
threading library to use liblzma since liblzma's API headers
don't #include <pthread.h>. But <pthread.h> tends to be in the
default include path so here this change makes no difference.)

One cannot mix target_link_libraries() calls that use the scope
(PRIVATE, PUBLIC, or INTERFACE) keyword and calls that don't use it.
The calls without the keyword are like PUBLIC except perhaps when
they aren't, or something like that... It seems best to always
specify a scope keyword as the meanings of those three keywords
at least are clear.
2024-06-17 18:20:21 +03:00
Lasse Collin 82986d8c69 CMake: Add empty lines 2024-06-17 18:20:21 +03:00
Lasse Collin 2aecffe0f0 CMake: Use CMAKE_THREAD_LIBS_INIT in liblzma.pc only with pthreads
This shouldn't make much difference in practice as on Windows
no flags are needed anyway and unitialized variable (when threading
is disabled) expands to empty. But it's clearer this way.
2024-06-17 18:20:21 +03:00
Lasse Collin 5ca96a9348 CMake: Use native newlines in liblzma.pc
vcpkg doesn't specify the newline type so it should be fine to
use native newlines in liblzma.pc on Windows.
2024-06-17 18:01:39 +03:00
Lasse Collin ebd155c3a1 CMake: Use relative paths in liblzma.pc if possible
Now liblzma.pc can be relocatable only if using CMake >= 3.20
but that should be OK as now we shouldn't get broken liblzma.pc
if CMAKE_INSTALL_LIBDIR or CMAKE_INSTALL_INCLUDEDIR contain an
absolute path.

Thanks to Eli Schwartz.
2024-06-17 18:01:39 +03:00
Lasse Collin 7a366d93cf Revert "CMake: Set only "prefix" as an absolute path in liblzma.pc"
This reverts commit 5d1c649ba9.

While CMAKE_INSTALL_<dir> tend to be relative paths, they don't need
to be. Thus the commit was broken. A fancier method is required.

Thanks to Eli Schwartz for the bug report and explanation.
2024-06-17 18:01:39 +03:00
Lasse Collin 2178acf8a4 CMake: Prefer C11 with a fallback to C99
There is no need to make a similar change in configure.ac.
With Autoconf 2.72, the deprecated macro AC_PROG_CC_C99
is an alias for AC_PROG_CC which prefers a C11 compiler.
2024-06-12 14:28:37 +03:00
Lasse Collin dc03f6290f liblzma: Add ARM64 CRC32 instruction support detection on OpenBSD
The C code is from Christian Weisgerber, I merely reordered the OSes.
Then I added the build system checks without testing them.

Also thanks to Brad Smith who submitted a similar patch on GitHub
a few hours after Christian had sent his via email.

Co-authored-by: Christian Weisgerber <naddy@mips.inka.de>
Closes: https://github.com/tukaani-project/xz/pull/125
2024-06-07 15:06:59 +03:00
Lasse Collin e5491dfab9 CMake: Include the "alpha" or "beta" suffix in PACKAGE_VERSION
This way the version string gets into xzgrep and other scripts
in full and also into liblzma.pc.

For the project() command, a suffixless string is required though.
2024-06-05 13:42:47 +03:00
Lasse Collin 1d3c61575f CMake: Fix wrong version variable
liblzma_VERSION has never existed in the repository. xz_VERSION from
the project() command was used for liblzma SOVERSION so use xz_VERSION
here too.

The wrong variable did no harm in practice as PROJECT_VERSION
was used as the fallback. It has the same value as xz_VERSION.

Fixes: 7e3493d40e
2024-06-05 13:30:28 +03:00