Skip to content

Commit 63dd5e2

Browse files
Build - Vendor the Ceres library in mmSolverLibs
This commit vendors Ceres Solver 1.14.0 into the mmSolver project to eliminate external dependency management and ensure consistent behavior across all build environments.
1 parent 7a2cad7 commit 63dd5e2

609 files changed

Lines changed: 314920 additions & 295 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ if(EXISTS "${eigen_vendored_dir}")
100100
message(STATUS "Set up vendored Eigen variables for dependencies: ${eigen_vendored_dir}")
101101
endif()
102102

103+
add_subdirectory(thirdparty)
104+
103105
# Finds and builds external (third-party) dependencies for
104106
# mmsolverlibs.
105107
include(FindAndBuildMmsolverDependencies)
106108

107109
# Finds and builds external (third-party) LDPK dependencies.
108110
include(FindAndBuildLdpkPackages)
109-
110-
add_subdirectory(thirdparty)
111111
add_subdirectory(mmsolverlibs/src)
112112

113113
option(MMSOLVERLIBS_BUILD_TESTS "Do you want to build the test files for mmsolverlibs?" OFF)

lib/thirdparty/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
add_subdirectory(cminpack)
2323
add_subdirectory(eigen)
2424
add_subdirectory(glog)
25+
add_subdirectory(ceres)
2526
add_subdirectory(openMVG)

lib/thirdparty/ceres/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*~
2+
.*.swp
3+
CMakeLists.txt.user*
4+
*.kdev*
5+
*.bak
6+
*.orig
7+
build/
8+
build-release/
9+
build-debug/
10+
docs/html
11+
*.aux
12+
*.blg
13+
*.toc
14+
*.fdb_latexmk
15+
*.bbl
16+
*.log
17+
*.synctex.gz
18+
ceres.pdf
19+
ceres-solver.pdf
20+
docs/minted.sty
21+
obj/
22+
jni/libs/
23+
.buildinfo
24+
bazel-*

lib/thirdparty/ceres/BUILD

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Ceres Solver - A fast non-linear least squares minimizer
2+
# Copyright 2018 Google Inc. All rights reserved.
3+
# http://ceres-solver.org/
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright notice,
9+
# this list of conditions and the following disclaimer.
10+
# * Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
# * Neither the name of Google Inc. nor the names of its contributors may be
14+
# used to endorse or promote products derived from this software without
15+
# specific prior written permission.
16+
#
17+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
# POSSIBILITY OF SUCH DAMAGE.
28+
#
29+
# Author: mierle@gmail.com (Keir Mierle)
30+
#
31+
# These are Bazel rules to build Ceres. It's currently in Alpha state, and does
32+
# not support parameterization around threading choice or sparse backends.
33+
34+
load("//:bazel/ceres.bzl", "ceres_library")
35+
36+
ceres_library(
37+
name = "ceres",
38+
restrict_schur_specializations = False,
39+
)
40+
41+
cc_library(
42+
name = "test_util",
43+
srcs = ["internal/ceres/" + x for x in [
44+
"evaluator_test_utils.cc",
45+
"numeric_diff_test_utils.cc",
46+
"test_util.cc",
47+
"gmock_gtest_all.cc",
48+
"gmock_main.cc",
49+
"gmock/gmock.h",
50+
"gmock/mock-log.h",
51+
"gtest/gtest.h",
52+
]],
53+
hdrs = [
54+
"internal/ceres/gmock/gmock.h",
55+
"internal/ceres/gmock/mock-log.h",
56+
"internal/ceres/gtest/gtest.h",
57+
],
58+
copts = [
59+
"-Wno-sign-compare",
60+
"-DCERES_TEST_SRCDIR_SUFFIX=\\\"data/\\\"",
61+
],
62+
includes = [
63+
"internal",
64+
"internal/ceres",
65+
],
66+
deps = [
67+
"//:ceres",
68+
"@com_github_gflags_gflags//:gflags",
69+
],
70+
)
71+
72+
CERES_TESTS = [
73+
"array_utils",
74+
"autodiff_cost_function",
75+
"autodiff_local_parameterization",
76+
"autodiff",
77+
"block_jacobi_preconditioner",
78+
"block_random_access_dense_matrix",
79+
"block_random_access_diagonal_matrix",
80+
"block_random_access_sparse_matrix",
81+
"block_sparse_matrix",
82+
"canonical_views_clustering",
83+
"c_api",
84+
"compressed_col_sparse_matrix_utils",
85+
"compressed_row_sparse_matrix",
86+
"concurrent_queue",
87+
"conditioned_cost_function",
88+
"conjugate_gradients_solver",
89+
"corrector",
90+
"cost_function_to_functor",
91+
"covariance",
92+
"cubic_interpolation",
93+
"dense_linear_solver",
94+
"dense_sparse_matrix",
95+
"detect_structure",
96+
"dogleg_strategy",
97+
"dynamic_autodiff_cost_function",
98+
"dynamic_compressed_row_sparse_matrix",
99+
"dynamic_numeric_diff_cost_function",
100+
"dynamic_sparse_normal_cholesky_solver",
101+
"dynamic_sparsity",
102+
"evaluation_callback",
103+
"evaluator",
104+
"gradient_checker",
105+
"gradient_checking_cost_function",
106+
"gradient_problem_solver",
107+
"gradient_problem",
108+
"graph_algorithms",
109+
"graph",
110+
"householder_vector",
111+
"implicit_schur_complement",
112+
"inner_product_computer",
113+
"invert_psd_matrix",
114+
"is_close",
115+
"iterative_schur_complement_solver",
116+
"jet",
117+
"levenberg_marquardt_strategy",
118+
"line_search_minimizer",
119+
"line_search_preprocessor",
120+
"local_parameterization",
121+
"loss_function",
122+
"minimizer",
123+
"normal_prior",
124+
"numeric_diff_cost_function",
125+
"ordered_groups",
126+
"parallel_for",
127+
"parallel_utils",
128+
"parameter_block_ordering",
129+
"parameter_block",
130+
"partitioned_matrix_view",
131+
"polynomial",
132+
"problem",
133+
"program",
134+
"reorder_program",
135+
"residual_block",
136+
"residual_block_utils",
137+
"rotation",
138+
"schur_complement_solver",
139+
"schur_eliminator",
140+
"single_linkage_clustering",
141+
"small_blas",
142+
"solver",
143+
"sparse_cholesky",
144+
"sparse_normal_cholesky_solver",
145+
"subset_preconditioner",
146+
"system",
147+
"thread_pool",
148+
"tiny_solver_autodiff_function",
149+
"tiny_solver_cost_function_adapter",
150+
"tiny_solver",
151+
"triplet_sparse_matrix",
152+
"trust_region_minimizer",
153+
"trust_region_preprocessor",
154+
"visibility_based_preconditioner",
155+
"visibility",
156+
]
157+
158+
TEST_COPTS = [
159+
# Needed to silence GFlags complaints.
160+
"-Wno-sign-compare",
161+
162+
# These two warnings don't work well in conjunction with GMock, and
163+
# trigger incorrectly on parts of rotation_test. For now, disable them,
164+
# but in the future disable these warnings only for rotation_test.
165+
# TODO(keir): When the tests are macro-ified, apply these selectively.
166+
"-Wno-nonnull-compare",
167+
"-Wno-address",
168+
]
169+
170+
TEST_DEPS = [
171+
"//:ceres",
172+
"//:test_util",
173+
"@com_github_eigen_eigen//:eigen",
174+
"@com_github_gflags_gflags//:gflags",
175+
]
176+
177+
# Instantiate all the tests with a template.
178+
[cc_test(
179+
name = test_name + "_test",
180+
timeout = "short",
181+
srcs = ["internal/ceres/" + test_name + "_test.cc"],
182+
copts = TEST_COPTS,
183+
deps = TEST_DEPS,
184+
) for test_name in CERES_TESTS]
185+
186+
# Instantiate all the bundle adjustment tests. These are separate to
187+
# parallelize the execution of the tests; otherwise the tests take a long time.
188+
#
189+
# Note: While it is possible to run the Python script to generate the .cc files
190+
# as part of the build, it introduces an undesirable build-time Python
191+
# dependency that we'd prefer to avoid.
192+
[cc_test(
193+
name = test_filename.split("/")[-1][:-3], # Remove .cc.
194+
timeout = "moderate",
195+
srcs = [test_filename],
196+
copts = TEST_COPTS,
197+
198+
# This is the data set that is bundled for the testing.
199+
data = [":data/problem-16-22106-pre.txt"],
200+
deps = TEST_DEPS,
201+
) for test_filename in glob([
202+
"internal/ceres/generated_bundle_adjustment_tests/*_test.cc",
203+
])]
204+
205+
# Build the benchmarks.
206+
[cc_binary(
207+
name = benchmark_name,
208+
srcs = ["internal/ceres/" + benchmark_name + ".cc"],
209+
copts = TEST_COPTS,
210+
deps = TEST_DEPS + ["@com_github_google_benchmark//:benchmark"],
211+
) for benchmark_name in [
212+
"autodiff_cost_function_benchmark",
213+
"small_blas_gemm_benchmark",
214+
"small_blas_gemv_benchmark",
215+
]]

0 commit comments

Comments
 (0)