blob: 486b1b21d10274a981a7412a059a8dfc972148c2 [file] [log] [blame]
Stepan Salenikovich1f47b552016-05-03 17:24:33 -04001# Taken from:
2# https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
3#
4# Copyright (C) 2016 Savoir-faire Linux Inc.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19#
20
21if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
22 message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
23endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
24
25file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
26string(REGEX REPLACE "\n" ";" files "${files}")
27foreach(file ${files})
28 message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
29 if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
30 exec_program(
31 "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
32 OUTPUT_VARIABLE rm_out
33 RETURN_VALUE rm_retval
34 )
35 if(NOT "${rm_retval}" STREQUAL 0)
36 message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
37 endif(NOT "${rm_retval}" STREQUAL 0)
38 else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
39 message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
40 endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
41endforeach(file)