[cmake]: add uninstall target

This commit is contained in:
Konstantinos Chatzilygeroudis
2021-03-06 01:08:41 +02:00
parent db387345ab
commit 74f35c0a4d
2 changed files with 28 additions and 0 deletions

View File

@@ -99,3 +99,7 @@ if(RYML_BUILD_TESTS OR RYML_BUILD_BENCHMARKS)
endif()
c4_add_dev_targets()
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${PROJECT_SOURCE_DIR}/cmake/uninstall.cmake"
)

24
cmake/uninstall.cmake Normal file
View File

@@ -0,0 +1,24 @@
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
if(NOT EXISTS ${MANIFEST})
message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'")
endif()
file(STRINGS ${MANIFEST} files)
foreach(file ${files})
if(EXISTS ${file})
message(STATUS "Removing file: '${file}'")
exec_program(
${CMAKE_COMMAND} ARGS "-E remove ${file}"
OUTPUT_VARIABLE stdout
RETURN_VALUE result
)
if(NOT "${result}" STREQUAL 0)
message(FATAL_ERROR "Failed to remove file: '${file}'.")
endif()
else()
MESSAGE(STATUS "File '${file}' does not exist.")
endif()
endforeach(file)