GeezerVison is showing github.com — Add cmake TARGET: uninstall · sevan/bcc@99146aa
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: CMakeLists.txt +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -196,3 +196,13 @@ add_subdirectory(tests) |
196 | 196 | endif(ENABLE_TESTS) |
197 | 197 | add_subdirectory(tools) |
198 | 198 | endif(ENABLE_CLANG_JIT) |
| 199 | + |
| 200 | +if(NOT TARGET uninstall) |
| 201 | + configure_file( |
| 202 | + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CmakeUninstall.cmake.in" |
| 203 | + "${CMAKE_CURRENT_BINARY_DIR}/CmakeUninstall.cmake" |
| 204 | + IMMEDIATE @ONLY) |
| 205 | + |
| 206 | + add_custom_target(uninstall |
| 207 | + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CmakeUninstall.cmake) |
| 208 | +endif() |
Collapse file
Copy file name to clipboard +29Lines changed: 29 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | +# Copyright (C) 2022 Rong Tao |
| 3 | +# |
| 4 | +function(UninstallManifest manifest) |
| 5 | +if(NOT EXISTS "${manifest}") |
| 6 | + message(FATAL_ERROR "Cannot find install manifest: ${manifest}") |
| 7 | +endif() |
| 8 | + |
| 9 | +file(READ "${manifest}" files) |
| 10 | +string(REGEX REPLACE "\n" ";" files "${files}") |
| 11 | +foreach(file ${files}) |
| 12 | + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") |
| 13 | + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") |
| 14 | + exec_program( |
| 15 | + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" |
| 16 | + OUTPUT_VARIABLE rm_out |
| 17 | + RETURN_VALUE rm_retval |
| 18 | + ) |
| 19 | + if(NOT "${rm_retval}" STREQUAL 0) |
| 20 | + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") |
| 21 | + endif() |
| 22 | + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") |
| 23 | + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") |
| 24 | + endif() |
| 25 | +endforeach() |
| 26 | +endfunction() |
| 27 | + |
| 28 | +UninstallManifest("@CMAKE_BINARY_DIR@/install_manifest.txt") |
| 29 | +UninstallManifest("@CMAKE_BINARY_DIR@/install_manifest_python_bcc.txt") |
Collapse file
Copy file name to clipboardExpand all lines: src/python/CMakeLists.txt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,7 +40,7 @@ foreach(PY_CMD ${PYTHON_CMD}) |
40 | 40 | install( |
41 | 41 | CODE " |
42 | 42 | execute_process( |
43 | | - COMMAND ${PY_CMD} setup.py install -f ${PYTHON_FLAGS} --prefix=${CMAKE_INSTALL_PREFIX} |
| 43 | + COMMAND ${PY_CMD} setup.py install -f ${PYTHON_FLAGS} --prefix=${CMAKE_INSTALL_PREFIX} --record ${CMAKE_BINARY_DIR}/install_manifest_python_bcc.txt |
44 | 44 | WORKING_DIRECTORY ${PY_DIRECTORY})" |
45 | 45 | COMPONENT python) |
46 | 46 | endforeach() |