1# Ceres Solver - A fast non-linear least squares minimizer 2# Copyright 2010, 2011, 2012 Google Inc. All rights reserved. 3# http://code.google.com/p/ceres-solver/ 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: keir@google.com (Keir Mierle) 30 31SET(CERES_INTERNAL_SRC 32 array_utils.cc 33 block_evaluate_preparer.cc 34 block_jacobi_preconditioner.cc 35 block_jacobian_writer.cc 36 block_random_access_dense_matrix.cc 37 block_random_access_matrix.cc 38 block_random_access_sparse_matrix.cc 39 block_sparse_matrix.cc 40 block_structure.cc 41 canonical_views_clustering.cc 42 cgnr_solver.cc 43 compressed_row_jacobian_writer.cc 44 compressed_row_sparse_matrix.cc 45 conditioned_cost_function.cc 46 conjugate_gradients_solver.cc 47 coordinate_descent_minimizer.cc 48 corrector.cc 49 cxsparse.cc 50 dense_normal_cholesky_solver.cc 51 dense_qr_solver.cc 52 dense_sparse_matrix.cc 53 detect_structure.cc 54 dogleg_strategy.cc 55 evaluator.cc 56 file.cc 57 gradient_checking_cost_function.cc 58 implicit_schur_complement.cc 59 iterative_schur_complement_solver.cc 60 levenberg_marquardt_strategy.cc 61 linear_least_squares_problems.cc 62 linear_operator.cc 63 linear_solver.cc 64 local_parameterization.cc 65 loss_function.cc 66 normal_prior.cc 67 parameter_block_ordering.cc 68 partitioned_matrix_view.cc 69 polynomial_solver.cc 70 problem.cc 71 problem_impl.cc 72 program.cc 73 residual_block.cc 74 residual_block_utils.cc 75 runtime_numeric_diff_cost_function.cc 76 schur_complement_solver.cc 77 schur_eliminator.cc 78 scratch_evaluate_preparer.cc 79 solver.cc 80 solver_impl.cc 81 sparse_matrix.cc 82 sparse_normal_cholesky_solver.cc 83 split.cc 84 stringprintf.cc 85 suitesparse.cc 86 triplet_sparse_matrix.cc 87 trust_region_minimizer.cc 88 trust_region_strategy.cc 89 types.cc 90 visibility.cc 91 visibility_based_preconditioner.cc 92 wall_time.cc 93) 94 95If (${PROTOBUF_FOUND}) 96 PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS matrix.proto) 97ENDIF (${PROTOBUF_FOUND}) 98 99# Also depend on the header files so that they appear in IDEs. 100FILE(GLOB CERES_INTERNAL_HDRS *.h) 101 102# Include the specialized schur solvers. 103IF (${SCHUR_SPECIALIZATIONS}) 104 FILE(GLOB CERES_INTERNAL_SCHUR_FILES generated/*.cc) 105ELSE (${SCHUR_SPECIALIZATIONS}) 106 # Only the fully dynamic solver. The build is much faster this way. 107 FILE(GLOB CERES_INTERNAL_SCHUR_FILES generated/schur_eliminator_d_d_d.cc) 108ENDIF (${SCHUR_SPECIALIZATIONS}) 109 110# For Android, use the internal Glog implementation. 111IF (${BUILD_ANDROID}) 112 ADD_LIBRARY(miniglog STATIC 113 miniglog/glog/logging.cc) 114 115 # The Android logging library that defines e.g. __android_log_print is 116 # creatively named "log". 117 TARGET_LINK_LIBRARIES(miniglog log) 118 119 INSTALL(TARGETS miniglog 120 RUNTIME DESTINATION bin 121 LIBRARY DESTINATION lib 122 ARCHIVE DESTINATION lib) 123ENDIF (${BUILD_ANDROID}) 124 125SET(CERES_LIBRARY_DEPENDENCIES ${GLOG_LIB}) 126 127IF (${GFLAGS}) 128 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${GFLAGS_LIB}) 129ENDIF (${GFLAGS}) 130 131IF (${SUITESPARSE_FOUND}) 132 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${CHOLMOD_LIB}) 133 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${CCOLAMD_LIB}) 134 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${CAMD_LIB}) 135 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${COLAMD_LIB}) 136 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${AMD_LIB}) 137 IF (EXISTS ${SUITESPARSE_CONFIG_LIB}) 138 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${SUITESPARSE_CONFIG_LIB}) 139 ENDIF (EXISTS ${SUITESPARSE_CONFIG_LIB}) 140 141 IF (EXISTS ${METIS_LIB}) 142 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${METIS_LIB}) 143 ENDIF (EXISTS ${METIS_LIB}) 144 145 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${LAPACK_LIB}) 146 147 IF (EXISTS ${BLAS_LIB}) 148 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${BLAS_LIB}) 149 ENDIF (EXISTS ${BLAS_LIB}) 150ENDIF (${SUITESPARSE_FOUND}) 151 152IF (${CXSPARSE_FOUND}) 153 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${CXSPARSE_LIB}) 154ENDIF (${CXSPARSE_FOUND}) 155 156IF (${OPENMP_FOUND}) 157 IF (NOT MSVC) 158 LIST(APPEND CERES_LIBRARY_DEPENDENCIES gomp) 159 ENDIF (NOT MSVC) 160ENDIF (${OPENMP_FOUND}) 161 162IF (${PROTOBUF_FOUND}) 163 LIST(APPEND CERES_LIBRARY_DEPENDENCIES ${PROTOBUF_LIBRARY}) 164ENDIF (${PROTOBUF_FOUND}) 165 166SET(CERES_LIBRARY_SOURCE 167 ${PROTO_SRCS} 168 ${PROTO_HDRS} 169 ${CERES_INTERNAL_SRC} 170 ${CERES_INTERNAL_HDRS} 171 ${CERES_INTERNAL_SCHUR_FILES}) 172 173ADD_LIBRARY(ceres STATIC ${CERES_LIBRARY_SOURCE}) 174TARGET_LINK_LIBRARIES(ceres ${CERES_LIBRARY_DEPENDENCIES}) 175 176INSTALL(TARGETS ceres 177 RUNTIME DESTINATION bin 178 LIBRARY DESTINATION lib 179 ARCHIVE DESTINATION lib) 180 181# Don't build a DLL on MSVC. Supporting Ceres as a DLL on Windows involves 182# nontrivial changes that we haven't made yet. 183IF (NOT MSVC AND NOT ${BUILD_ANDROID}) 184 ADD_LIBRARY(ceres_shared SHARED ${CERES_LIBRARY_SOURCE}) 185 TARGET_LINK_LIBRARIES(ceres_shared ${CERES_LIBRARY_DEPENDENCIES}) 186 SET_TARGET_PROPERTIES(ceres_shared PROPERTIES 187 VERSION ${CERES_VERSION} 188 SOVERSION ${CERES_ABI_VERSION}) 189 190 INSTALL(TARGETS ceres_shared 191 RUNTIME DESTINATION bin 192 LIBRARY DESTINATION lib 193 ARCHIVE DESTINATION lib) 194 195ENDIF (NOT MSVC AND NOT ${BUILD_ANDROID}) 196 197IF (${BUILD_TESTING} AND ${GFLAGS}) 198 ADD_LIBRARY(gtest gmock_gtest_all.cc gmock_main.cc) 199 ADD_LIBRARY(test_util test_util.cc) 200 TARGET_LINK_LIBRARIES(gtest ${GFLAGS_LIB} ${GLOG_LIB}) 201 202 MACRO (CERES_TEST NAME) 203 ADD_EXECUTABLE(${NAME}_test ${NAME}_test.cc) 204 TARGET_LINK_LIBRARIES(${NAME}_test test_util ceres gtest) 205 ADD_TEST(NAME ${NAME}_test 206 COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${NAME}_test 207 --test_srcdir 208 ${CMAKE_SOURCE_DIR}/data) 209 ENDMACRO (CERES_TEST) 210 211 CERES_TEST(array_utils) 212 CERES_TEST(autodiff) 213 CERES_TEST(autodiff_cost_function) 214 CERES_TEST(block_random_access_dense_matrix) 215 CERES_TEST(block_random_access_sparse_matrix) 216 CERES_TEST(block_sparse_matrix) 217 CERES_TEST(canonical_views_clustering) 218 CERES_TEST(compressed_row_sparse_matrix) 219 CERES_TEST(conditioned_cost_function) 220 CERES_TEST(corrector) 221 CERES_TEST(dense_sparse_matrix) 222 CERES_TEST(evaluator) 223 CERES_TEST(gradient_checker) 224 CERES_TEST(gradient_checking_cost_function) 225 CERES_TEST(graph) 226 CERES_TEST(graph_algorithms) 227 CERES_TEST(implicit_schur_complement) 228 CERES_TEST(iterative_schur_complement_solver) 229 CERES_TEST(jet) 230 CERES_TEST(levenberg_marquardt_strategy) 231 CERES_TEST(dogleg_strategy) 232 CERES_TEST(local_parameterization) 233 CERES_TEST(loss_function) 234 CERES_TEST(minimizer) 235 CERES_TEST(normal_prior) 236 CERES_TEST(numeric_diff_cost_function) 237 CERES_TEST(ordered_groups) 238 CERES_TEST(parameter_block) 239 CERES_TEST(parameter_block_ordering) 240 CERES_TEST(partitioned_matrix_view) 241 CERES_TEST(polynomial_solver) 242 CERES_TEST(problem) 243 CERES_TEST(residual_block) 244 CERES_TEST(residual_block_utils) 245 CERES_TEST(rotation) 246 CERES_TEST(runtime_numeric_diff_cost_function) 247 CERES_TEST(schur_complement_solver) 248 CERES_TEST(schur_eliminator) 249 CERES_TEST(solver_impl) 250 251 IF (${SUITESPARSE_FOUND}) 252 CERES_TEST(suitesparse) 253 ENDIF (${SUITESPARSE_FOUND}) 254 255 CERES_TEST(symmetric_linear_solver) 256 CERES_TEST(triplet_sparse_matrix) 257 CERES_TEST(trust_region_minimizer) 258 CERES_TEST(unsymmetric_linear_solver) 259 CERES_TEST(visibility) 260 CERES_TEST(visibility_based_preconditioner) 261 262 # Put the large end to end test last. 263 CERES_TEST(system) 264ENDIF (${BUILD_TESTING} AND ${GFLAGS}) 265