Fix and modernize Bazel build for Bazel 8/9 and missing targets

- Add .bazelignore to exclude third_party submodules from //...
- Ignore MODULE.bazel.lock in .gitignore
- Update MODULE.bazel dependencies (abseil-cpp, googletest, eigen,
  google_benchmark, rules_cc) for Bazel 8/9 compatibility
- Define CERES_HAS_GTEST on //:test_util (fixing regression from ccd1198d)
- Add missing sources (dynamic_cost_function_to_functor.cc,
  fake_bundle_adjustment_jacobian.cc) to CERES_SRCS in bazel/ceres.bzl
- Add missing unit tests, benchmarks, and example targets to BUILD and
  examples/BUILD

Change-Id: I303727d991fb30e5d156f79fd5c50475ebf661a7
diff --git a/.bazelignore b/.bazelignore
new file mode 100644
index 0000000..e8ebdec
--- /dev/null
+++ b/.bazelignore
@@ -0,0 +1,2 @@
+third_party
+cmake-build
diff --git a/.gitignore b/.gitignore
index ca55495..8326583 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@
 jni/libs/
 .buildinfo
 bazel-*
+MODULE.bazel.lock
 *.pyc
 .idea*
 
diff --git a/BUILD b/BUILD
index ce36537..a2d07a0 100644
--- a/BUILD
+++ b/BUILD
@@ -33,6 +33,8 @@
 load("//:bazel/ceres.bzl", "ceres_library")
 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
 
+exports_files(["data/problem-16-22106-pre.txt"])
+
 ceres_library(
     name = "ceres",
     restrict_schur_specializations = False,
@@ -49,6 +51,9 @@
         "-Wno-sign-compare",
         "-DCERES_TEST_SRCDIR_SUFFIX=\\\"_main/data/\\\"",
     ],
+    defines = [
+        "CERES_HAS_GTEST",
+    ],
     includes = [
         "internal",
         "internal/ceres",
@@ -61,17 +66,19 @@
 
 CERES_TESTS = [
     "accurate_norm",
+    "array_selector",
     "array_utils",
-    "autodiff_cost_function",
-    "autodiff_manifold",
     "autodiff",
+    "autodiff_cost_function",
+    "autodiff_first_order_function",
+    "autodiff_manifold",
     "block_jacobi_preconditioner",
     "block_random_access_dense_matrix",
     "block_random_access_diagonal_matrix",
     "block_random_access_sparse_matrix",
     "block_sparse_matrix",
-    "canonical_views_clustering",
     "c_api",
+    "canonical_views_clustering",
     "compressed_col_sparse_matrix_utils",
     "compressed_row_sparse_matrix",
     "concurrent_queue",
@@ -83,6 +90,7 @@
     "cubic_interpolation",
     "dense_cholesky",
     "dense_linear_solver",
+    "dense_qr",
     "dense_sparse_matrix",
     "detect_structure",
     "dogleg_strategy",
@@ -95,32 +103,38 @@
     "evaluator",
     "gradient_checker",
     "gradient_checking_cost_function",
-    "gradient_problem_solver",
     "gradient_problem",
-    "graph_algorithms",
+    "gradient_problem_solver",
     "graph",
+    "graph_algorithms",
     "householder_vector",
     "implicit_schur_complement",
     "inner_product_computer",
+    "integer_sequence_algorithm",
     "invert_psd_matrix",
     "is_close",
     "iterative_refiner",
     "iterative_schur_complement_solver",
     "jet",
+    "jet_traits",
     "levenberg_marquardt_strategy",
     "line_search_minimizer",
     "line_search_preprocessor",
     "loss_function",
+    "manifold",
     "minimizer",
     "normal_prior",
     "numeric_diff_cost_function",
+    "numeric_diff_first_order_function",
     "ordered_groups",
     "parallel_for",
     "parallel_utils",
-    "parameter_block_ordering",
     "parameter_block",
+    "parameter_block_ordering",
+    "parameter_dims",
     "partitioned_matrix_view",
     "polynomial",
+    "power_series_expansion_preconditioner",
     "problem",
     "program",
     "reorder_program",
@@ -137,14 +151,14 @@
     "subset_preconditioner",
     "system",
     "thread_pool",
+    "tiny_solver",
     "tiny_solver_autodiff_function",
     "tiny_solver_cost_function_adapter",
-    "tiny_solver",
     "triplet_sparse_matrix",
     "trust_region_minimizer",
     "trust_region_preprocessor",
-    "visibility_based_preconditioner",
     "visibility",
+    "visibility_based_preconditioner",
 ]
 
 TEST_DEPS = [
@@ -184,14 +198,25 @@
     srcs = ["internal/ceres/" + benchmark_name + ".cc"],
     copts = ["-mllvm -inlinehint-threshold=1000000"],
     deps = TEST_DEPS + ["@google_benchmark//:benchmark"],
-
 ) for benchmark_name in [
+    "block_jacobi_preconditioner_benchmark",
+    "dense_linear_solver_benchmark",
     "evaluation_benchmark",
     "invert_psd_matrix_benchmark",
-    "schur_eliminator_benchmark",
     "jet_operator_benchmark",
-    "dense_linear_solver_benchmark",
+    "parallel_for_benchmark",
     "parallel_vector_operations_benchmark",
+    "schur_eliminator_benchmark",
     "small_blas_gemm_benchmark",
     "small_blas_gemv_benchmark",
+    "spmv_benchmark",
 ]]
+
+cc_binary(
+    name = "autodiff_benchmarks",
+    srcs = ["internal/ceres/autodiff_benchmarks/autodiff_benchmarks.cc"] + glob([
+        "internal/ceres/autodiff_benchmarks/*.h",
+    ]),
+    copts = ["-mllvm -inlinehint-threshold=1000000"],
+    deps = TEST_DEPS + ["@google_benchmark//:benchmark"],
+)
diff --git a/MODULE.bazel b/MODULE.bazel
index 97ba31e..4523c36 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,9 +1,9 @@
 # MODULE.bazel
 
-module(name = "ceres-solver", version="head")
+module(name = "ceres-solver", version = "head")
 
-bazel_dep(name = "abseil-cpp", version = "20250127.0")
-bazel_dep(name = "googletest", version = "1.16.0")
-bazel_dep(name = "eigen", version = "3.4.0")
-bazel_dep(name = "google_benchmark", version = "1.8.4")
+bazel_dep(name = "abseil-cpp", version = "20250814.2")
+bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
+bazel_dep(name = "eigen", version = "3.4.0.bcr.3")
+bazel_dep(name = "google_benchmark", version = "1.9.5")
 bazel_dep(name = "rules_cc", version = "0.2.22")
diff --git a/bazel/ceres.bzl b/bazel/ceres.bzl
index 609ba92..e161120 100644
--- a/bazel/ceres.bzl
+++ b/bazel/ceres.bzl
@@ -66,11 +66,13 @@
     "dogleg_strategy.cc",
     "dynamic_compressed_row_jacobian_writer.cc",
     "dynamic_compressed_row_sparse_matrix.cc",
+    "dynamic_cost_function_to_functor.cc",
     "dynamic_sparse_normal_cholesky_solver.cc",
     "eigensparse.cc",
     "evaluation_callback.cc",
     "evaluator.cc",
     "event_logger.cc",
+    "fake_bundle_adjustment_jacobian.cc",
     "file.cc",
     "first_order_function.cc",
     "function_sample.cc",
@@ -138,17 +140,11 @@
 ]]
 
 # TODO(rodrigoq): add support to configure Ceres into various permutations,
-# like SuiteSparse or not, threading or not, glog or not, and so on.
+# like SuiteSparse or not, and so on.
 # See https://github.com/ceres-solver/ceres-solver/issues/335.
 def ceres_library(
         name,
         restrict_schur_specializations = False):
-    # The path to internal/ depends on whether Ceres is the main workspace or
-    # an external repository.
-    if native.repository_name() != "@":
-        internal = "external/%s/internal" % native.repository_name().lstrip("@")
-    else:
-        internal = "internal"
 
     # The fixed-size Schur eliminator template instantiations incur a large
     # binary size penalty, and are slow to compile, so support disabling them.
diff --git a/examples/BUILD b/examples/BUILD
index dddc0f9..5000649 100644
--- a/examples/BUILD
+++ b/examples/BUILD
@@ -30,6 +30,8 @@
 
 
 
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
+
 EXAMPLE_DEPS = [
     "//:ceres",
     "@eigen//:eigen",
@@ -52,6 +54,31 @@
     deps = EXAMPLE_DEPS,
 )
 
+cc_test(
+    name = "bal_problem_test",
+    timeout = "short",
+    srcs = [
+        "bal_problem.cc",
+        "bal_problem.h",
+        "bal_problem_test.cc",
+    ],
+    copts = [
+        "-DCERES_TEST_DATA_DIR=\\\"data\\\"",
+    ],
+    data = ["//:data/problem-16-22106-pre.txt"],
+    deps = EXAMPLE_DEPS + [
+        "@googletest//:gtest_main",
+    ],
+)
+
+cc_binary(
+    name = "curve_fitting_c",
+    srcs = [
+        "curve_fitting.c",
+    ],
+    deps = EXAMPLE_DEPS,
+)
+
 cc_binary(
     name = "denoising",
     srcs = [
@@ -102,12 +129,16 @@
     srcs = [example + ".cc"],
     deps = EXAMPLE_DEPS,
 ) for example in [
+    "bicubic_interpolation",
+    "bicubic_interpolation_analytic",
     "circle_fit",
     "curve_fitting",
     "ellipse_approximation",
+    "evaluation_callback_example",
     "helloworld",
     "helloworld_analytic_diff",
     "helloworld_numeric_diff",
+    "iteration_callback_example",
     "libmv_bundle_adjuster",
     "libmv_homography",
     "more_garbow_hillstrom",
@@ -115,6 +146,8 @@
     "powell",
     "robust_curve_fitting",
     "rosenbrock",
+    "rosenbrock_analytic_diff",
+    "rosenbrock_numeric_diff",
     "sampled_function/sampled_function",
     "simple_bundle_adjuster",
 ]]