From 537d2c54d343c3d874d0def160c2f1ae55ec60e7 Mon Sep 17 00:00:00 2001 From: Johan Hedin Date: Fri, 12 Jan 2024 16:11:37 +0100 Subject: [PATCH] Only create uninstall target if it does not exist In case librtlsdr is included as a subdirectory into another cmake project the uninstall target may already be set and causes cmake to fail. In a standalone build the check this patch adds does not alter the behaviour. (cherry picked from commit 0990db4247f16878d4f2765dd7d545080574ca79) --- CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9aa5242..24cc690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,14 +148,17 @@ include_directories( ######################################################################## # Create uninstall target ######################################################################## -configure_file( - ${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake -@ONLY) - -add_custom_target(uninstall - ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake -) +if(NOT TARGET uninstall) + configure_file( + ${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + @ONLY + ) + + add_custom_target(uninstall + ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + ) +endif() ######################################################################## # Install udev rules