1
0
mirror of https://git.tukaani.org/xz.git synced 2026-02-25 21:38:06 +00:00

CMake: Guard script configure_file() calls with ENABLE_SCRIPTS

The configure_file() calls for xzdiff, xzgrep, xzmore, and xzless
were running unconditionally within the if(UNIX) block, even when
ENABLE_SCRIPTS was OFF. This would cause a build failure if the
src/scripts/*.in files were not present. Deleting those files can
simplify license compliance when the scripts aren't needed.

Move the foreach loop and related code inside if(ENABLE_SCRIPTS) guard
so that configure_file() is only called when scripts are actually needed.
This is mostly whitespace changes to adjust the indentation.

Co-authored-by: Lasse Collin <lasse.collin@tukaani.org>
Closes: https://github.com/tukaani-project/xz/pull/210
This commit is contained in:
Radek Zikmund 2026-02-23 17:50:00 +01:00 committed by Lasse Collin
parent 1007bf08b5
commit b51d67f4a9
No known key found for this signature in database
GPG Key ID: 38EE757D69184620

View File

@ -2380,9 +2380,10 @@ xzdiff, xzgrep, xzmore, xzless, and their symlinks" ON)
set(XZ_POSIX_SHELL "${POSIX_SHELL_DEFAULT}" CACHE STRING set(XZ_POSIX_SHELL "${POSIX_SHELL_DEFAULT}" CACHE STRING
"Shell to use for scripts (xzgrep and others)") "Shell to use for scripts (xzgrep and others)")
# Guess the extra path to add from XZ_POSIX_SHELL. Autotools-based build if(ENABLE_SCRIPTS)
# has a separate option --enable-path-for-scripts=PREFIX but this is # Guess the extra path to add from XZ_POSIX_SHELL. Autotools-based
# enough for Solaris. # build has a separate option --enable-path-for-scripts=PREFIX but
# this is enough for Solaris.
set(enable_path_for_scripts) set(enable_path_for_scripts)
get_filename_component(POSIX_SHELL_DIR "${XZ_POSIX_SHELL}" DIRECTORY) get_filename_component(POSIX_SHELL_DIR "${XZ_POSIX_SHELL}" DIRECTORY)
@ -2413,18 +2414,15 @@ xzdiff, xzgrep, xzmore, xzless, and their symlinks" ON)
GROUP_READ GROUP_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE) WORLD_READ WORLD_EXECUTE)
if(ENABLE_SCRIPTS)
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${S}" install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${S}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT scripts_Runtime) COMPONENT scripts_Runtime)
endif()
endforeach() endforeach()
unset(xz) unset(xz)
unset(POSIX_SHELL) unset(POSIX_SHELL)
unset(enable_path_for_scripts) unset(enable_path_for_scripts)
if(ENABLE_SCRIPTS)
my_install_symlinks(scripts_Runtime "${CMAKE_INSTALL_BINDIR}" my_install_symlinks(scripts_Runtime "${CMAKE_INSTALL_BINDIR}"
xzdiff "" "${XZDIFF_LINKS}") xzdiff "" "${XZDIFF_LINKS}")