diff options
author | Antenore Gatta (tmow) <antenore@simbiosi.org> | 2021-07-14 18:12:27 +0300 |
---|---|---|
committer | Antenore Gatta (tmow) <antenore@simbiosi.org> | 2021-07-14 18:12:27 +0300 |
commit | 433a113ab690bf4e08eb1e71ac146eba08698c28 (patch) | |
tree | bfe468debfa4eb23bfdc4c93d36aa3605fa06be5 /cmake | |
parent | 460d70a5c28464c1e350d7c2a478f36e11864394 (diff) |
Improved uninstall target. closes #2314
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/cmake_uninstall.cmake.in | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index 47a971545..09bff1867 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -1,3 +1,22 @@ +# 'delete_empty_folder' function +function(delete_empty_folder DIR) + if(NOT EXISTS ${DIR}) + return() + endif() + + # check if folder is empty + file(GLOB RESULT "${DIR}/*") + list(LENGTH RESULT RES_LEN) + if(RES_LEN EQUAL 0) + message(STATUS "Delete empty folder ${DIR}") + #file(REMOVE_RECURSE ${DIR}) + else() + # message(STATUS "${DIR} is not empty! It won't be removed.") + # message(STATUS "FILES = ${RESULT}") + endif() +endfunction(delete_empty_folder) + + 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" ) @@ -25,4 +44,25 @@ foreach(file ${files}) endif(EXISTS "$ENV{DESTDIR}${file}") + + get_filename_component(FOLDER $ENV{DESTDIR}${file} DIRECTORY) + set(FOLDERS ${FOLDERS} ${FOLDER}) + endforeach(file) + +# remove empty folders +message(STATUS "") +message(STATUS "Removing empty folders") + +list(REMOVE_DUPLICATES FOLDERS) +foreach(dir ${FOLDERS}) +# message(STATUS ${dir}) + delete_empty_folder(${dir}) +# message(STATUS "") +endforeach(dir) + +delete_empty_folder("@INSTALL_INCLUDE_DIR@") +delete_empty_folder("@INSTALL_BIN_DIR@") +delete_empty_folder("@INSTALL_LIB_DIR@/CMake") +delete_empty_folder("@INSTALL_LIB_DIR@") +message(STATUS "") |