From a862a6a66f425ced67fef876fb1d723ff247d389 Mon Sep 17 00:00:00 2001 From: Navid Jalali Date: Sat, 18 Dec 2021 10:30:10 +0330 Subject: [PATCH 1/3] Initial commit. Uninstall target. --- cmake_uninstall.cmake.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cmake_uninstall.cmake.in diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000..121489683 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,22 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif() + +file(READ "@CMAKE_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}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif() + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach() + From e72559d35c26c1deaa4ef80d3197f239ca3654c3 Mon Sep 17 00:00:00 2001 From: Navid Jalali Date: Sat, 18 Dec 2021 10:30:51 +0330 Subject: [PATCH 2/3] Introducing the uninstall (custom) target to CMake --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ccbd8851..4919c2730 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,3 +142,16 @@ set(CPACK_DEBIAN_PACKAGE_DEBUG OFF) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) include(CPack) + +##################################### +# Uninstall Files +##################################### +if(NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() From 115d6c7922d95c18de2813cb4dcab2536585875c Mon Sep 17 00:00:00 2001 From: Navid Jalali Date: Sun, 19 Dec 2021 10:57:17 +0330 Subject: [PATCH 3/3] Moving cmake_uninstall.cmake.in to cmake directory and changing the path in CMakeLists.txt --- CMakeLists.txt | 2 +- cmake_uninstall.cmake.in => cmake/cmake_uninstall.cmake.in | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename cmake_uninstall.cmake.in => cmake/cmake_uninstall.cmake.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4919c2730..bf0e05284 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,7 @@ include(CPack) ##################################### if(NOT TARGET uninstall) configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) diff --git a/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in similarity index 100% rename from cmake_uninstall.cmake.in rename to cmake/cmake_uninstall.cmake.in