Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ include(AMReXInstallHelpers)
install_amrex_targets(${_amrex_targets})

if(AMReX_INSTALL)
add_uninstall_target(${CMAKE_CURRENT_LIST_DIR})

# Add a test_install target to smoke-test
# the installation
add_test_install_target(
Expand Down
5 changes: 5 additions & 0 deletions Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ The CMake build process is summarized as follows:
cmake [options] -DCMAKE_BUILD_TYPE=[Debug|Release|RelWithDebInfo|MinSizeRel] -DCMAKE_INSTALL_PREFIX=/path/to/installdir /path/to/amrex
make install
make test_install # optional step to test if the installation is working
make uninstall # optional step to remove files from install_manifest.txt

In the above snippet, ``[options]`` indicates one or more options for the
customization of the build, as described in the subsection on
Expand All @@ -391,6 +392,10 @@ customization of the build, as described in the subsection on
build directory, we advise against doing so. After the installation is
complete, ``builddir`` can be removed.

The ``uninstall`` target removes files listed in ``install_manifest.txt``.
For staged installs, use the same ``DESTDIR`` setting that was used for the
install step.


.. _sec:build:cmake:options:

Expand Down
19 changes: 19 additions & 0 deletions Tools/CMake/AMReXInstallHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,22 @@ macro( add_test_install_target _dir _amrex_root )
)

endmacro()

#
# Add uninstall target
#
# _amrex_root: Root directory of AMReX (contains Tools/CMake/)
#
macro(add_uninstall_target _amrex_root)
if(NOT TARGET uninstall)
configure_file(
"${_amrex_root}/Tools/CMake/AMReX_cmake_uninstall.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
COMMENT "Uninstalling files listed in install_manifest.txt"
)
endif()
endmacro()
25 changes: 25 additions & 0 deletions Tools/CMake/AMReX_cmake_uninstall.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()

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

foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}"
RESULT_VARIABLE rm_retval
OUTPUT_VARIABLE rm_out
ERROR_VARIABLE rm_err
)
if(NOT "${rm_retval}" STREQUAL "0")
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}: ${rm_err}")
endif()
else()
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()

message(STATUS "Uninstall complete")
Loading