Add uninstall target to CMake.

This commit is contained in:
theraven 2012-12-22 11:04:20 +00:00
parent 5cd0a37e27
commit 651962702a
2 changed files with 34 additions and 3 deletions

View File

@ -97,7 +97,7 @@ if (BOEHM_GC)
else ()
find_library(LIBGC gc PATHS GC_LIBRARY_DIRS)
endif ()
message("-- Using Boehm GC library: ${LIBGC}")
message(STATUS "Using Boehm GC library: ${LIBGC}")
include_directories(GC_INCLUDE_DIRS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_CFLAGS}")
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -fobjc-gc")
@ -158,13 +158,13 @@ endif (NOT CXX_RUNTIME)
# for Objective-C and Objective-C++. If not, then we need to provide a
# separate libobjcxx.
if (CXX_RUNTIME)
message("-- Using ${CXX_RUNTIME} as the C++ runtime library")
message(STATUS "Using ${CXX_RUNTIME} as the C++ runtime library")
set(libobjc_CXX_SRCS ${libobjcxx_CXX_SRCS})
# We don't want to link the STL implementation (e.g. libstdc++) if we have
# a separate C++ runtime.
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
else (CXX_RUNTIME)
message("-- No C++ runtime library found")
message(STATUS "No C++ runtime library found")
add_library(objcxx SHARED ${libobjcxx_CXX_SRCS})
set_target_properties(objcxx PROPERTIES
LINKER_LANGUAGE C
@ -262,3 +262,12 @@ if (UNIX)
endif ()
include (CPack)
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.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)

22
cmake_uninstall.cmake.in Normal file
View File

@ -0,0 +1,22 @@
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(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)