xo-cmake: add --dry-run option to generated reconfigure script

This commit is contained in:
Roland Conybeare 2026-01-11 15:12:22 -05:00
commit d028a21547
2 changed files with 54 additions and 10 deletions

View file

@ -292,7 +292,7 @@ function(xo_generate_reconfigure_script)
return()
endif()
set(_reconfigure_script "${CMAKE_BINARY_DIR}/xo-reconfigure")
set(_reconfigure_script "${CMAKE_BINARY_DIR}/reconfigure")
configure_file(${_reconfigure_template} ${_reconfigure_script} @ONLY)
file(CHMOD ${_reconfigure_script} PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE

View file

@ -1,11 +1,55 @@
#!/bin/bash
# Generated by cmake - rerun to reconfigure
cmake \
-B @CMAKE_BINARY_DIR@ \
-S @CMAKE_SOURCE_DIR@ \
-DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@ \
-DCMAKE_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ \
-DXO_ENABLE_DOCS=@XO_ENABLE_DOCS@ \
-DXO_ENABLE_EXAMPLES=@XO_ENABLE_EXAMPLES@ \
-DXO_ENABLE_ASM=@XO_ENABLE_ASM@ \
"$@"
dry_run_flag=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-n|--dry-run)
dry_run_flag=true
;;
--)
break;
;;
*)
echo "error: xo-reconfigure: unexpected argument [$1]"
echo "usage: xo-reconfigure"
echo " xo-reconfigure [-n] -- CMAKE_ARGS"
exit 1
esac
shift
done
# Build the cmake command
CMAKE_CMD=(
cmake
-B @CMAKE_BINARY_DIR@
-S @CMAKE_SOURCE_DIR@
-DCMAKE_BUILD_TYPE=@CMAKE_BUILD_TYPE@
-DCMAKE_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@
-DCMAKE_INSTALL_DOCDIR=@CMAKE_INSTALL_DOCDIR@
-DCMAKE_MODULE_PATH=@CMAKE_MODULE_PATH@
-DCMAKE_PREFIX_PATH=@CMAKE_PREFIX_PATH@
-DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@
-DXO_CMAKE_CONFIG_EXECUTABLE=@XO_CMAKE_CONFIG_EXECUTABLE@
-DENABLE_TESTING=@ENABLE_TESTING@
-DXO_ENABLE_DOCS=@XO_ENABLE_DOCS@
-DXO_ENABLE_ASM=@XO_ENABLE_ASM@
-DXO_ENABLE_EXAMPLES=@XO_ENABLE_EXAMPLES@
-DXO_ENABLE_VULKAN=@XO_ENABLE_VULKAN@
-DXO_ENABLE_OPENGL=@XO_ENABLE_OPENGL@
"${@}"
)
if [[ ${dry_run_flag} = true ]]; then
# Print the command with proper quoting for copy-paste
printf '%q ' "${CMAKE_CMD[@]}" | sed -e 's: -D: \\\n -D:g'
printf '\n'
else
# Execute the command
"${CMAKE_CMD[@]}"
fi