cmake_uninstall.cmake.in 2.49 KB
Newer Older
1
#
Julien Michel's avatar
Julien Michel committed
2
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#
# This file is part of Orfeo Toolbox
#
#     https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

21 22 23 24 25 26 27 28 29 30
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
  message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
  return()
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}")
Rashad Kanavath's avatar
Rashad Kanavath committed
31 32 33 34
    execute_process(COMMAND
      "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
      OUTPUT_VARIABLE out_var
      RESULT_VARIABLE res_var
35
      )
Rashad Kanavath's avatar
Rashad Kanavath committed
36
    if(NOT "${res_var}" STREQUAL 0)
37
      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
Rashad Kanavath's avatar
Rashad Kanavath committed
38
    endif()
39 40 41 42
  else()
    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
  endif()
endforeach(file)
43 44 45 46 47 48 49 50

set(otb_dir_name "OTB-@OTB_VERSION_MAJOR@.@OTB_VERSION_MINOR@")

set(installed_dirs)
# include/OTB-X.Y directory
list(APPEND installed_dirs "@CMAKE_INSTALL_PREFIX@/include/${otb_dir_name}")
# lib/{otb,python} directory
list(APPEND installed_dirs "@CMAKE_INSTALL_PREFIX@/lib/otb")
51 52
# share/otb directory
list(APPEND installed_dirs "@CMAKE_INSTALL_PREFIX@/share/otb")
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
# lib/cmake/OTB-X.Y directory
list(APPEND installed_dirs "@CMAKE_INSTALL_PREFIX@/lib/cmake/${otb_dir_name}")
# share/doc/OTB-X.Y directory
list(APPEND installed_dirs "@CMAKE_INSTALL_PREFIX@/share/doc/${otb_dir_name}")

foreach(installed_dir ${installed_dirs})
  message(STATUS "Uninstalling ${installed_dir}")
  if(EXISTS "${installed_dir}" AND IS_DIRECTORY "${installed_dir}")
    execute_process(COMMAND
      "@CMAKE_COMMAND@" -E remove_directory "${installed_dir}"
      OUTPUT_VARIABLE out_rmdir
      RESULT_VARIABLE res_rmdir
      )
    if(NOT "${res_rmdir}" STREQUAL 0)
      message(FATAL_ERROR "Problem when removing ${installed_dir}")
    endif()
  endif()
endforeach()