Export ceres_cuda_kernels to project's build tree
This avoids the following CMake error when exporting Ceres build
directory to local CMake package registry:
export called with target "ceres" which requires target
"ceres_cuda_kernels" that is not in any export set.
Fixes #966
Change-Id: I5a75191fc414a3f138b19cb9d5850f7330f2d24a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cedc787..a6d196d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -814,13 +814,23 @@
${Ceres_BINARY_DIR}
${Ceres_SOURCE_DIR})
+ set (Ceres_EXPORT_TARGETS ceres)
+
+ if (TARGET ceres_cuda_kernels)
+ # The target ceres depends on ceres_cuda_kernels requiring the latter to be
+ # exported as part of the same export set.
+ list (APPEND Ceres_EXPORT_TARGETS ceres_cuda_kernels)
+ endif (TARGET ceres_cuda_kernels)
+
# Analogously to install(EXPORT ...), export the Ceres target from the build
# directory as a package called Ceres into the local CMake package registry.
- export(TARGETS ceres
+ export(TARGETS ${Ceres_EXPORT_TARGETS}
NAMESPACE Ceres::
FILE ${Ceres_BINARY_DIR}/CeresTargets.cmake)
export(PACKAGE ${CMAKE_PROJECT_NAME})
+ unset (Ceres_EXPORT_TARGETS)
+
# Configure a CeresConfig.cmake file for the export of the Ceres build
# directory from the template, reflecting the current build options.
set(SETUP_CERES_CONFIG_FOR_INSTALLATION FALSE)