Skip to content

Commit 287043a

Browse files
authored
Merge pull request #171 from brchiu/add_uninstall_capability
Add uninstall capability
2 parents 7b310b6 + 81980a8 commit 287043a

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,6 @@ add_custom_target(cleancache
293293
COMMAND find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} +
294294
COMMAND rm -rf Makefile Doxyfile
295295
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
296+
297+
# uninstall
298+
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake")

CMakeModules/uninstall.cmake

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.0.2)
2+
3+
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
4+
5+
if(NOT EXISTS ${MANIFEST})
6+
message(FATAL_ERROR "Cannot find install manifest: ${MANIFEST}")
7+
endif()
8+
9+
file(STRINGS ${MANIFEST} files)
10+
foreach(file ${files})
11+
if(EXISTS ${file} OR IS_SYMLINK ${file})
12+
message(STATUS "Removing: ${file}")
13+
14+
execute_process(COMMAND rm -f ${file}
15+
RESULT_VARIABLE result
16+
OUTPUT_QUIET
17+
ERROR_VARIABLE stderr
18+
ERROR_STRIP_TRAILING_WHITESPACE
19+
)
20+
21+
if(NOT ${result} EQUAL 0)
22+
message(FATAL_ERROR "${stderr}")
23+
endif()
24+
else()
25+
message(STATUS "Does-not-exist: ${file}")
26+
endif()
27+
endforeach(file)

0 commit comments

Comments
 (0)