# SPDX-FileCopyrightText: 2012 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later

set(INC
  .
  include
  internal
  config
)

set(INC_SYS
  ${EIGEN3_INCLUDE_DIRS}
  ${GFLAGS_INCLUDE_DIRS}
  ${GLOG_INCLUDE_DIRS}
)

set(SRC
  include/ceres/autodiff_cost_function.h
  include/ceres/autodiff_first_order_function.h
  include/ceres/autodiff_local_parameterization.h
  include/ceres/autodiff_manifold.h
  include/ceres/c_api.h
  include/ceres/ceres.h
  include/ceres/conditioned_cost_function.h
  include/ceres/context.h
  include/ceres/cost_function.h
  include/ceres/cost_function_to_functor.h
  include/ceres/covariance.h
  include/ceres/crs_matrix.h
  include/ceres/cubic_interpolation.h
  include/ceres/dynamic_autodiff_cost_function.h
  include/ceres/dynamic_cost_function.h
  include/ceres/dynamic_cost_function_to_functor.h
  include/ceres/dynamic_numeric_diff_cost_function.h
  include/ceres/evaluation_callback.h
  include/ceres/first_order_function.h
  include/ceres/gradient_checker.h
  include/ceres/gradient_problem.h
  include/ceres/gradient_problem_solver.h
  include/ceres/iteration_callback.h
  include/ceres/jet.h
  include/ceres/jet_fwd.h
  include/ceres/line_manifold.h
  include/ceres/local_parameterization.h
  include/ceres/loss_function.h
  include/ceres/manifold.h
  include/ceres/manifold_test_utils.h
  include/ceres/normal_prior.h
  include/ceres/numeric_diff_cost_function.h
  include/ceres/numeric_diff_first_order_function.h
  include/ceres/numeric_diff_options.h
  include/ceres/ordered_groups.h
  include/ceres/problem.h
  include/ceres/product_manifold.h
  include/ceres/rotation.h
  include/ceres/sized_cost_function.h
  include/ceres/solver.h
  include/ceres/sphere_manifold.h
  include/ceres/tiny_solver.h
  include/ceres/tiny_solver_autodiff_function.h
  include/ceres/tiny_solver_cost_function_adapter.h
  include/ceres/types.h
  include/ceres/version.h

  include/ceres/internal/array_selector.h
  include/ceres/internal/autodiff.h
  include/ceres/internal/disable_warnings.h
  include/ceres/internal/eigen.h
  include/ceres/internal/fixed_array.h
  include/ceres/internal/householder_vector.h
  include/ceres/internal/integer_sequence_algorithm.h
  include/ceres/internal/jet_traits.h
  include/ceres/internal/line_parameterization.h
  include/ceres/internal/memory.h
  include/ceres/internal/numeric_diff.h
  include/ceres/internal/parameter_dims.h
  include/ceres/internal/port.h
  include/ceres/internal/reenable_warnings.h
  include/ceres/internal/sphere_manifold_functions.h
  include/ceres/internal/variadic_evaluate.h

  internal/ceres/accelerate_sparse.cc
  internal/ceres/accelerate_sparse.h
  internal/ceres/array_utils.cc
  internal/ceres/array_utils.h
  internal/ceres/block_evaluate_preparer.cc
  internal/ceres/block_evaluate_preparer.h
  internal/ceres/block_jacobi_preconditioner.cc
  internal/ceres/block_jacobi_preconditioner.h
  internal/ceres/block_jacobian_writer.cc
  internal/ceres/block_jacobian_writer.h
  internal/ceres/block_random_access_dense_matrix.cc
  internal/ceres/block_random_access_dense_matrix.h
  internal/ceres/block_random_access_diagonal_matrix.cc
  internal/ceres/block_random_access_diagonal_matrix.h
  internal/ceres/block_random_access_matrix.cc
  internal/ceres/block_random_access_matrix.h
  internal/ceres/block_random_access_sparse_matrix.cc
  internal/ceres/block_random_access_sparse_matrix.h
  internal/ceres/block_sparse_matrix.cc
  internal/ceres/block_sparse_matrix.h
  internal/ceres/block_structure.cc
  internal/ceres/block_structure.h
  internal/ceres/c_api.cc
  internal/ceres/callbacks.cc
  internal/ceres/callbacks.h
  internal/ceres/canonical_views_clustering.cc
  internal/ceres/canonical_views_clustering.h
  internal/ceres/casts.h
  internal/ceres/cgnr_linear_operator.h
  internal/ceres/cgnr_solver.cc
  internal/ceres/cgnr_solver.h
  internal/ceres/compressed_col_sparse_matrix_utils.cc
  internal/ceres/compressed_col_sparse_matrix_utils.h
  internal/ceres/compressed_row_jacobian_writer.cc
  internal/ceres/compressed_row_jacobian_writer.h
  internal/ceres/compressed_row_sparse_matrix.cc
  internal/ceres/compressed_row_sparse_matrix.h
  internal/ceres/concurrent_queue.h
  internal/ceres/conditioned_cost_function.cc
  internal/ceres/conjugate_gradients_solver.cc
  internal/ceres/conjugate_gradients_solver.h
  internal/ceres/context.cc
  internal/ceres/context_impl.cc
  internal/ceres/context_impl.h
  internal/ceres/coordinate_descent_minimizer.cc
  internal/ceres/coordinate_descent_minimizer.h
  internal/ceres/corrector.cc
  internal/ceres/corrector.h
  internal/ceres/cost_function.cc
  internal/ceres/covariance.cc
  internal/ceres/covariance_impl.cc
  internal/ceres/covariance_impl.h
  internal/ceres/cuda_buffer.h
  internal/ceres/cxsparse.cc
  internal/ceres/cxsparse.h
  internal/ceres/dense_cholesky.cc
  internal/ceres/dense_cholesky.h
  internal/ceres/dense_jacobian_writer.h
  internal/ceres/dense_normal_cholesky_solver.cc
  internal/ceres/dense_normal_cholesky_solver.h
  internal/ceres/dense_qr.cc
  internal/ceres/dense_qr.h
  internal/ceres/dense_qr_solver.cc
  internal/ceres/dense_qr_solver.h
  internal/ceres/dense_sparse_matrix.cc
  internal/ceres/dense_sparse_matrix.h
  internal/ceres/detect_structure.cc
  internal/ceres/detect_structure.h
  internal/ceres/dogleg_strategy.cc
  internal/ceres/dogleg_strategy.h
  internal/ceres/dynamic_compressed_row_finalizer.h
  internal/ceres/dynamic_compressed_row_jacobian_writer.cc
  internal/ceres/dynamic_compressed_row_jacobian_writer.h
  internal/ceres/dynamic_compressed_row_sparse_matrix.cc
  internal/ceres/dynamic_compressed_row_sparse_matrix.h
  internal/ceres/dynamic_sparse_normal_cholesky_solver.cc
  internal/ceres/dynamic_sparse_normal_cholesky_solver.h
  internal/ceres/eigensparse.cc
  internal/ceres/eigensparse.h
  internal/ceres/evaluation_callback.cc
  internal/ceres/evaluator.cc
  internal/ceres/evaluator.h
  internal/ceres/execution_summary.h
  internal/ceres/file.cc
  internal/ceres/file.h
  internal/ceres/first_order_function.cc
  internal/ceres/float_cxsparse.cc
  internal/ceres/float_cxsparse.h
  internal/ceres/float_suitesparse.cc
  internal/ceres/float_suitesparse.h
  internal/ceres/function_sample.cc
  internal/ceres/function_sample.h
  internal/ceres/gradient_checker.cc
  internal/ceres/gradient_checking_cost_function.cc
  internal/ceres/gradient_checking_cost_function.h
  internal/ceres/gradient_problem.cc
  internal/ceres/gradient_problem_evaluator.h
  internal/ceres/gradient_problem_solver.cc
  internal/ceres/graph.h
  internal/ceres/graph_algorithms.h
  internal/ceres/implicit_schur_complement.cc
  internal/ceres/implicit_schur_complement.h
  internal/ceres/inner_product_computer.cc
  internal/ceres/inner_product_computer.h
  internal/ceres/invert_psd_matrix.h
  internal/ceres/is_close.cc
  internal/ceres/is_close.h
  internal/ceres/iteration_callback.cc
  internal/ceres/iterative_refiner.cc
  internal/ceres/iterative_refiner.h
  internal/ceres/iterative_schur_complement_solver.cc
  internal/ceres/iterative_schur_complement_solver.h
  internal/ceres/levenberg_marquardt_strategy.cc
  internal/ceres/levenberg_marquardt_strategy.h
  internal/ceres/line_search.cc
  internal/ceres/line_search.h
  internal/ceres/line_search_direction.cc
  internal/ceres/line_search_direction.h
  internal/ceres/line_search_minimizer.cc
  internal/ceres/line_search_minimizer.h
  internal/ceres/line_search_preprocessor.cc
  internal/ceres/line_search_preprocessor.h
  internal/ceres/linear_least_squares_problems.cc
  internal/ceres/linear_least_squares_problems.h
  internal/ceres/linear_operator.cc
  internal/ceres/linear_operator.h
  internal/ceres/linear_solver.cc
  internal/ceres/linear_solver.h
  internal/ceres/local_parameterization.cc
  internal/ceres/loss_function.cc
  internal/ceres/low_rank_inverse_hessian.cc
  internal/ceres/low_rank_inverse_hessian.h
  internal/ceres/manifold.cc
  internal/ceres/manifold_adapter.h
  internal/ceres/map_util.h
  internal/ceres/minimizer.cc
  internal/ceres/minimizer.h
  internal/ceres/normal_prior.cc
  internal/ceres/pair_hash.h
  internal/ceres/parallel_for.h
  internal/ceres/parallel_for_cxx.cc
  internal/ceres/parallel_for_nothreads.cc
  internal/ceres/parallel_for_openmp.cc
  internal/ceres/parallel_utils.cc
  internal/ceres/parallel_utils.h
  internal/ceres/parameter_block.h
  internal/ceres/parameter_block_ordering.cc
  internal/ceres/parameter_block_ordering.h
  internal/ceres/partitioned_matrix_view.cc
  internal/ceres/partitioned_matrix_view.h
  internal/ceres/partitioned_matrix_view_impl.h
  internal/ceres/polynomial.cc
  internal/ceres/polynomial.h
  internal/ceres/preconditioner.cc
  internal/ceres/preconditioner.h
  internal/ceres/preprocessor.cc
  internal/ceres/preprocessor.h
  internal/ceres/problem.cc
  internal/ceres/problem_impl.cc
  internal/ceres/problem_impl.h
  internal/ceres/program.cc
  internal/ceres/program.h
  internal/ceres/program_evaluator.h
  internal/ceres/random.h
  internal/ceres/reorder_program.cc
  internal/ceres/reorder_program.h
  internal/ceres/residual_block.cc
  internal/ceres/residual_block.h
  internal/ceres/residual_block_utils.cc
  internal/ceres/residual_block_utils.h
  internal/ceres/schur_complement_solver.cc
  internal/ceres/schur_complement_solver.h
  internal/ceres/schur_eliminator.cc
  internal/ceres/schur_eliminator.h
  internal/ceres/schur_eliminator_impl.h
  internal/ceres/schur_jacobi_preconditioner.cc
  internal/ceres/schur_jacobi_preconditioner.h
  internal/ceres/schur_templates.cc
  internal/ceres/schur_templates.h
  internal/ceres/scoped_thread_token.h
  internal/ceres/scratch_evaluate_preparer.cc
  internal/ceres/scratch_evaluate_preparer.h
  internal/ceres/single_linkage_clustering.cc
  internal/ceres/single_linkage_clustering.h
  internal/ceres/small_blas.h
  internal/ceres/small_blas_generic.h
  internal/ceres/solver.cc
  internal/ceres/solver_utils.cc
  internal/ceres/solver_utils.h
  internal/ceres/sparse_cholesky.cc
  internal/ceres/sparse_cholesky.h
  internal/ceres/sparse_matrix.cc
  internal/ceres/sparse_matrix.h
  internal/ceres/sparse_normal_cholesky_solver.cc
  internal/ceres/sparse_normal_cholesky_solver.h
  internal/ceres/stl_util.h
  internal/ceres/stringprintf.cc
  internal/ceres/stringprintf.h
  internal/ceres/subset_preconditioner.cc
  internal/ceres/subset_preconditioner.h
  internal/ceres/suitesparse.cc
  internal/ceres/suitesparse.h
  internal/ceres/thread_pool.cc
  internal/ceres/thread_pool.h
  internal/ceres/thread_token_provider.cc
  internal/ceres/thread_token_provider.h
  internal/ceres/triplet_sparse_matrix.cc
  internal/ceres/triplet_sparse_matrix.h
  internal/ceres/trust_region_minimizer.cc
  internal/ceres/trust_region_minimizer.h
  internal/ceres/trust_region_preprocessor.cc
  internal/ceres/trust_region_preprocessor.h
  internal/ceres/trust_region_step_evaluator.cc
  internal/ceres/trust_region_step_evaluator.h
  internal/ceres/trust_region_strategy.cc
  internal/ceres/trust_region_strategy.h
  internal/ceres/types.cc
  internal/ceres/visibility.cc
  internal/ceres/visibility.h
  internal/ceres/visibility_based_preconditioner.cc
  internal/ceres/visibility_based_preconditioner.h
  internal/ceres/wall_time.cc
  internal/ceres/wall_time.h

  internal/ceres/generated/partitioned_matrix_view_d_d_d.cc
  internal/ceres/generated/schur_eliminator_d_d_d.cc
)

set(LIB
  ${GLOG_LIBRARIES}
  ${GFLAGS_LIBRARIES}
)

if(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
  list(APPEND SRC
    internal/ceres/generated/partitioned_matrix_view_2_2_2.cc
    internal/ceres/generated/partitioned_matrix_view_2_2_3.cc
    internal/ceres/generated/partitioned_matrix_view_2_2_4.cc
    internal/ceres/generated/partitioned_matrix_view_2_2_d.cc
    internal/ceres/generated/partitioned_matrix_view_2_3_3.cc
    internal/ceres/generated/partitioned_matrix_view_2_3_4.cc
    internal/ceres/generated/partitioned_matrix_view_2_3_6.cc
    internal/ceres/generated/partitioned_matrix_view_2_3_9.cc
    internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
    internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
    internal/ceres/generated/partitioned_matrix_view_2_4_4.cc
    internal/ceres/generated/partitioned_matrix_view_2_4_6.cc
    internal/ceres/generated/partitioned_matrix_view_2_4_8.cc
    internal/ceres/generated/partitioned_matrix_view_2_4_9.cc
    internal/ceres/generated/partitioned_matrix_view_2_4_d.cc
    internal/ceres/generated/partitioned_matrix_view_2_d_d.cc
    internal/ceres/generated/partitioned_matrix_view_3_3_3.cc
    internal/ceres/generated/partitioned_matrix_view_4_4_2.cc
    internal/ceres/generated/partitioned_matrix_view_4_4_3.cc
    internal/ceres/generated/partitioned_matrix_view_4_4_4.cc
    internal/ceres/generated/partitioned_matrix_view_4_4_d.cc
    internal/ceres/generated/schur_eliminator_2_2_2.cc
    internal/ceres/generated/schur_eliminator_2_2_3.cc
    internal/ceres/generated/schur_eliminator_2_2_4.cc
    internal/ceres/generated/schur_eliminator_2_2_d.cc
    internal/ceres/generated/schur_eliminator_2_3_3.cc
    internal/ceres/generated/schur_eliminator_2_3_4.cc
    internal/ceres/generated/schur_eliminator_2_3_6.cc
    internal/ceres/generated/schur_eliminator_2_3_9.cc
    internal/ceres/generated/schur_eliminator_2_3_d.cc
    internal/ceres/generated/schur_eliminator_2_4_3.cc
    internal/ceres/generated/schur_eliminator_2_4_4.cc
    internal/ceres/generated/schur_eliminator_2_4_6.cc
    internal/ceres/generated/schur_eliminator_2_4_8.cc
    internal/ceres/generated/schur_eliminator_2_4_9.cc
    internal/ceres/generated/schur_eliminator_2_4_d.cc
    internal/ceres/generated/schur_eliminator_2_d_d.cc
    internal/ceres/generated/schur_eliminator_3_3_3.cc
    internal/ceres/generated/schur_eliminator_4_4_2.cc
    internal/ceres/generated/schur_eliminator_4_4_3.cc
    internal/ceres/generated/schur_eliminator_4_4_4.cc
    internal/ceres/generated/schur_eliminator_4_4_d.cc
  )
else()
  add_definitions(-DCERES_RESTRICT_SCHUR_SPECIALIZATION)
endif()

add_definitions(${GFLAGS_DEFINES})
add_definitions(${GLOG_DEFINES})

blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
