mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Add namespace qualified Ceres::ceres CMake target
- This reflects modern CMake style, and also provides a measure of protection against missing find_package() imports in downstream clients resulting in linker errors when 'ceres' matches the compiled library and not the imported target. - The original 'ceres' target remains, as a local imported interface target created by CeresConfig for backwards compatibility. Change-Id: Ie9ed8de9b7059bc0cae1ae5002bb94d8fe617188
This commit is contained in:
committed by
Sameer Agarwal
parent
99efa54bdb
commit
b70687fcc8
@@ -262,7 +262,7 @@ if (NOT TARGET ceres AND NOT Ceres_BINARY_DIR)
|
||||
include(${CERES_CURRENT_CONFIG_DIR}/CeresTargets.cmake)
|
||||
endif (NOT TARGET ceres AND NOT Ceres_BINARY_DIR)
|
||||
# Set the expected XX_LIBRARIES variable for FindPackage().
|
||||
set(CERES_LIBRARIES ceres)
|
||||
set(CERES_LIBRARIES Ceres::ceres)
|
||||
|
||||
# Reset CMake module path to its state when this script was called.
|
||||
set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH})
|
||||
@@ -320,3 +320,11 @@ ceres_message(STATUS "Found " ${CERES_DETECTED_VERSION_STRING})
|
||||
# Ceres_FOUND is not (explicitly, i.e. undefined does not count) set
|
||||
# to FALSE.
|
||||
set(CERES_FOUND TRUE)
|
||||
|
||||
if (NOT TARGET ceres)
|
||||
# For backwards compatibility, create a local 'alias' target with the
|
||||
# non-namespace-qualified Ceres target name. Note that this is not a
|
||||
# true ALIAS library in CMake terms as they cannot point to imported targets.
|
||||
add_library(ceres INTERFACE IMPORTED)
|
||||
set_target_properties(ceres PROPERTIES INTERFACE_LINK_LIBRARIES Ceres::ceres)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user