gnucash stable: Fix uninstall target for cmake > 3.25
John Ralls
jralls at code.gnucash.org
Tue Jan 28 13:46:07 EST 2025
Updated via https://github.com/Gnucash/gnucash/commit/19591988 (commit)
from https://github.com/Gnucash/gnucash/commit/57df6c2b (commit)
commit 19591988e2bc804251d2e553577ba2e5a5140971
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Jan 28 10:39:42 2025 -0800
Fix uninstall target for cmake > 3.25
execute_process and exce_program were changed in cmake 3.26 to run
only at configure time, breaking cmake_uninstall.cmake. The recommened
replacement is add_custom_target and add_custom_commsnd, but there's
no way to run a loop in either of those so this commit replaces
cmake_uninstall.cmake with cmake_uninstall.sh. This works on Microsoft
Windows beacuse at present we have to build on Windows in a MSYS2
shell. If at some point we gain the ability to build in a straight
Windows environment then we'll need a Windows CMD equivalent.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f9d0ad921..614e0edb0c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -958,12 +958,12 @@ add_custom_target(distcheck DEPENDS dist
# uninstall target
configure_file(
- "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.sh.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.sh"
@ONLY)
add_custom_target(uninstall
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+ COMMAND /bin/sh ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.sh)
set(_MODULES gnc-core-utils gnc-engine gnc-app-utils gnc-module gnc-locale-tax gnc-backend-xml-utils gnucash-guile)
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
deleted file mode 100644
index 91dfd32965..0000000000
--- a/cmake/cmake_uninstall.cmake.in
+++ /dev/null
@@ -1,23 +0,0 @@
-# This is taken from https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
-
-if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
- message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
-endif()
-
-file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
-string(REGEX REPLACE "\n" ";" files "${files}")
-foreach(file ${files})
- message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
- if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E remove \"$ENV{DESTDIR}${file}\"
- OUTPUT_VARIABLE rm_out
- RESULT_VARIABLE rm_retval
- )
- if(NOT "${rm_retval}" STREQUAL 0)
- message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
- endif()
- else()
- message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
- endif()
-endforeach(file)
diff --git a/cmake/cmake_uninstall.sh.in b/cmake/cmake_uninstall.sh.in
new file mode 100644
index 0000000000..88c0583efa
--- /dev/null
+++ b/cmake/cmake_uninstall.sh.in
@@ -0,0 +1,13 @@
+#!/bin/sh
+if [ ! -s install_manifest.txt ]; then
+ echo "Error: No install manifest."
+fi
+while IFS= read -r filename; do
+ if [ -e $filename ]; then
+ echo "--Uninstalling $filename"
+ rm $filename
+ else
+ echo "--$filename not found"
+ fi
+done<install_manifest.txt
+
Summary of changes:
CMakeLists.txt | 6 +++---
cmake/cmake_uninstall.cmake.in | 23 -----------------------
cmake/cmake_uninstall.sh.in | 13 +++++++++++++
3 files changed, 16 insertions(+), 26 deletions(-)
delete mode 100644 cmake/cmake_uninstall.cmake.in
create mode 100644 cmake/cmake_uninstall.sh.in
More information about the gnucash-changes
mailing list