diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in index 1dd0999c4..8e1bb56e4 100644 --- a/cmake_uninstall.cmake.in +++ b/cmake_uninstall.cmake.in @@ -19,7 +19,7 @@ IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(STATUS "catkin path: @CMAKE_INSTALL_PREFIX@/.catkin") -IF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin") +IF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin" AND PACKAGE_CREATES_DOT_CATKIN) MESSAGE(STATUS "Try to remove @CMAKE_INSTALL_PREFIX@/.catkin") EXECUTE_PROCESS( COMMAND @CMAKE_COMMAND@ -E remove "@CMAKE_INSTALL_PREFIX@/.catkin" @@ -27,7 +27,7 @@ IF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin") OUTPUT_VARIABLE rm_out ERROR_VARIABLE rm_err ) -ENDIF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin") +ENDIF() IF(EXISTS "@CMAKE_CURRRENT_BINARY_DIR@/install_manifest.txt") return() diff --git a/uninstall.cmake b/uninstall.cmake index 4bd98958f..e48903a19 100644 --- a/uninstall.cmake +++ b/uninstall.cmake @@ -19,6 +19,15 @@ # Add custom rule to uninstall the package. # macro(_SETUP_PROJECT_UNINSTALL) + # Detect if the .catkin was created previously + IF(NOT DEFINED PACKAGE_CREATES_DOT_CATKIN OR NOT "${PACKAGE_PREVIOUS_INSTALL_PREFIX}" STREQUAL "${CMAKE_INSTALL_PREFIX}") + SET(PACKAGE_PREVIOUS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "Cache install prefix given to the package") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/.catkin") + SET(PACKAGE_CREATES_DOT_CATKIN FALSE CACHE INTERNAL "") + ELSE() + SET(PACKAGE_CREATES_DOT_CATKIN TRUE CACHE INTERNAL "") + ENDIF() + ENDIF() # FIXME: it is utterly stupid to rely on the install manifest. Can't we just # remember what we install ?! configure_file(