Make CMake threads a public Ceres dependency.

- Required to propagate the threading flags to example targets that
  depend upon Ceres and do not directly specify threads as a dependency
  to support some *nix builds.

Change-Id: I1c229bd0241da55a203c2b1f8fc28ea43c312e69
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index d2a6bd1..e90562a 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -30,7 +30,6 @@
 
 # Avoid 'xxx.cc has no symbols' warnings from source files which are 'empty'
 # when their enclosing #ifdefs are disabled.
-find_package(Threads QUIET)
 if (CERES_THREADING_MODEL STREQUAL "CXX11_THREADS")
   set(CERES_PARALLEL_FOR_SRC parallel_for_cxx.cc thread_pool.cc)
 elseif (CERES_THREADING_MODEL STREQUAL "OPENMP")
@@ -39,10 +38,6 @@
     # OpenMP in GCC requires the GNU OpenMP library.
     list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES gomp)
   endif()
-  if (NOT MSVC)
-    # Add thread library dependencies for OpenMP to the Ceres target.
-    list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES ${CMAKE_THREAD_LIBS_INIT})
-  endif()
 elseif (CERES_THREADING_MODEL STREQUAL "NO_THREADS")
   set(CERES_PARALLEL_FOR_SRC parallel_for_nothreads.cc)
 endif()
@@ -176,6 +171,9 @@
 endif (SCHUR_SPECIALIZATIONS)
 
 # Build the list of dependencies for Ceres based on the current configuration.
+find_package(Threads QUIET)
+list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES Threads::Threads)
+
 if (NOT MINIGLOG AND GLOG_FOUND)
   list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES ${GLOG_LIBRARIES})
   if (GFLAGS_FOUND)