From 6726cd50732157e12e476445c8e3081379e5e2a1 Mon Sep 17 00:00:00 2001 From: Sameer Agarwal Date: Mon, 12 Aug 2024 05:56:27 -0700 Subject: [PATCH] Fix absl::log_flags linking on Linux Generator expressions were introduced in CMake version 3.24. Without them including absl::log_flags as an internal dependency causes linking problems on some platforms. So for platforms with an older CMake version we make absl::log_flags a public dependency. Change-Id: I686f41e76b0ac17a03f1cd1d614372a7f130dfd9 --- internal/ceres/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt index 921ea9e12..c997a4df8 100644 --- a/internal/ceres/CMakeLists.txt +++ b/internal/ceres/CMakeLists.txt @@ -34,7 +34,17 @@ find_package(Threads REQUIRED) list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES Threads::Threads) # Make dependency visible to the parent CMakeLists.txt set(Threads_DEPENDENCY "find_dependency (Threads)" PARENT_SCOPE) -list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES $) + +# Generator expressions were introduced in CMake version 3.24. Without +# them including absl::log_flags as an internal dependency causes +# linking problems on some platforms. So for platforms with an older +# CMake version we make absl::log_flags a public dependency. +if(CMAKE_VERSION VERSION_LESS "3.24.0") + list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES absl::log_flags) +else() + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES $) +endif() + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES absl::strings) list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES absl::time)