Link against threading library only if necessary

1. The platform specific threads library is only needed if we actually
   use threads. In this case, the library is not optional opposed to
   previous logic.
2. Do not hide the find module output to allow the user to understand
   what happens in case of a CMake failure to locate Threads.
3. Finally, Threads is private dependency that does need to be
   propagated to consumers unless Ceres was compiled as a static
   library.

Change-Id: I8d9d9cd42930e1ed234f69a2dba70d0ee2755b4e
This commit is contained in:
Sergiu Deitsch
2022-06-07 23:53:12 +02:00
parent 69eddfb6da
commit dfce1e128d
2 changed files with 10 additions and 8 deletions
+3 -4
View File
@@ -1,5 +1,5 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# Copyright 2022 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
@@ -176,11 +176,10 @@ endif(CERES_WAS_INSTALLED)
set(CERES_VERSION @CERES_VERSION@)
include(CMakeFindDependencyMacro)
find_dependency(Threads)
# Optional dependencies
@SuiteSparse_DEPENDENCY@
@OpenMP_DEPENDENCY@
@SuiteSparse_DEPENDENCY@
@Threads_DEPENDENCY@
# As imported CMake targets are not re-exported when a dependent target is
# exported, we must invoke find_package(XXX) here to reload the definition