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:
parent
1007bf08b5
commit
b51d67f4a9
@ -2380,51 +2380,49 @@ 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
|
||||||
set(enable_path_for_scripts)
|
# this is enough for Solaris.
|
||||||
get_filename_component(POSIX_SHELL_DIR "${XZ_POSIX_SHELL}" DIRECTORY)
|
set(enable_path_for_scripts)
|
||||||
|
get_filename_component(POSIX_SHELL_DIR "${XZ_POSIX_SHELL}" DIRECTORY)
|
||||||
|
|
||||||
if(NOT POSIX_SHELL_DIR MATCHES "^/bin$|^/usr/bin$")
|
if(NOT POSIX_SHELL_DIR MATCHES "^/bin$|^/usr/bin$")
|
||||||
set(enable_path_for_scripts "PATH=${POSIX_SHELL_DIR}:\$PATH")
|
set(enable_path_for_scripts "PATH=${POSIX_SHELL_DIR}:\$PATH")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(XZDIFF_LINKS xzcmp)
|
set(XZDIFF_LINKS xzcmp)
|
||||||
set(XZGREP_LINKS xzegrep xzfgrep)
|
set(XZGREP_LINKS xzegrep xzfgrep)
|
||||||
set(XZMORE_LINKS)
|
set(XZMORE_LINKS)
|
||||||
set(XZLESS_LINKS)
|
set(XZLESS_LINKS)
|
||||||
|
|
||||||
if(XZ_TOOL_SYMLINKS_LZMA)
|
if(XZ_TOOL_SYMLINKS_LZMA)
|
||||||
list(APPEND XZDIFF_LINKS lzdiff lzcmp)
|
list(APPEND XZDIFF_LINKS lzdiff lzcmp)
|
||||||
list(APPEND XZGREP_LINKS lzgrep lzegrep lzfgrep)
|
list(APPEND XZGREP_LINKS lzgrep lzegrep lzfgrep)
|
||||||
list(APPEND XZMORE_LINKS lzmore)
|
list(APPEND XZMORE_LINKS lzmore)
|
||||||
list(APPEND XZLESS_LINKS lzless)
|
list(APPEND XZLESS_LINKS lzless)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(xz "xz")
|
set(xz "xz")
|
||||||
set(POSIX_SHELL "${XZ_POSIX_SHELL}")
|
set(POSIX_SHELL "${XZ_POSIX_SHELL}")
|
||||||
|
|
||||||
foreach(S xzdiff xzgrep xzmore xzless)
|
foreach(S xzdiff xzgrep xzmore xzless)
|
||||||
configure_file("src/scripts/${S}.in" "${S}"
|
configure_file("src/scripts/${S}.in" "${S}"
|
||||||
@ONLY
|
@ONLY
|
||||||
NEWLINE_STYLE LF
|
NEWLINE_STYLE LF
|
||||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||||
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}")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user