Make the custom uninstall target optional
Ceres-solver provides a custom uninstall target to ease the removal of
installed files from the system. This clashes with other projects, that
too provide an uninstall target (like Eigen3).
Related issue: https://github.com/ceres-solver/ceres-solver/issues/451#issuecomment-565571090
Change-Id: Id153830ae20a880d23c7468acb39f55f48a2129a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc6b846..e224cad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -164,6 +164,7 @@
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_BENCHMARKS "Build Ceres benchmarking suite" ON)
option(BUILD_SHARED_LIBS "Build Ceres as a shared library." OFF)
+option(PROVIDE_UNINSTALL_TARGET "Add a custom target to ease removal of installed targets" ON)
option(CODE_GENERATION "Build the code generation module." OFF)
if(CODE_GENERATION)
message(WARNING "The code generation module is still under development. The functionality and API of the current implementation might change in the future.")
@@ -762,12 +763,14 @@
"${Ceres_SOURCE_DIR}/cmake/FindGlog.cmake"
DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR})
-# Create an uninstall target to remove all installed files.
-configure_file("${Ceres_SOURCE_DIR}/cmake/uninstall.cmake.in"
- "${Ceres_BINARY_DIR}/cmake/uninstall.cmake"
- @ONLY)
-add_custom_target(uninstall
- COMMAND ${CMAKE_COMMAND} -P ${Ceres_BINARY_DIR}/cmake/uninstall.cmake)
+if (PROVIDE_UNINSTALL_TARGET)
+ # Create an uninstall target to remove all installed files.
+ configure_file("${Ceres_SOURCE_DIR}/cmake/uninstall.cmake.in"
+ "${Ceres_BINARY_DIR}/cmake/uninstall.cmake"
+ @ONLY)
+ add_custom_target(uninstall
+ COMMAND ${CMAKE_COMMAND} -P ${Ceres_BINARY_DIR}/cmake/uninstall.cmake)
+endif()
# Install method #2: Put Ceres build into local CMake registry.
#