7fd86b69dcfb1eb09d69fec62428be547f5c9bcc
[blender.git] / extern / libmv / third_party / ceres / CMakeLists.txt
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # The Original Code is Copyright (C) 2012, Blender Foundation
18 # All rights reserved.
19 #
20 # Contributor(s): Blender Foundation,
21 #                 Sergey Sharybin
22 #
23 # ***** END GPL LICENSE BLOCK *****
24
25 # NOTE: This file is automatically generated by bundle.sh script
26 #       If you're doing changes in this file, please update template
27 #       in that script too
28
29 set(INC
30         .
31         include
32         internal
33         ../gflags
34         ../../
35 )
36
37 set(INC_SYS
38         ../../../Eigen3
39 )
40
41 set(SRC
42         internal/ceres/array_utils.cc
43         internal/ceres/blas.cc
44         internal/ceres/block_evaluate_preparer.cc
45         internal/ceres/block_jacobian_writer.cc
46         internal/ceres/block_jacobi_preconditioner.cc
47         internal/ceres/block_random_access_crs_matrix.cc
48         internal/ceres/block_random_access_dense_matrix.cc
49         internal/ceres/block_random_access_diagonal_matrix.cc
50         internal/ceres/block_random_access_matrix.cc
51         internal/ceres/block_random_access_sparse_matrix.cc
52         internal/ceres/block_sparse_matrix.cc
53         internal/ceres/block_structure.cc
54         internal/ceres/canonical_views_clustering.cc
55         internal/ceres/c_api.cc
56         internal/ceres/cgnr_solver.cc
57         internal/ceres/compressed_col_sparse_matrix_utils.cc
58         internal/ceres/compressed_row_jacobian_writer.cc
59         internal/ceres/compressed_row_sparse_matrix.cc
60         internal/ceres/conditioned_cost_function.cc
61         internal/ceres/conjugate_gradients_solver.cc
62         internal/ceres/coordinate_descent_minimizer.cc
63         internal/ceres/corrector.cc
64         internal/ceres/covariance.cc
65         internal/ceres/covariance_impl.cc
66         internal/ceres/cxsparse.cc
67         internal/ceres/dense_normal_cholesky_solver.cc
68         internal/ceres/dense_qr_solver.cc
69         internal/ceres/dense_sparse_matrix.cc
70         internal/ceres/detect_structure.cc
71         internal/ceres/dogleg_strategy.cc
72         internal/ceres/evaluator.cc
73         internal/ceres/file.cc
74         internal/ceres/generated/partitioned_matrix_view_d_d_d.cc
75         internal/ceres/generated/schur_eliminator_d_d_d.cc
76         internal/ceres/gradient_checking_cost_function.cc
77         internal/ceres/implicit_schur_complement.cc
78         internal/ceres/incomplete_lq_factorization.cc
79         internal/ceres/iterative_schur_complement_solver.cc
80         internal/ceres/lapack.cc
81         internal/ceres/levenberg_marquardt_strategy.cc
82         internal/ceres/linear_least_squares_problems.cc
83         internal/ceres/linear_operator.cc
84         internal/ceres/linear_solver.cc
85         internal/ceres/line_search.cc
86         internal/ceres/line_search_direction.cc
87         internal/ceres/line_search_minimizer.cc
88         internal/ceres/local_parameterization.cc
89         internal/ceres/loss_function.cc
90         internal/ceres/low_rank_inverse_hessian.cc
91         internal/ceres/minimizer.cc
92         internal/ceres/normal_prior.cc
93         internal/ceres/parameter_block_ordering.cc
94         internal/ceres/partitioned_matrix_view.cc
95         internal/ceres/polynomial.cc
96         internal/ceres/preconditioner.cc
97         internal/ceres/problem.cc
98         internal/ceres/problem_impl.cc
99         internal/ceres/program.cc
100         internal/ceres/residual_block.cc
101         internal/ceres/residual_block_utils.cc
102         internal/ceres/schur_complement_solver.cc
103         internal/ceres/schur_eliminator.cc
104         internal/ceres/schur_jacobi_preconditioner.cc
105         internal/ceres/scratch_evaluate_preparer.cc
106         internal/ceres/single_linkage_clustering.cc
107         internal/ceres/solver.cc
108         internal/ceres/solver_impl.cc
109         internal/ceres/sparse_matrix.cc
110         internal/ceres/sparse_normal_cholesky_solver.cc
111         internal/ceres/split.cc
112         internal/ceres/stringprintf.cc
113         internal/ceres/suitesparse.cc
114         internal/ceres/triplet_sparse_matrix.cc
115         internal/ceres/trust_region_minimizer.cc
116         internal/ceres/trust_region_strategy.cc
117         internal/ceres/types.cc
118         internal/ceres/visibility_based_preconditioner.cc
119         internal/ceres/visibility.cc
120         internal/ceres/wall_time.cc
121
122         include/ceres/autodiff_cost_function.h
123         include/ceres/autodiff_local_parameterization.h
124         include/ceres/c_api.h
125         include/ceres/ceres.h
126         include/ceres/conditioned_cost_function.h
127         include/ceres/cost_function.h
128         include/ceres/cost_function_to_functor.h
129         include/ceres/covariance.h
130         include/ceres/crs_matrix.h
131         include/ceres/dynamic_autodiff_cost_function.h
132         include/ceres/dynamic_numeric_diff_cost_function.h
133         include/ceres/fpclassify.h
134         include/ceres/gradient_checker.h
135         include/ceres/internal/autodiff.h
136         include/ceres/internal/eigen.h
137         include/ceres/internal/fixed_array.h
138         include/ceres/internal/macros.h
139         include/ceres/internal/manual_constructor.h
140         include/ceres/internal/numeric_diff.h
141         include/ceres/internal/port.h
142         include/ceres/internal/scoped_ptr.h
143         include/ceres/internal/variadic_evaluate.h
144         include/ceres/iteration_callback.h
145         include/ceres/jet.h
146         include/ceres/local_parameterization.h
147         include/ceres/loss_function.h
148         include/ceres/normal_prior.h
149         include/ceres/numeric_diff_cost_function.h
150         include/ceres/numeric_diff_functor.h
151         include/ceres/ordered_groups.h
152         include/ceres/problem.h
153         include/ceres/rotation.h
154         include/ceres/sized_cost_function.h
155         include/ceres/solver.h
156         include/ceres/types.h
157         internal/ceres/array_utils.h
158         internal/ceres/blas.h
159         internal/ceres/block_evaluate_preparer.h
160         internal/ceres/block_jacobian_writer.h
161         internal/ceres/block_jacobi_preconditioner.h
162         internal/ceres/block_random_access_crs_matrix.h
163         internal/ceres/block_random_access_dense_matrix.h
164         internal/ceres/block_random_access_diagonal_matrix.h
165         internal/ceres/block_random_access_matrix.h
166         internal/ceres/block_random_access_sparse_matrix.h
167         internal/ceres/block_sparse_matrix.h
168         internal/ceres/block_structure.h
169         internal/ceres/canonical_views_clustering.h
170         internal/ceres/casts.h
171         internal/ceres/cgnr_linear_operator.h
172         internal/ceres/cgnr_solver.h
173         internal/ceres/collections_port.h
174         internal/ceres/compressed_col_sparse_matrix_utils.h
175         internal/ceres/compressed_row_jacobian_writer.h
176         internal/ceres/compressed_row_sparse_matrix.h
177         internal/ceres/conjugate_gradients_solver.h
178         internal/ceres/coordinate_descent_minimizer.h
179         internal/ceres/corrector.h
180         internal/ceres/covariance_impl.h
181         internal/ceres/cxsparse.h
182         internal/ceres/dense_jacobian_writer.h
183         internal/ceres/dense_normal_cholesky_solver.h
184         internal/ceres/dense_qr_solver.h
185         internal/ceres/dense_sparse_matrix.h
186         internal/ceres/detect_structure.h
187         internal/ceres/dogleg_strategy.h
188         internal/ceres/evaluator.h
189         internal/ceres/execution_summary.h
190         internal/ceres/file.h
191         internal/ceres/gradient_checking_cost_function.h
192         internal/ceres/graph_algorithms.h
193         internal/ceres/graph.h
194         internal/ceres/implicit_schur_complement.h
195         internal/ceres/incomplete_lq_factorization.h
196         internal/ceres/integral_types.h
197         internal/ceres/iterative_schur_complement_solver.h
198         internal/ceres/lapack.h
199         internal/ceres/levenberg_marquardt_strategy.h
200         internal/ceres/linear_least_squares_problems.h
201         internal/ceres/linear_operator.h
202         internal/ceres/linear_solver.h
203         internal/ceres/line_search_direction.h
204         internal/ceres/line_search.h
205         internal/ceres/line_search_minimizer.h
206         internal/ceres/low_rank_inverse_hessian.h
207         internal/ceres/map_util.h
208         internal/ceres/minimizer.h
209         internal/ceres/mutex.h
210         internal/ceres/parameter_block.h
211         internal/ceres/parameter_block_ordering.h
212         internal/ceres/partitioned_matrix_view.h
213         internal/ceres/partitioned_matrix_view_impl.h
214         internal/ceres/polynomial.h
215         internal/ceres/preconditioner.h
216         internal/ceres/problem_impl.h
217         internal/ceres/program_evaluator.h
218         internal/ceres/program.h
219         internal/ceres/random.h
220         internal/ceres/residual_block.h
221         internal/ceres/residual_block_utils.h
222         internal/ceres/schur_complement_solver.h
223         internal/ceres/schur_eliminator.h
224         internal/ceres/schur_eliminator_impl.h
225         internal/ceres/schur_jacobi_preconditioner.h
226         internal/ceres/scratch_evaluate_preparer.h
227         internal/ceres/single_linkage_clustering.h
228         internal/ceres/small_blas.h
229         internal/ceres/solver_impl.h
230         internal/ceres/sparse_matrix.h
231         internal/ceres/sparse_normal_cholesky_solver.h
232         internal/ceres/split.h
233         internal/ceres/stl_util.h
234         internal/ceres/stringprintf.h
235         internal/ceres/suitesparse.h
236         internal/ceres/triplet_sparse_matrix.h
237         internal/ceres/trust_region_minimizer.h
238         internal/ceres/trust_region_strategy.h
239         internal/ceres/visibility_based_preconditioner.h
240         internal/ceres/visibility.h
241         internal/ceres/wall_time.h
242 )
243
244 #if(FALSE)
245 #       list(APPEND SRC
246 #               internal/ceres/generated/partitioned_matrix_view_2_2_2.cc
247 #               internal/ceres/generated/partitioned_matrix_view_2_2_3.cc
248 #               internal/ceres/generated/partitioned_matrix_view_2_2_4.cc
249 #               internal/ceres/generated/partitioned_matrix_view_2_2_d.cc
250 #               internal/ceres/generated/partitioned_matrix_view_2_3_3.cc
251 #               internal/ceres/generated/partitioned_matrix_view_2_3_4.cc
252 #               internal/ceres/generated/partitioned_matrix_view_2_3_9.cc
253 #               internal/ceres/generated/partitioned_matrix_view_2_3_d.cc
254 #               internal/ceres/generated/partitioned_matrix_view_2_4_3.cc
255 #               internal/ceres/generated/partitioned_matrix_view_2_4_4.cc
256 #               internal/ceres/generated/partitioned_matrix_view_2_4_d.cc
257 #               internal/ceres/generated/partitioned_matrix_view_2_d_d.cc
258 #               internal/ceres/generated/partitioned_matrix_view_4_4_2.cc
259 #               internal/ceres/generated/partitioned_matrix_view_4_4_3.cc
260 #               internal/ceres/generated/partitioned_matrix_view_4_4_4.cc
261 #               internal/ceres/generated/partitioned_matrix_view_4_4_d.cc
262 #               internal/ceres/generated/schur_eliminator_2_2_2.cc
263 #               internal/ceres/generated/schur_eliminator_2_2_3.cc
264 #               internal/ceres/generated/schur_eliminator_2_2_4.cc
265 #               internal/ceres/generated/schur_eliminator_2_2_d.cc
266 #               internal/ceres/generated/schur_eliminator_2_3_3.cc
267 #               internal/ceres/generated/schur_eliminator_2_3_4.cc
268 #               internal/ceres/generated/schur_eliminator_2_3_9.cc
269 #               internal/ceres/generated/schur_eliminator_2_3_d.cc
270 #               internal/ceres/generated/schur_eliminator_2_4_3.cc
271 #               internal/ceres/generated/schur_eliminator_2_4_4.cc
272 #               internal/ceres/generated/schur_eliminator_2_4_d.cc
273 #               internal/ceres/generated/schur_eliminator_2_d_d.cc
274 #               internal/ceres/generated/schur_eliminator_4_4_2.cc
275 #               internal/ceres/generated/schur_eliminator_4_4_3.cc
276 #               internal/ceres/generated/schur_eliminator_4_4_4.cc
277 #               internal/ceres/generated/schur_eliminator_4_4_d.cc
278 #       )
279 #endif()
280
281 if(WIN32)
282         list(APPEND INC
283                 ../glog/src/windows
284         )
285
286         if(NOT MINGW)
287                 list(APPEND INC
288                         ../msinttypes
289                 )
290         endif()
291 else()
292         list(APPEND INC
293                 ../glog/src
294         )
295 endif()
296
297 add_definitions(
298         -DCERES_HAVE_PTHREAD
299         -DCERES_NO_SUITESPARSE
300         -DCERES_NO_CXSPARSE
301         -DCERES_NO_LAPACK
302         -DCERES_RESTRICT_SCHUR_SPECIALIZATION
303         -DCERES_HAVE_RWLOCK
304 )
305
306 if(WITH_OPENMP)
307         add_definitions(
308                 -DCERES_USE_OPENMP
309         )
310 endif()
311
312 include(CheckIncludeFileCXX)
313 CHECK_INCLUDE_FILE_CXX(unordered_map HAVE_STD_UNORDERED_MAP_HEADER)
314 if(HAVE_STD_UNORDERED_MAP_HEADER)
315         # Even so we've found unordered_map header file it doesn't
316         # mean unordered_map and unordered_set will be declared in
317         # std namespace.
318         #
319         # Namely, MSVC 2008 have unordered_map header which declares
320         # unordered_map class in std::tr1 namespace. In order to support
321         # this, we do extra check to see which exactly namespace is
322         # to be used.
323
324         include(CheckCXXSourceCompiles)
325         CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
326                                   int main() {
327                                     std::unordered_map<int, int> map;
328                                     return 0;
329                                   }"
330                                   HAVE_UNURDERED_MAP_IN_STD_NAMESPACE)
331         if(HAVE_UNURDERED_MAP_IN_STD_NAMESPACE)
332                 add_definitions(-DCERES_STD_UNORDERED_MAP)
333                 message(STATUS "Found unordered_map/set in std namespace.")
334         else()
335                 CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
336                                           int main() {
337                                             std::tr1::unordered_map<int, int> map;
338                                             return 0;
339                                           }"
340                                           HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
341                 if(HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
342                         add_definitions(-DCERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
343                         message(STATUS "Found unordered_map/set in std::tr1 namespace.")
344                 else()
345                         message(STATUS "Found <unordered_map> but cannot find either std::unordered_map "
346                                 "or std::tr1::unordered_map.")
347                         message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)")
348                         add_definitions(-DCERES_NO_UNORDERED_MAP)
349                 endif()
350         endif()
351 else()
352         CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" UNORDERED_MAP_IN_TR1_NAMESPACE)
353         if(UNORDERED_MAP_IN_TR1_NAMESPACE)
354                 add_definitions(-DCERES_TR1_UNORDERED_MAP)
355                 message(STATUS "Found unordered_map/set in std::tr1 namespace.")
356         else()
357                 message(STATUS "Unable to find <unordered_map> or <tr1/unordered_map>. ")
358                 message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)")
359                 add_definitions(-DCERES_NO_UNORDERED_MAP)
360         endif()
361 endif()
362
363 unset(HAVE_UNURDERED_MAP_IN_TR1_NAMESPACE)
364 unset(HAVE_STD_UNORDERED_MAP_HEADER)
365
366 blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}")