Skip to content

Commit

Permalink
Add uninstall target to CMakeLists.txt (Fixes #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed Jan 25, 2024
1 parent ec702ed commit f1b4056
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,13 @@ option(BUILD_FORIMAGE_EXAMPLES "Build examples")
message(STATUS "Build FORIMAGE examples: ${BUILD_FORIMAGE_EXAMPLES}")
if (BUILD_FORIMAGE_EXAMPLES)
add_subdirectory(example)
endif()
endif()

# Uninstall
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake)
13 changes: 13 additions & 0 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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()

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")

foreach (file ${files})
message(STATUS "Removing file: ${file}")
if (EXISTS "${file}")
file(REMOVE "${file}")
endif()
endforeach()

0 comments on commit f1b4056

Please sign in to comment.