From 6a2a8e06d71556beafe0bdaefba75c38970d7505 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Sat, 26 Mar 2016 17:08:24 +0000 Subject: [PATCH] [CMake] Declare uninstall rule before the components so that they can add dependencies to the rule for their own custom uninstall logic. --- CMakeLists.txt | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df6d528b0..a3ba4968e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -327,6 +327,25 @@ message(STATUS "CMAKE_INSTALL_LIBDIR: \"${CMAKE_INSTALL_LIBDIR}\"") message(STATUS "CMAKE_INSTALL_BINDIR: \"${CMAKE_INSTALL_BINDIR}\"") message(STATUS "CMAKE_INSTALL_INCLUDEDIR: \"${CMAKE_INSTALL_INCLUDEDIR}\"") +################################################################################ +# Uninstall rule +################################################################################ +configure_file( + "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY +) + +# Target needs to be declared before the components so that they can add +# dependencies to this target so they can run their own custom uninstall rules. +add_custom_target(uninstall + COMMAND + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + COMMENT "Uninstalling..." + ${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG} + VERBATIM +) + ################################################################################ # CMake build file locations ################################################################################ @@ -362,19 +381,3 @@ if (ENABLE_EXAMPLE_TARGETS) add_subdirectory(examples) endif() -################################################################################ -# Uninstall rule -################################################################################ -configure_file( - "${CMAKE_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" - COMMENT "Uninstalling..." - ${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG} - VERBATIM -)