Emit deprecation warning on unscoped import target usage

CMake will print the following warning:

CMake Warning (dev) at CMakeLists.txt:n (target_link_libraries):
  The library that is being linked to, ceres, is marked as being deprecated
  by the owner.  The message provided by the developer is:

  The unscoped import target `ceres' is deprecated and will be removed in a
  future Ceres Solver release.  Please use the Ceres::ceres import target
  instead.

This warning is for project developers.  Use -Wno-dev to suppress it.

Change-Id: I5abc875b1f61e1f47523375d1579a188047c45d4
This commit is contained in:
Sergiu Deitsch
2025-02-17 20:37:19 +01:00
parent ca4da54950
commit 7d196b4e6a
+6
View File
@@ -310,4 +310,10 @@ if (NOT TARGET ceres)
# true ALIAS library in CMake terms as they cannot point to imported targets. # true ALIAS library in CMake terms as they cannot point to imported targets.
add_library(ceres INTERFACE IMPORTED) add_library(ceres INTERFACE IMPORTED)
set_target_properties(ceres PROPERTIES INTERFACE_LINK_LIBRARIES Ceres::ceres) set_target_properties(ceres PROPERTIES INTERFACE_LINK_LIBRARIES Ceres::ceres)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
set_target_properties(ceres PROPERTIES DEPRECATION
"The unscoped import target `ceres' is deprecated and will be removed in a \
future Ceres Solver release. Please use the Ceres::ceres import target instead.")
endif (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17)
endif() endif()