From 3b459c368c475482b7d2bb833a34f82797545c6c Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Sat, 20 Nov 2010 12:18:54 -0600 Subject: [PATCH] Added uninstall target --- CMakeLists.txt | 21 +++++++++++++++----- aux/binpac | 2 +- aux/bro-aux | 2 +- aux/broccoli | 2 +- aux/broctl | 2 +- cmake/cmake_uninstall.cmake.in | 35 ++++++++++++++++++++++++++++++++++ policy/CMakeLists.txt | 2 +- 7 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 cmake/cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 64555b02d5..2a67e5984a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ -######################################################################## ## CMake Configuration +project(Bro) + +######################################################################## +## CMake Configuration cmake_minimum_required(VERSION 2.8 FATAL_ERROR) # Prohibit in-source builds. @@ -8,19 +11,27 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") "initialize the build configuration.") endif () -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") + # uninstall target + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY) + + add_custom_target(uninstall COMMAND + ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif () ######################################################################## ## Project/Build Configuration -project(Bro) - set(BRO_ROOT_DIR ${CMAKE_INSTALL_PREFIX}) if (NOT POLICYDIR) set(POLICYDIR ${BRO_ROOT_DIR}/share/bro) endif () -file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1) +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1) set(EXTRA_COMPILE_FLAGS "-Wall -Wno-unused") diff --git a/aux/binpac b/aux/binpac index 9886b3d164..2a97dd5ff1 160000 --- a/aux/binpac +++ b/aux/binpac @@ -1 +1 @@ -Subproject commit 9886b3d16447bd7c8575b8b4a190767183a6d1a7 +Subproject commit 2a97dd5ff19cc864cebd1b7687945857dadf96b3 diff --git a/aux/bro-aux b/aux/bro-aux index ac747bc3c3..b23a5d5614 160000 --- a/aux/bro-aux +++ b/aux/bro-aux @@ -1 +1 @@ -Subproject commit ac747bc3c3d64fa963e4b2238df7441af4d513b5 +Subproject commit b23a5d561440514b50efe9c9a005e390dea3d1d5 diff --git a/aux/broccoli b/aux/broccoli index 7ec41e3af3..9fccc65e06 160000 --- a/aux/broccoli +++ b/aux/broccoli @@ -1 +1 @@ -Subproject commit 7ec41e3af3009c468d70b22fda143ba4dc1c151c +Subproject commit 9fccc65e065c490c0689393ddf1b4d6b8d1f1831 diff --git a/aux/broctl b/aux/broctl index 0a0aa63ff3..5a2c50336b 160000 --- a/aux/broctl +++ b/aux/broctl @@ -1 +1 @@ -Subproject commit 0a0aa63ff38fbb7b2b85cbdbc922c92c2c94c124 +Subproject commit 5a2c50336b9e6abecdd3771c6189ab5824bc3c8a diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 0000000000..e801cff1c3 --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,35 @@ +function(uninstall_manifest manifestPath) + file(READ "${manifestPath}" files) + string(REGEX REPLACE "\n" ";" files "${files}") + foreach (file ${files}) + set(fileName $ENV{DESTDIR}${file}) + + if (EXISTS "${fileName}" OR IS_SYMLINK "${fileName}") + message(STATUS "Uninstalling: ${fileName}") + + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "${fileName}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + + if (NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing: ${fileName}") + endif () + else () + message(STATUS "Does not exist: ${fileName}") + endif () + + endforeach () +endfunction(uninstall_manifest) + +file(GLOB install_manifests @CMAKE_CURRENT_BINARY_DIR@/install_manifest*.txt) + +if (install_manifests) + foreach (manifest ${install_manifests}) + uninstall_manifest(${manifest}) + endforeach () +else () + message(FATAL_ERROR "Cannot find any install manifests in: " + "\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest*.txt\"") +endif () diff --git a/policy/CMakeLists.txt b/policy/CMakeLists.txt index cda588a9a5..a79e841661 100644 --- a/policy/CMakeLists.txt +++ b/policy/CMakeLists.txt @@ -1,4 +1,4 @@ -install(DIRECTORY . DESTINATION ${POLICYDIR} FILES_MATCHING +install(DIRECTORY ./ DESTINATION ${POLICYDIR} FILES_MATCHING PATTERN "summaries" EXCLUDE PATTERN "all.bro" EXCLUDE PATTERN "bro.init"