summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-08-31 16:42:04 +0300
committerLasse Collin <lasse.collin@tukaani.org>2022-08-31 16:42:04 +0300
commit80a1a8bb838842a2be343bd88ad1462c21c5e2c9 (patch)
tree30aaebf680ef4ac121f8a7e38d736581f3522034 /CMakeLists.txt
parenta4193bb6d85d7765b1b87faeab3e50106d3ab2e9 (diff)
downloadxz-80a1a8bb838842a2be343bd88ad1462c21c5e2c9.tar.gz
CMake: Add xz symlinks.
These are a minor thing especially since the xz build has some real problems still like lack of large file support on 32-bit systems but I'll commit this since the code exists. Thanks to Jia Tan.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt38
1 files changed, 37 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f4a1b9..14b5adc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,6 @@
# - No replacement getopt_long(), libc must have it
# - No sandboxing support
# - No translations
-# - No xz symlinks are installed
#
# Other missing things:
# - No xzgrep or other scripts or their symlinks
@@ -685,6 +684,43 @@ if(NOT MSVC AND HAVE_GETOPT_LONG)
install(FILES src/xz/xz.1
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
COMPONENT xz)
+
+ option(CREATE_XZ_SYMLINKS "Create unxz and xzcat symlinks" ON)
+ option(CREATE_LZMA_SYMLINKS "Create lzma, unlzma, and lzcat symlinks"
+ ON)
+ set(XZ_LINKS)
+
+ if(CREATE_XZ_SYMLINKS)
+ list(APPEND XZ_LINKS "unxz" "xzcat")
+ endif()
+
+ if(CREATE_LZMA_SYMLINKS)
+ list(APPEND XZ_LINKS "lzma" "unlzma" "lzcat")
+ endif()
+
+ # Create symlinks in the build directory and then install them.
+ #
+ # FIXME? On OSes where executables have a suffix like .exe, this
+ # will create links like unxz -> xz.exe which is correct on Cygwin
+ # but perhaps on some other cases unxz.suffix -> xz.suffix would
+ # be the corrent thing?
+ foreach(LINK IN LISTS XZ_LINKS)
+ add_custom_target("${LINK}" ALL
+ "${CMAKE_COMMAND}" -E create_symlink
+ "$<TARGET_FILE_NAME:xz>" "${LINK}"
+ BYPRODUCTS "${LINK}"
+ VERBATIM)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LINK}"
+ DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ COMPONENT xz)
+ add_custom_target("${LINK}.1" ALL
+ "${CMAKE_COMMAND}" -E create_symlink "xz.1" "${LINK}.1"
+ BYPRODUCTS "${LINK}.1"
+ VERBATIM)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LINK}.1"
+ DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
+ COMPONENT xz)
+ endforeach()
endif()
endif()