From 175c2c3710a1cfae26ae30e1aaae4189ac432873 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 10 Jul 2013 21:07:43 +0000 Subject: [PATCH] adding uninstall target, required by PyBombs for updating the package git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@385 64b25241-fba3-4117-9849-534c7e92360d --- CMakeLists.txt | 11 +++++++++++ cmake/cmake_uninstall.cmake.in | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 cmake/cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c3ed50c..d1f48e914 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -498,6 +498,17 @@ endif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) list(APPEND CMAKE_CXX_FLAGS ${MY_CXX_FLAGS}) +######################################################################## +# Create uninstall target +######################################################################## +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake +@ONLY) + +add_custom_target(uninstall + ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake +) ######################################################################## diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 000000000..4a2a55c5b --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,22 @@ +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(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +list(REVERSE files) +foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (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} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) \ No newline at end of file