CMake: Use the same option list for XZ_SANDBOX as in configure.ac

It's simpler to document this way.
This commit is contained in:
Lasse Collin 2024-06-15 18:07:04 +03:00
parent c715dec8e8
commit 37f7af3452
1 changed files with 10 additions and 10 deletions

View File

@ -1038,14 +1038,14 @@ endif()
# Sandboxing # # Sandboxing #
############## ##############
# ON Use sandboxing if a supported method is available in the OS. # auto Use sandboxing if a supported method is available in the OS.
# OFF Disable sandboxing. # no Disable sandboxing.
# capsicum Require Capsicum (FreeBSD >= 10.2) and fail if not found. # capsicum Require Capsicum (FreeBSD >= 10.2) and fail if not found.
# pledge Require pledge(2) (OpenBSD >= 5.9) and fail if not found. # pledge Require pledge(2) (OpenBSD >= 5.9) and fail if not found.
# landlock Require Landlock (Linux >= 5.13) and fail if not found. # landlock Require Landlock (Linux >= 5.13) and fail if not found.
set(SUPPORTED_SANDBOX_METHODS ON OFF capsicum pledge landlock) set(SUPPORTED_SANDBOX_METHODS auto no capsicum pledge landlock)
set(XZ_SANDBOX ON CACHE STRING set(XZ_SANDBOX auto CACHE STRING
"Sandboxing method to use in 'xz', 'xzdec', and 'lzmadec'") "Sandboxing method to use in 'xz', 'xzdec', and 'lzmadec'")
set_property(CACHE XZ_SANDBOX PROPERTY STRINGS "${SUPPORTED_SANDBOX_METHODS}") set_property(CACHE XZ_SANDBOX PROPERTY STRINGS "${SUPPORTED_SANDBOX_METHODS}")
@ -1057,7 +1057,7 @@ endif()
# When autodetecting, the search order is fixed and we must not find # When autodetecting, the search order is fixed and we must not find
# more than one method. # more than one method.
if(XZ_SANDBOX STREQUAL "OFF") if(XZ_SANDBOX STREQUAL "no")
set(SANDBOX_FOUND ON) set(SANDBOX_FOUND ON)
else() else()
set(SANDBOX_FOUND OFF) set(SANDBOX_FOUND OFF)
@ -1068,7 +1068,7 @@ endif()
set(SANDBOX_COMPILE_DEFINITION OFF) set(SANDBOX_COMPILE_DEFINITION OFF)
# Sandboxing: Capsicum # Sandboxing: Capsicum
if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^capsicum$") if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^auto$|^capsicum$")
check_symbol_exists(cap_rights_limit sys/capsicum.h check_symbol_exists(cap_rights_limit sys/capsicum.h
HAVE_CAP_RIGHTS_LIMIT) HAVE_CAP_RIGHTS_LIMIT)
if(HAVE_CAP_RIGHTS_LIMIT) if(HAVE_CAP_RIGHTS_LIMIT)
@ -1078,7 +1078,7 @@ if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^capsicum$")
endif() endif()
# Sandboxing: pledge(2) # Sandboxing: pledge(2)
if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^pledge$") if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^auto$|^pledge$")
check_symbol_exists(pledge unistd.h HAVE_PLEDGE) check_symbol_exists(pledge unistd.h HAVE_PLEDGE)
if(HAVE_PLEDGE) if(HAVE_PLEDGE)
set(SANDBOX_COMPILE_DEFINITION "HAVE_PLEDGE") set(SANDBOX_COMPILE_DEFINITION "HAVE_PLEDGE")
@ -1087,7 +1087,7 @@ if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^pledge$")
endif() endif()
# Sandboxing: Landlock # Sandboxing: Landlock
if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^landlock$") if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^auto$|^landlock$")
# A compile check is done here because some systems have # A compile check is done here because some systems have
# linux/landlock.h, but do not have the syscalls defined # linux/landlock.h, but do not have the syscalls defined
# in order to actually use Linux Landlock. # in order to actually use Linux Landlock.
@ -1129,13 +1129,13 @@ if(NOT SANDBOX_FOUND AND XZ_SANDBOX MATCHES "^ON$|^landlock$")
message(SEND_ERROR message(SEND_ERROR
"CMAKE_C_FLAGS or the environment variable CFLAGS " "CMAKE_C_FLAGS or the environment variable CFLAGS "
"contains '-fsanitize=' which is incompatible " "contains '-fsanitize=' which is incompatible "
"with Landlock sandboxing. Use -DXZ_SANDBOX=OFF " "with Landlock sandboxing. Use -DXZ_SANDBOX=no "
"as an argument to 'cmake' when using '-fsanitize'.") "as an argument to 'cmake' when using '-fsanitize'.")
endif() endif()
endif() endif()
endif() endif()
if(NOT SANDBOX_FOUND AND NOT XZ_SANDBOX MATCHES "^ON$|^OFF$") if(NOT SANDBOX_FOUND AND NOT XZ_SANDBOX MATCHES "^auto$|^no$")
message(SEND_ERROR "XZ_SANDBOX=${XZ_SANDBOX} was used but " message(SEND_ERROR "XZ_SANDBOX=${XZ_SANDBOX} was used but "
"support for the sandboxing method wasn't found.") "support for the sandboxing method wasn't found.")
endif() endif()