Skip to content

Commit

Permalink
Implement uninstall target
Browse files Browse the repository at this point in the history
- Added logic to generate an uninstall script and defined a
  target to run the script.

Signed-off-by: Derek Foster <derek.foster@intel.com>
  • Loading branch information
ffoulkes committed Nov 5, 2024
1 parent 696ff26 commit 044d4da
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ include(SetInstallRpath)

include(P4RuntimeProtobufs)

####################
# Uninstall target #
####################

# Create script to uninstall the build.
configure_file(
"cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY
)

# Define target to run uninstall script.
add_custom_target(uninstall
COMMAND
${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)

##################
# Subdirectories #
##################
Expand Down
17 changes: 17 additions & 0 deletions cmake/cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Intel Corporation
# SPDX-License-Identifier: Apache 2.0
#
# Uninstalls the files listed in install_manifest.txt.
#

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

foreach(file ${files})
message(STATUS "Uninstalling ${file}")
if(EXISTS "${file}")
file(REMOVE "${file}")
else()
message(STATUS "File ${file} does not exist.")
endif()
endforeach()

0 comments on commit 044d4da

Please sign in to comment.