Commit Graph

168 Commits

Author SHA1 Message Date
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
Lasse Collin 5d1c649ba9 CMake: Set only "prefix" as an absolute path in liblzma.pc
CMake provides variables that are relative to CMAKE_INSTALL_PREFIX
so use them instead of repeating the full path.
2024-06-05 12:59:59 +03:00
Lasse Collin e0d6d05ce0 CMake: Fix liblzma filename in Windows environments
This is a mess because liblzma DLL outside Cygwin and MSYS2
is liblzma.dll instead of lzma.dll to avoid a conflict with
lzma.dll from LZMA SDK.

On Cygwin the name was "liblzma-5.dll" while "cyglzma-5.dll"
would have been correct (and match what Libtool produces).
MSYS2 likely was broken too as it uses the "msys-" prefix.

This change has no effect with MinGW-w64 because with that
the "lib" prefix was correct already.

With MSVC builds this is a small breaking change that requires developers
to adjust the library name when linking against liblzma. The liblzma.dll
name is kept as is but the import library and static library are now
lzma.lib instead of liblzma.lib. This is helpful when using pkgconf
because "pkgconf --msvc-syntax --libs liblzma" outputs "lzma.lib"
(it's converted from "-llzma" in liblzma.pc). It would be easy to
keep the liblzma.lib naming but the pkgconf compatibility seems worth
it in the long run. The lzma.lib name is compatible with MinGW-w64
too as -llzma will find also lzma.lib.

vcpkg had been patching CMakeLists.txt this way since 2022 but I
learned this only recently. The reasoning for the patch makes sense,
and while this is a small breaking change with MSVC, it seems like
a decent compromise as it keeps the DLL name the same.

2022 patch in vcpkg: 0707a17ecf/ports/liblzma/win_output_name.patch
See the discussion: https://github.com/microsoft/vcpkg/pull/39024

Thanks to Vincent Torri for confirming the naming issue on Cygwin.
2024-06-04 23:59:29 +03:00
Lasse Collin afa938e429 CMake: Install liblzma.pc even with MSVC
I had misunderstood that it wouldn't be useful with MSVC.
vcpkg had been installing liblzma.pc with custom rules since 2020,
years before liblzma.pc support was added to CMakeLists.txt.

See:
eb895b95aa/ports/liblzma/portfile.cmake
https://github.com/microsoft/vcpkg/pull/39024#issuecomment-2145064670
2024-06-03 17:44:50 +03:00
Lasse Collin 24387c234b CMake: Add manual support for 32-bit x86 assembly files
One has to pass -DENABLE_X86_ASM=ON to cmake to enable the
CRC assembly code. Autodetection isn't done. Looking at
CMAKE_SYSTEM_PROCESSOR might not work as it comes from uname
unless cross-compilation is done using a CMake toolchain file.

On top of this, if the code is run on modern processors that support
the CLMUL instruction, then the C code should be faster (but then
one should also be using a x86-64 build if possible).
2024-05-23 15:32:43 +03:00
Lasse Collin 0fb3c9c3f6 CMake: Rename USE_DOXYGEN to ENABLE_DOXYGEN
It's more consistent with the other option() uses.
2024-05-23 14:26:45 +03:00
Lasse Collin d35368b33e CMake: Remove the note that some tests aren't run
They are now in the common build configurations.
2024-05-20 16:55:00 +03:00
Lasse Collin 64503cc2b7 CMake: Support building liblzma API docs using Doxygen
This is disabled by default to match the default in Autotools.
Use -DUSE_DOXYGEN=ON to enable Doxygen usage.

This uses the update-doxygen script, thus this is under if(UNIX)
although Doxygen itself can run on Windows too.
2024-04-30 17:09:08 +03:00
Lasse Collin 0a7f5a80d8 CMake: List API headers in LIBLZMA_API_HEADERS variable
This way the same list will be usable in more than one location.
2024-04-30 17:09:08 +03:00
Lasse Collin aaff75c348 CMake: Keep the build working if the "tests" directory is missing
This moves the tests section as is from CMakeLists.txt into
tests/tests.cmake. CMakeLists.txt now includes tests/tests.cmake
if the latter file exists.

Now it's possible to delete the whole "tests" directory and
building with CMake will still work normally, just without
the tests. This way the tests are readily available for those
who want them, and those who won't run the tests anyway have
a straightforward way to ensure that nothing from the "tests"
directory can affect the build process.
2024-04-27 20:21:30 +03:00
Lasse Collin 0478473953 CMake: Bump maximum policy version to 3.29 2024-04-26 18:25:18 +03:00
Lasse Collin 689ae24273 liblzma: Remove ifunc support.
This is *NOT* done for security reasons even though the backdoor
relied on the ifunc code. Instead, the reason is that in this
project ifunc provides little benefits but it's quite a bit of
extra code to support it. The only case where ifunc *might* matter
for performance is if the CRC functions are used directly by an
application. In normal compression use it's completely irrelevant.
2024-04-09 18:22:27 +03:00
Lasse Collin 17aa2e1a79 Update website URLs back to tukaani.org.
The XZ projects were moved back to their original URLs.
2024-04-09 18:22:27 +03:00
Lasse Collin f9cf4c05ed CMake: Fix sabotaged Landlock sandbox check.
It never enabled it.
2024-03-30 14:36:28 +02:00
Lasse Collin c273123ed0 CMake: Use only the generic symbol versioning with NVIDIA HPC Compiler.
It doesn't support the __symver__ attribute or __asm__(".symver ...").
The generic symbol versioning can still be used since it only needs
linker support.
2024-03-15 18:04:10 +02:00
Lasse Collin 2ad7fad670 CMake: Disable symbol versioning on non-glibc Linux.
This better matches what configure.ac does. For example, musl has
only basic symbol versioning support:

https://wiki.musl-libc.org/functional-differences-from-glibc.html#Symbol_versioning

configure.ac tries to enable symbol versioning only with glibc
so now CMake does the same.
2024-03-15 17:30:50 +02:00
Lasse Collin 82f0c0d39e CMake: Make symbol versioning configurable. 2024-03-15 17:30:50 +02:00
Jia Tan b93a8d7631 Tests: Replace HAVE_MICROLZMA usage in CMake and Autotools builds.
This reverts commit adaacafde6.
2024-03-09 09:49:55 +08:00
Jia Tan e5faaebbcf Build: Require attribute no_profile_instrument_function for ifunc usage.
Using __attribute__((__no_profile_instrument_function__)) on the ifunc
resolver works around a bug in GCC -fprofile-generate:
it adds profiling code even to ifunc resolvers which can make
the ifunc resolver crash at program startup. This attribute
was not introduced until GCC 7 and Clang 13, so ifunc won't
be used with prior versions of these compilers.

This bug was brought to our attention by:

    https://bugs.gentoo.org/925415

And was reported to upstream GCC by:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11411
2024-03-05 01:54:30 +08:00