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
31 changes: 27 additions & 4 deletions Tools/CMake/AMReXInstallHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ function (install_amrex_targets)
# legacy symlink for: libamrex.[so|a] / amrex.[dll.lib]
# escape spaces for generated cmake_install.cmake file
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}/lib" ABS_INSTALL_LIB_DIR)
install(CODE "file(CREATE_LINK
$<TARGET_FILE_NAME:amrex_${AMReX_SPACEDIM_LAST}d>
\"${ABS_INSTALL_LIB_DIR}/$<TARGET_FILE_PREFIX:amrex_${AMReX_SPACEDIM_LAST}d>amrex$<TARGET_FILE_SUFFIX:amrex_${AMReX_SPACEDIM_LAST}d>\"
COPY_ON_ERROR SYMBOLIC)"
install(CODE "
set(symlink_name \"${ABS_INSTALL_LIB_DIR}/$<TARGET_FILE_PREFIX:amrex_${AMReX_SPACEDIM_LAST}d>amrex$<TARGET_FILE_SUFFIX:amrex_${AMReX_SPACEDIM_LAST}d>\")
file(CREATE_LINK
$<TARGET_FILE_NAME:amrex_${AMReX_SPACEDIM_LAST}d>
\"\${symlink_name}\"
COPY_ON_ERROR SYMBOLIC)
list(APPEND CMAKE_INSTALL_MANIFEST_FILES \"\${symlink_name}\")
"
)

# Install fortran modules if Fortran is enabled
Expand Down Expand Up @@ -178,3 +182,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