Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 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 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 31 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 32 | |
| 33 | IF (COMMAND cmake_policy) |
| 34 | CMAKE_POLICY(SET CMP0003 NEW) |
| 35 | ENDIF (COMMAND cmake_policy) |
| 36 | |
| 37 | PROJECT(CERES C CXX) |
| 38 | |
Keir Mierle | 05107ba | 2012-07-18 13:50:12 -0700 | [diff] [blame] | 39 | # Important: Always bump the second number (e.g. 1.3.x to 1.4.0) for any |
| 40 | # release that changes the ABI. The ABI changes for almost any modification to |
| 41 | # include/ceres (e.g. the public API). If you are unsure about whether |
| 42 | # something is an ABI change, please ask on the list. |
| 43 | # |
| 44 | # For versions without ABI changes, bump the smallest number in CERES_VERSION, |
| 45 | # but leave the CERES_ABI_VERSION unchanged. |
| 46 | SET(CERES_VERSION 1.3.0) |
| 47 | SET(CERES_ABI_VERSION 1.3.0) |
| 48 | |
Sameer Agarwal | 30c5f93 | 2012-05-03 10:44:43 -0700 | [diff] [blame] | 49 | ENABLE_TESTING() |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 50 | |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 51 | OPTION(BUILD_TESTING |
| 52 | "Enable tests" |
| 53 | ON) |
| 54 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 55 | OPTION(BUILD_ANDROID |
| 56 | "Build for Android. Use build_android.sh instead of setting this." |
| 57 | OFF) |
| 58 | |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 59 | # To get a more static build, try the following line on Mac and Linux: |
| 60 | # SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 61 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 62 | # Default locations to search for on various platforms. |
| 63 | LIST(APPEND SEARCH_LIBS /usr/lib) |
| 64 | LIST(APPEND SEARCH_LIBS /usr/local/lib) |
| 65 | LIST(APPEND SEARCH_LIBS /usr/local/homebrew/lib) # Mac OS X |
| 66 | LIST(APPEND SEARCH_LIBS /opt/local/lib) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 67 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 68 | LIST(APPEND SEARCH_HEADERS /usr/include) |
| 69 | LIST(APPEND SEARCH_HEADERS /usr/local/include) |
| 70 | LIST(APPEND SEARCH_HEADERS /usr/local/homebrew/include) # Mac OS X |
| 71 | LIST(APPEND SEARCH_HEADERS /opt/local/include) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 72 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 73 | # Locations to search for Eigen |
| 74 | SET(EIGEN_SEARCH_HEADERS ${SEARCH_HEADERS}) |
| 75 | LIST(APPEND EIGEN_SEARCH_HEADERS /usr/include/eigen3) # Ubuntu 10.04's default location. |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 76 | LIST(APPEND EIGEN_SEARCH_HEADERS /usr/local/include/eigen3) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 77 | LIST(APPEND EIGEN_SEARCH_HEADERS /usr/local/homebrew/include/eigen3) # Mac OS X |
| 78 | LIST(APPEND EIGEN_SEARCH_HEADERS /opt/local/var/macports/software/eigen3/opt/local/include/eigen3) # Mac OS X |
| 79 | |
| 80 | # Locations to search for SuiteSparse |
| 81 | SET(SUITESPARSE_SEARCH_LIBS ${SEARCH_LIBS}) |
| 82 | LIST(APPEND SUITESPARSE_SEARCH_LIBS /usr/lib/suitesparse) # Ubuntu |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 83 | LIST(APPEND SUITESPARSE_SEARCH_LIBS /usr/local/lib/suitesparse) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 84 | LIST(APPEND SUITESPARSE_SEARCH_LIBS /opt/local/lib/ufsparse) # Mac OS X |
| 85 | |
| 86 | SET(SUITESPARSE_SEARCH_HEADERS ${SEARCH_HEADERS}) |
| 87 | LIST(APPEND SUITESPARSE_SEARCH_HEADERS /usr/include/suitesparse) # Ubuntu |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 88 | LIST(APPEND SUITESPARSE_SEARCH_HEADERS /usr/local/include/suitesparse) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 89 | LIST(APPEND SUITESPARSE_SEARCH_HEADERS /opt/local/include/ufsparse) # Mac OS X |
| 90 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 91 | SET(CXSPARSE_SEARCH_LIBS ${SEARCH_LIBS}) |
| 92 | SET(CXSPARSE_SEARCH_HEADERS ${SEARCH_HEADERS}) |
| 93 | LIST(APPEND CXSPARSE_SEARCH_HEADERS /usr/include/suitesparse) # Ubuntu |
| 94 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 95 | # Check for SuiteSparse dependencies |
| 96 | MESSAGE("-- Check for AMD") |
| 97 | SET(AMD_FOUND TRUE) |
| 98 | |
| 99 | FIND_LIBRARY(AMD_LIB NAMES amd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 100 | IF (EXISTS ${AMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 101 | MESSAGE("-- Found AMD library: ${AMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 102 | ELSE (EXISTS ${AMD_LIB}) |
| 103 | MESSAGE("-- Did not find AMD library") |
| 104 | SET(AMD_FOUND FALSE) |
| 105 | ENDIF (EXISTS ${AMD_LIB}) |
| 106 | |
| 107 | FIND_PATH(AMD_INCLUDE NAMES amd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 108 | IF (EXISTS ${AMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 109 | MESSAGE("-- Found AMD header in: ${AMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 110 | ELSE (EXISTS ${AMD_INCLUDE}) |
| 111 | MESSAGE("-- Did not find AMD header") |
| 112 | SET(AMD_FOUND FALSE) |
| 113 | ENDIF (EXISTS ${AMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 114 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 115 | MESSAGE("-- Check for CAMD") |
| 116 | SET(CAMD_FOUND TRUE) |
| 117 | |
| 118 | FIND_LIBRARY(CAMD_LIB NAMES camd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 119 | IF (EXISTS ${CAMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 120 | MESSAGE("-- Found CAMD library: ${CAMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 121 | ELSE (EXISTS ${CAMD_LIB}) |
| 122 | MESSAGE("-- Did not find CAMD library") |
| 123 | SET(CAMD_FOUND FALSE) |
| 124 | ENDIF (EXISTS ${CAMD_LIB}) |
| 125 | |
| 126 | FIND_PATH(CAMD_INCLUDE NAMES camd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 127 | IF (EXISTS ${CAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 128 | MESSAGE("-- Found CAMD header in: ${CAMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 129 | ELSE (EXISTS ${CAMD_INCLUDE}) |
| 130 | MESSAGE("-- Did not find CAMD header") |
| 131 | SET(CAMD_FOUND FALSE) |
| 132 | ENDIF (EXISTS ${CAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 133 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 134 | MESSAGE("-- Check for COLAMD") |
| 135 | SET(COLAMD_FOUND TRUE) |
| 136 | |
| 137 | FIND_LIBRARY(COLAMD_LIB NAMES colamd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 138 | IF (EXISTS ${COLAMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 139 | MESSAGE("-- Found COLAMD library: ${COLAMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 140 | ELSE (EXISTS ${COLAMD_LIB}) |
| 141 | MESSAGE("-- Did not find COLAMD library") |
| 142 | SET(COLAMD_FOUND FALSE) |
| 143 | ENDIF (EXISTS ${COLAMD_LIB}) |
| 144 | |
| 145 | FIND_PATH(COLAMD_INCLUDE NAMES colamd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 146 | IF (EXISTS ${COLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 147 | MESSAGE("-- Found COLAMD header in: ${COLAMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 148 | ELSE (EXISTS ${COLAMD_INCLUDE}) |
| 149 | MESSAGE("-- Did not find COLAMD header") |
| 150 | SET(COLAMD_FOUND FALSE) |
| 151 | ENDIF (EXISTS ${COLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 152 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 153 | MESSAGE("-- Check for CCOLAMD") |
| 154 | SET(CCOLAMD_FOUND TRUE) |
| 155 | |
| 156 | FIND_LIBRARY(CCOLAMD_LIB NAMES ccolamd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 157 | IF (EXISTS ${CCOLAMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 158 | MESSAGE("-- Found CCOLAMD library: ${CCOLAMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 159 | ELSE (EXISTS ${CCOLAMD_LIB}) |
| 160 | MESSAGE("-- Did not find CCOLAMD library") |
| 161 | SET(CCOLAMD_FOUND FALSE) |
| 162 | ENDIF (EXISTS ${CCOLAMD_LIB}) |
| 163 | |
| 164 | FIND_PATH(CCOLAMD_INCLUDE NAMES ccolamd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 165 | IF (EXISTS ${CCOLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 166 | MESSAGE("-- Found CCOLAMD header in: ${CCOLAMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 167 | ELSE (EXISTS ${CCOLAMD_INCLUDE}) |
| 168 | MESSAGE("-- Did not find CCOLAMD header") |
| 169 | SET(CCOLAMD_FOUND FALSE) |
| 170 | ENDIF (EXISTS ${CCOLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 171 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 172 | MESSAGE("-- Check for CHOLMOD") |
| 173 | SET(CHOLMOD_FOUND TRUE) |
| 174 | |
| 175 | FIND_LIBRARY(CHOLMOD_LIB NAMES cholmod PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 176 | IF (EXISTS ${CHOLMOD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 177 | MESSAGE("-- Found CHOLMOD library: ${CHOLMOD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 178 | ELSE (EXISTS ${CHOLMOD_LIB}) |
| 179 | MESSAGE("-- Did not find CHOLMOD library") |
| 180 | SET(CHOLMOD_FOUND FALSE) |
| 181 | ENDIF (EXISTS ${CHOLMOD_LIB}) |
| 182 | |
| 183 | FIND_PATH(CHOLMOD_INCLUDE NAMES cholmod.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 184 | IF (EXISTS ${CHOLMOD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 185 | MESSAGE("-- Found CHOLMOD header in: ${CHOLMOD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 186 | ELSE (EXISTS ${CHOLMOD_INCLUDE}) |
| 187 | MESSAGE("-- Did not find CHOLMOD header") |
| 188 | SET(CHOLMOD_FOUND FALSE) |
| 189 | ENDIF (EXISTS ${CHOLMOD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 190 | |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 191 | # If SuiteSparse version is >= 4 then SuiteSparse_config is required. |
| 192 | # For SuiteSparse 3, UFconfig.h is required. |
| 193 | MESSAGE("-- Check for SuiteSparse_config (SuiteSparse v4)") |
| 194 | SET(SUITESPARSE_CONFIG_FOUND TRUE) |
| 195 | |
| 196 | FIND_LIBRARY(SUITESPARSE_CONFIG_LIB |
| 197 | NAMES suitesparseconfig |
| 198 | PATHS ${SUITESPARSE_SEARCH_LIBS}) |
| 199 | IF (EXISTS ${SUITESPARSE_CONFIG_LIB}) |
| 200 | MESSAGE("-- Found SuiteSparse_config library: ${SUITESPARSE_CONFIG_LIB}") |
| 201 | ELSE (EXISTS ${SUITESPARSE_CONFIG_LIB}) |
| 202 | MESSAGE("-- Did not find SuiteSparse_config library") |
| 203 | ENDIF (EXISTS ${SUITESPARSE_CONFIG_LIB}) |
| 204 | |
| 205 | FIND_PATH(SUITESPARSE_CONFIG_INCLUDE |
| 206 | NAMES SuiteSparse_config.h |
Sameer Agarwal | 96f25dc | 2012-08-17 15:34:42 -0700 | [diff] [blame^] | 207 | PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 208 | IF (EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 209 | MESSAGE("-- Found SuiteSparse_config header in: ${SUITESPARSE_CONFIG_INCLUDE}") |
| 210 | ELSE (EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 211 | MESSAGE("-- Did not find SuiteSparse_config header") |
| 212 | ENDIF (EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 213 | |
| 214 | IF (NOT EXISTS ${SUITESPARSE_CONFIG_LIB} OR NOT EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 215 | SET(SUITESPARSE_CONFIG_FOUND FALSE) |
| 216 | ENDIF (NOT EXISTS ${SUITESPARSE_CONFIG_LIB} OR NOT EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 217 | |
| 218 | MESSAGE("-- Check for UFconfig (SuiteSparse v3)") |
| 219 | SET(UFCONFIG_FOUND TRUE) |
| 220 | |
| 221 | FIND_PATH(UFCONFIG_INCLUDE |
| 222 | NAMES UFconfig.h |
Sameer Agarwal | 96f25dc | 2012-08-17 15:34:42 -0700 | [diff] [blame^] | 223 | PATHS ${SUITESPARSE_SEARCH_INCLUDE}) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 224 | IF (EXISTS ${UFCONFIG_INCLUDE}) |
| 225 | MESSAGE("-- Found UFconfig header in: ${UFCONFIG_INCLUDE}") |
| 226 | ELSE (EXISTS ${UFCONFIG_INCLUDE}) |
| 227 | MESSAGE("-- Did not find UFconfig header") |
| 228 | SET(UFCONFIG_FOUND FALSE) |
| 229 | ENDIF (EXISTS ${UFCONFIG_INCLUDE}) |
| 230 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 231 | MESSAGE("-- Check for METIS (optional)") |
| 232 | FIND_LIBRARY(METIS_LIB NAMES metis PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 233 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 234 | IF (EXISTS ${METIS_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 235 | MESSAGE("-- Found METIS library: ${METIS_LIB}") |
| 236 | ELSE (EXISTS ${METIS_LIB}) |
| 237 | MESSAGE("-- Did not find METIS library") |
| 238 | ENDIF (EXISTS ${METIS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 239 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 240 | SET(BLAS_AND_LAPACK_FOUND TRUE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 241 | IF (${APPLE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 242 | # Mac OS X has LAPACK/BLAS bundled in a framework called |
| 243 | # "vecLib". Search for that instead of for the normal "lapack" |
| 244 | # library. |
| 245 | FIND_LIBRARY(LAPACK_LIB NAMES vecLib) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 246 | ELSE (${APPLE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 247 | FIND_LIBRARY(BLAS_LIB NAMES blas) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 248 | IF (EXISTS ${BLAS_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 249 | MESSAGE("-- Found BLAS library: ${BLAS_LIB}") |
| 250 | ELSE (EXISTS ${BLAS_LIB}) |
| 251 | MESSAGE("-- Did not find BLAS library") |
| 252 | SET(BLAS_AND_LAPACK_FOUND FALSE) |
| 253 | ENDIF (EXISTS ${BLAS_LIB}) |
| 254 | FIND_LIBRARY(LAPACK_LIB NAMES lapack) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 255 | ENDIF (${APPLE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 256 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 257 | IF (EXISTS ${LAPACK_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 258 | MESSAGE("-- Found LAPACK library: ${LAPACK_LIB}") |
| 259 | ELSE (EXISTS ${LAPACK_LIB}) |
| 260 | SET(BLAS_AND_LAPACK_FOUND FALSE) |
| 261 | MESSAGE("-- Did not find LAPACK library") |
| 262 | ENDIF (EXISTS ${LAPACK_LIB}) |
Keir Mierle | 92d5ab5 | 2012-05-01 18:33:08 -0700 | [diff] [blame] | 263 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 264 | SET(SUITESPARSE_FOUND |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 265 | ${AMD_FOUND} AND |
| 266 | ${CAMD_FOUND} AND |
| 267 | ${COLAMD_FOUND} AND |
| 268 | ${CCOLAMD_FOUND} AND |
| 269 | ${CHOLMOD_FOUND} AND |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 270 | (${SUITESPARSE_CONFIG_FOUND} OR ${UFCONFIG_FOUND}) AND |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 271 | ${BLAS_AND_LAPACK_FOUND}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 272 | |
| 273 | # By default, if all of SuiteSparse's dependencies are found, Ceres is |
| 274 | # built with SuiteSparse support. -DSUITESPARSE=ON/OFF can be used to |
| 275 | # enable/disable SuiteSparse explicitly. |
| 276 | IF (DEFINED SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 277 | IF (${SUITESPARSE}) |
| 278 | IF (NOT ${SUITESPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 279 | MESSAGE(FATAL_ERROR "One or more of SuiteSparse's dependencies was not found") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 280 | ENDIF (NOT ${SUITESPARSE_FOUND}) |
| 281 | ELSE (${SUITESPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 282 | ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 283 | ENDIF (${SUITESPARSE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 284 | ELSE (DEFINED SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 285 | IF (${SUITESPARSE_FOUND}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 286 | MESSAGE("-- Found all SuiteSparse dependencies. Building with SuiteSparse") |
| 287 | SET(SUITESPARSE ON) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 288 | ELSE (${SUITESPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 289 | MESSAGE("-- Did not find all SuiteSparse dependencies. Building without SuiteSparse") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 290 | SET(SUITESPARSE OFF) |
| 291 | ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 292 | ENDIF (${SUITESPARSE_FOUND}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 293 | ENDIF (DEFINED SUITESPARSE) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 294 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 295 | # By default, if all of CXSparse's dependencies are found, Ceres is |
| 296 | # built with CXSparse support. -DCXSPARSE=ON/OFF can be used to |
| 297 | # enable/disable CXSparse explicitly. |
| 298 | MESSAGE("-- Check for CXSparse") |
| 299 | SET(CXSPARSE_FOUND ON) |
| 300 | |
| 301 | FIND_LIBRARY(CXSPARSE_LIB NAMES cxsparse PATHS ${CXSPARSE_SEARCH_LIBS}) |
| 302 | IF (EXISTS ${CXSPARSE_LIB}) |
| 303 | MESSAGE("-- Found CXSparse library in: ${CXSPARSE_LIB}") |
| 304 | ELSE (EXISTS ${CXSPARSE_LIB}) |
| 305 | MESSAGE("-- Did not find CXSparse header") |
| 306 | SET(CXSPARSE_FOUND FALSE) |
| 307 | ENDIF (EXISTS ${CXSPARSE_LIB}) |
| 308 | |
| 309 | FIND_PATH(CXSPARSE_INCLUDE NAMES cs.h PATHS ${CXSPARSE_SEARCH_HEADERS}) |
| 310 | IF (EXISTS ${CXSPARSE_INCLUDE}) |
| 311 | MESSAGE("-- Found CXSparse header in: ${CXSPARSE_INCLUDE}") |
| 312 | ELSE (EXISTS ${CXSPARSE_INCLUDE}) |
| 313 | MESSAGE("-- Did not find CXSparse header") |
| 314 | SET(CXSPARSE_FOUND FALSE) |
| 315 | ENDIF (EXISTS ${CXSPARSE_INCLUDE}) |
| 316 | |
| 317 | IF (DEFINED CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 318 | IF (${CXSPARSE}) |
| 319 | IF (NOT ${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 320 | MESSAGE(FATAL_ERROR "-- CXSparse not found.") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 321 | ENDIF (NOT ${CXSPARSE_FOUND}) |
| 322 | ELSE (${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 323 | ADD_DEFINITIONS(-DCERES_NO_CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 324 | ENDIF (${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 325 | ELSE (DEFINED CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 326 | IF (${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 327 | MESSAGE("-- Building with CXSparse support.") |
| 328 | SET(CXSPARSE ON) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 329 | ELSE (${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 330 | MESSAGE("-- Building without CXSparse.") |
| 331 | SET(CXSPARSE OFF) |
| 332 | ADD_DEFINITIONS(-DCERES_NO_CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 333 | ENDIF (${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 334 | ENDIF (DEFINED CXSPARSE) |
| 335 | |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 336 | # Google Flags |
| 337 | OPTION(GFLAGS |
| 338 | "Enable Google Flags." |
| 339 | ON) |
| 340 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 341 | IF (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 342 | MESSAGE("-- Check for Google Flags") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 343 | FIND_LIBRARY(GFLAGS_LIB NAMES gflags PATHS ${SEARCH_LIBS}) |
| 344 | IF (NOT EXISTS ${GFLAGS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 345 | MESSAGE(FATAL_ERROR |
| 346 | "Can't find Google Flags. Please specify: " |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 347 | "-DGFLAGS_LIB=...") |
| 348 | ENDIF (NOT EXISTS ${GFLAGS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 349 | MESSAGE("-- Found Google Flags library: ${GFLAGS_LIB}") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 350 | FIND_PATH(GFLAGS_INCLUDE NAMES gflags/gflags.h PATHS ${SEARCH_HEADERS}) |
| 351 | IF (NOT EXISTS ${GFLAGS_INCLUDE}) |
| 352 | MESSAGE(FATAL_ERROR |
| 353 | "Can't find Google Flags. Please specify: " |
| 354 | "-DGFLAGS_INCLUDE=...") |
| 355 | ENDIF (NOT EXISTS ${GFLAGS_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 356 | MESSAGE("-- Found Google Flags header in: ${GFLAGS_INCLUDE}") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 357 | ELSE (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 358 | MESSAGE("-- Google Flags disabled; no tests or tools will be built!") |
| 359 | ADD_DEFINITIONS(-DCERES_NO_GFLAGS) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 360 | ENDIF (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 361 | |
| 362 | # Google Logging |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 363 | IF (NOT ${BUILD_ANDROID}) |
| 364 | MESSAGE("-- Check for Google Log") |
| 365 | FIND_LIBRARY(GLOG_LIB NAMES glog PATHS ${SEARCH_LIBS}) |
| 366 | IF (NOT EXISTS ${GLOG_LIB}) |
| 367 | MESSAGE(FATAL_ERROR |
| 368 | "Can't find Google Log. Please specify: " |
| 369 | "-DGLOG_LIB=...") |
| 370 | ENDIF (NOT EXISTS ${GLOG_LIB}) |
| 371 | MESSAGE("-- Found Google Log library: ${GLOG_LIB}") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 372 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 373 | FIND_PATH(GLOG_INCLUDE NAMES glog/logging.h PATHS ${SEARCH_HEADERS}) |
| 374 | IF (NOT EXISTS ${GLOG_INCLUDE}) |
| 375 | MESSAGE(FATAL_ERROR |
| 376 | "Can't find Google Log. Please specify: " |
| 377 | "-DGLOG_INCLUDE=...") |
| 378 | ENDIF (NOT EXISTS ${GLOG_INCLUDE}) |
| 379 | MESSAGE("-- Found Google Log header in: ${GLOG_INCLUDE}") |
| 380 | ELSE (NOT ${BUILD_ANDROID}) |
| 381 | SET(GLOG_LIB miniglog) |
| 382 | MESSAGE("-- Using minimal Glog substitute for Android (library): ${GLOG_LIB}") |
| 383 | SET(GLOG_INCLUDE internal/ceres/miniglog) |
| 384 | MESSAGE("-- Using minimal Glog substitute for Android (include): ${GLOG_INCLUDE}") |
| 385 | ENDIF (NOT ${BUILD_ANDROID}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 386 | |
| 387 | # Eigen |
| 388 | MESSAGE("-- Check for Eigen 3.0") |
Keir Mierle | f477a38 | 2012-05-01 18:10:48 -0700 | [diff] [blame] | 389 | FIND_PATH(EIGEN_INCLUDE NAMES Eigen/Core PATHS ${EIGEN_SEARCH_HEADERS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 390 | IF (NOT EXISTS ${EIGEN_INCLUDE}) |
Keir Mierle | f477a38 | 2012-05-01 18:10:48 -0700 | [diff] [blame] | 391 | MESSAGE(FATAL_ERROR "Can't find Eigen. Try passing -DEIGEN_INCLUDE=...") |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 392 | ENDIF (NOT EXISTS ${EIGEN_INCLUDE}) |
| 393 | MESSAGE("-- Found Eigen 3.0: ${EIGEN_INCLUDE}") |
| 394 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 395 | # Template specializations for the Schur complement based solvers. If |
| 396 | # compile time, binary size or compiler performance is an issue, you |
| 397 | # may consider disabling this. |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 398 | OPTION(SCHUR_SPECIALIZATIONS |
| 399 | "Enable fixed-size schur specializations." |
| 400 | ON) |
| 401 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 402 | IF (NOT ${SCHUR_SPECIALIZATIONS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 403 | ADD_DEFINITIONS(-DCERES_RESTRICT_SCHUR_SPECIALIZATION) |
Keir Mierle | f10163a | 2012-05-04 21:33:53 -0700 | [diff] [blame] | 404 | MESSAGE("-- Disabling Schur specializations (faster compiles)") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 405 | ENDIF (NOT ${SCHUR_SPECIALIZATIONS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 406 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 407 | # Multithreading using OpenMP |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 408 | OPTION(OPENMP |
| 409 | "Enable threaded solving in Ceres (requires OpenMP)" |
| 410 | ON) |
| 411 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 412 | IF (${OPENMP}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 413 | FIND_PACKAGE(OpenMP) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 414 | IF(${OPENMP_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 415 | MESSAGE("-- Found OpenMP.") |
| 416 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") |
| 417 | ADD_DEFINITIONS(-DCERES_USE_OPENMP) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 418 | ELSE(${OPENMP_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 419 | MESSAGE("-- Can't find OpenMP. Continuing without it.") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 420 | ENDIF(${OPENMP_FOUND}) |
| 421 | ENDIF (${OPENMP}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 422 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 423 | # Protocol buffers |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 424 | OPTION(PROTOBUF |
| 425 | "Enable protocol buffers support." |
| 426 | ON) |
| 427 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 428 | IF (${PROTOBUF}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 429 | FIND_PACKAGE(Protobuf) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 430 | IF (${PROTOBUF_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 431 | INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS}) |
| 432 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/internal) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 433 | ELSE (${PROTOBUF_FOUND}) |
Sameer Agarwal | dd2b17d | 2012-08-16 19:34:57 -0700 | [diff] [blame] | 434 | ADD_DEFINITIONS(-DCERES_NO_PROTOCOL_BUFFERS) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 435 | ENDIF (${PROTOBUF_FOUND}) |
| 436 | ELSE (${PROTOBUF}) |
Sameer Agarwal | dd2b17d | 2012-08-16 19:34:57 -0700 | [diff] [blame] | 437 | ADD_DEFINITIONS(-DCERES_NO_PROTOCOL_BUFFERS) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 438 | ENDIF (${PROTOBUF}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 439 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 440 | |
| 441 | # Use threads but not on Android, where there is no support for OpenMP yet. |
Keir Mierle | 254f9d3 | 2012-08-02 21:18:49 -0700 | [diff] [blame] | 442 | IF ("${UNIX}" AND NOT ${BUILD_ANDROID}) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 443 | # At least on Linux, we need pthreads to be enabled for mutex to compile. |
| 444 | # This may not work on windows or android. |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 445 | FIND_PACKAGE(Threads REQUIRED) |
| 446 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") |
| 447 | ADD_DEFINITIONS(-DCERES_HAVE_PTHREAD) |
| 448 | ADD_DEFINITIONS(-DCERES_HAVE_RWLOCK) |
Keir Mierle | 254f9d3 | 2012-08-02 21:18:49 -0700 | [diff] [blame] | 449 | ENDIF ("${UNIX}" AND NOT ${BUILD_ANDROID}) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 450 | |
| 451 | # Disable threads in mutex.h. Someday, after there is OpenMP support in |
| 452 | # Android, this can get removed. |
| 453 | IF (${BUILD_ANDROID}) |
Keir Mierle | ff71d74 | 2012-08-10 17:05:15 -0700 | [diff] [blame] | 454 | ADD_DEFINITIONS(-DCERES_NO_THREADS) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 455 | ENDIF (${BUILD_ANDROID}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 456 | |
Keir Mierle | d216490 | 2012-08-15 19:04:50 -0700 | [diff] [blame] | 457 | OPTION(DISABLE_TR1 |
| 458 | "Don't use TR1. This replaces some hash tables with sets. Slower." |
| 459 | OFF) |
| 460 | |
| 461 | IF (${DISABLE_TR1}) |
| 462 | MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)") |
| 463 | ADD_DEFINITIONS(-DCERES_NO_TR1) |
| 464 | ELSE (${DISABLE_TR1}) |
| 465 | MESSAGE("-- Using normal TR1 unordered_map/set") |
| 466 | # Use the std namespace for the hash<> and related templates. This may vary by |
| 467 | # system. |
| 468 | IF (MSVC) |
| 469 | # This is known to work with Visual Studio 2010 Express. |
| 470 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std {\"") |
| 471 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}\"") |
| 472 | ELSE (MSVC) |
| 473 | # This is known to work with recent versions of Linux and Mac OS X. |
| 474 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"") |
| 475 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}}\"") |
| 476 | ENDIF (MSVC) |
| 477 | ENDIF (${DISABLE_TR1}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 478 | |
| 479 | INCLUDE_DIRECTORIES( |
| 480 | include |
| 481 | internal |
| 482 | internal/ceres |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 483 | ${GLOG_INCLUDE} |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 484 | ${EIGEN_INCLUDE} |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 485 | ) |
| 486 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 487 | IF (${SUITESPARSE}) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 488 | INCLUDE_DIRECTORIES(${AMD_INCLUDE}) |
| 489 | INCLUDE_DIRECTORIES(${CAMD_INCLUDE}) |
| 490 | INCLUDE_DIRECTORIES(${COLAMD_INCLUDE}) |
| 491 | INCLUDE_DIRECTORIES(${CCOLAMD_INCLUDE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 492 | INCLUDE_DIRECTORIES(${CHOLMOD_INCLUDE}) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 493 | IF (${SUITESPARSE_CONFIG_FOUND}) |
| 494 | INCLUDE_DIRECTORIES(${SUITESPARSE_CONFIG_INCLUDE}) |
| 495 | ENDIF (${SUITESPARSE_CONFIG_FOUND}) |
| 496 | IF (${UFCONFIG_FOUND}) |
| 497 | INCLUDE_DIRECTORIES(${UFCONFIG_INCLUDE}) |
| 498 | ENDIF (${UFCONFIG_FOUND}) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 499 | ENDIF(${SUITESPARSE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 500 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 501 | IF (${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 502 | INCLUDE_DIRECTORIES(${CXSPARSE_INCLUDE}) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 503 | ENDIF(${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 504 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 505 | IF (${GFLAGS}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 506 | INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE}) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 507 | ENDIF (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 508 | |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 509 | # Change the default build type from Debug to Release, while still |
| 510 | # supporting overriding the build type. |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 511 | # |
| 512 | # The CACHE STRING logic here and elsewhere is needed to force CMake |
| 513 | # to pay attention to the value of these variables. |
| 514 | IF (NOT CMAKE_BUILD_TYPE) |
| 515 | MESSAGE("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.") |
| 516 | SET(CMAKE_BUILD_TYPE Release CACHE STRING |
| 517 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." |
| 518 | FORCE) |
| 519 | ELSE (NOT CMAKE_BUILD_TYPE) |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 520 | IF (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 521 | MESSAGE("\n=================================================================================") |
| 522 | MESSAGE("\n-- Build type: Debug. Performance will be terrible!") |
| 523 | MESSAGE("-- Add -DCMAKE_BUILD_TYPE=Release to the CMake command line to get an optimized build.") |
| 524 | MESSAGE("\n=================================================================================") |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 525 | ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug") |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 526 | ENDIF (NOT CMAKE_BUILD_TYPE) |
| 527 | |
| 528 | # Set the default Ceres flags to an empty string. |
| 529 | SET (CERES_CXX_FLAGS) |
| 530 | |
| 531 | IF (CMAKE_BUILD_TYPE STREQUAL "Release") |
| 532 | IF (CMAKE_COMPILER_IS_GNUCXX) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 533 | IF (${BUILD_ANDROID}) |
| 534 | # TODO(keir): Figure out what flags should go here to make an optimized |
| 535 | # native ARM binary for Android. |
| 536 | ELSE (${BUILD_ANDROID}) |
| 537 | # Linux |
| 538 | IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 539 | SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -march=native -mtune=native") |
| 540 | ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 541 | # Mac OS X |
| 542 | IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
| 543 | SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -fast -msse3") |
| 544 | ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
| 545 | ENDIF (${BUILD_ANDROID}) |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 546 | ENDIF (CMAKE_COMPILER_IS_GNUCXX) |
| 547 | SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CERES_CXX_FLAGS}" |
| 548 | CACHE STRING "Release mode flags to the C++ Compiler" FORCE) |
| 549 | ENDIF (CMAKE_BUILD_TYPE STREQUAL "Release") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 550 | |
| 551 | # After the tweaks for the compile settings, disable some warnings on MSVC. |
| 552 | IF (MSVC) |
| 553 | # Disable signed/unsigned int conversion warnings. |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 554 | ADD_DEFINITIONS("/wd4018") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 555 | # Disable warning about using struct/class for the same symobl. |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 556 | ADD_DEFINITIONS("/wd4099") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 557 | # Disable warning about the insecurity of using "std::copy". |
| 558 | ADD_DEFINITIONS("/wd4996") |
| 559 | # Disable performance warning about int-to-bool conversion. |
| 560 | ADD_DEFINITIONS("/wd4800") |
| 561 | # Disable performance warning about fopen insecurity. |
| 562 | ADD_DEFINITIONS("/wd4996") |
| 563 | # Disable warning about int64 to int32 conversion. Disabling |
| 564 | # this warning may not be correct; needs investigation. |
| 565 | # TODO(keir): Investigate these warnings in more detail. |
| 566 | ADD_DEFINITIONS("/wd4244") |
| 567 | # It's not possible to use STL types in DLL interfaces in a portable and |
| 568 | # reliable way. However, that's what happens with Google Log and Google Flags |
| 569 | # on Windows. MSVC gets upset about this and throws warnings that we can't do |
| 570 | # much about. The real solution is to link static versions of Google Log and |
| 571 | # Google Test, but that seems tricky on Windows. So, disable the warning. |
| 572 | ADD_DEFINITIONS("/wd4251") |
| 573 | |
| 574 | # Google Flags doesn't have their DLL import/export stuff set up correctly, |
| 575 | # which results in linker warnings. This is irrelevant for Ceres, so ignore |
| 576 | # the warnings. |
| 577 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049") |
| 578 | ENDIF (MSVC) |
| 579 | |
| 580 | ADD_SUBDIRECTORY(internal/ceres) |
| 581 | ADD_SUBDIRECTORY(examples) |