From 9eee8ec0bb5d1d2b23424d7264ff9becd8fa4813 Mon Sep 17 00:00:00 2001 From: Matthew Albrecht Date: Fri, 20 Sep 2019 15:13:09 -0500 Subject: [PATCH] Check for existing uninstall target before creating. --- source/CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5c924e844..31413acc3 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -250,15 +250,17 @@ install(DIRECTORY ${XLNT_INCLUDE_DIR}/xlnt install(FILES ${XLNT_ROOT_DIR}/docs/xlnt.3 DESTINATION ${MAN_DEST_DIR}/man3) -# Configure uninstall -configure_file("${XLNT_ROOT_DIR}/cmake/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) - -# Add uninstall target -add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +if(NOT TARGET uninstall) + # Configure uninstall + configure_file("${XLNT_ROOT_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + + # Add uninstall target + add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() if(NOT MSVC) # Set pkg-config variables