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 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 191 | MESSAGE("-- Check for METIS (optional)") |
| 192 | FIND_LIBRARY(METIS_LIB NAMES metis PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 193 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 194 | IF (EXISTS ${METIS_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 195 | MESSAGE("-- Found METIS library: ${METIS_LIB}") |
| 196 | ELSE (EXISTS ${METIS_LIB}) |
| 197 | MESSAGE("-- Did not find METIS library") |
| 198 | ENDIF (EXISTS ${METIS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 199 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 200 | SET(BLAS_AND_LAPACK_FOUND TRUE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 201 | IF (${APPLE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 202 | # Mac OS X has LAPACK/BLAS bundled in a framework called |
| 203 | # "vecLib". Search for that instead of for the normal "lapack" |
| 204 | # library. |
| 205 | FIND_LIBRARY(LAPACK_LIB NAMES vecLib) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 206 | ELSE (${APPLE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 207 | FIND_LIBRARY(BLAS_LIB NAMES blas) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 208 | IF (EXISTS ${BLAS_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 209 | MESSAGE("-- Found BLAS library: ${BLAS_LIB}") |
| 210 | ELSE (EXISTS ${BLAS_LIB}) |
| 211 | MESSAGE("-- Did not find BLAS library") |
| 212 | SET(BLAS_AND_LAPACK_FOUND FALSE) |
| 213 | ENDIF (EXISTS ${BLAS_LIB}) |
| 214 | FIND_LIBRARY(LAPACK_LIB NAMES lapack) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 215 | ENDIF (${APPLE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 216 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 217 | IF (EXISTS ${LAPACK_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 218 | MESSAGE("-- Found LAPACK library: ${LAPACK_LIB}") |
| 219 | ELSE (EXISTS ${LAPACK_LIB}) |
| 220 | SET(BLAS_AND_LAPACK_FOUND FALSE) |
| 221 | MESSAGE("-- Did not find LAPACK library") |
| 222 | ENDIF (EXISTS ${LAPACK_LIB}) |
Keir Mierle | 92d5ab5 | 2012-05-01 18:33:08 -0700 | [diff] [blame] | 223 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 224 | SET(SUITESPARSE_FOUND |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 225 | ${AMD_FOUND} AND |
| 226 | ${CAMD_FOUND} AND |
| 227 | ${COLAMD_FOUND} AND |
| 228 | ${CCOLAMD_FOUND} AND |
| 229 | ${CHOLMOD_FOUND} AND |
| 230 | ${BLAS_AND_LAPACK_FOUND}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 231 | |
| 232 | # By default, if all of SuiteSparse's dependencies are found, Ceres is |
| 233 | # built with SuiteSparse support. -DSUITESPARSE=ON/OFF can be used to |
| 234 | # enable/disable SuiteSparse explicitly. |
| 235 | IF (DEFINED SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 236 | IF (${SUITESPARSE}) |
| 237 | IF (NOT ${SUITESPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 238 | 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] | 239 | ENDIF (NOT ${SUITESPARSE_FOUND}) |
| 240 | ELSE (${SUITESPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 241 | ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 242 | ENDIF (${SUITESPARSE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 243 | ELSE (DEFINED SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 244 | IF (${SUITESPARSE_FOUND}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 245 | MESSAGE("-- Found all SuiteSparse dependencies. Building with SuiteSparse") |
| 246 | SET(SUITESPARSE ON) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 247 | ELSE (${SUITESPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 248 | MESSAGE("-- Did not find all SuiteSparse dependencies. Building without SuiteSparse") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 249 | SET(SUITESPARSE OFF) |
| 250 | ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 251 | ENDIF (${SUITESPARSE_FOUND}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 252 | ENDIF (DEFINED SUITESPARSE) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 253 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 254 | # By default, if all of CXSparse's dependencies are found, Ceres is |
| 255 | # built with CXSparse support. -DCXSPARSE=ON/OFF can be used to |
| 256 | # enable/disable CXSparse explicitly. |
| 257 | MESSAGE("-- Check for CXSparse") |
| 258 | SET(CXSPARSE_FOUND ON) |
| 259 | |
| 260 | FIND_LIBRARY(CXSPARSE_LIB NAMES cxsparse PATHS ${CXSPARSE_SEARCH_LIBS}) |
| 261 | IF (EXISTS ${CXSPARSE_LIB}) |
| 262 | MESSAGE("-- Found CXSparse library in: ${CXSPARSE_LIB}") |
| 263 | ELSE (EXISTS ${CXSPARSE_LIB}) |
| 264 | MESSAGE("-- Did not find CXSparse header") |
| 265 | SET(CXSPARSE_FOUND FALSE) |
| 266 | ENDIF (EXISTS ${CXSPARSE_LIB}) |
| 267 | |
| 268 | FIND_PATH(CXSPARSE_INCLUDE NAMES cs.h PATHS ${CXSPARSE_SEARCH_HEADERS}) |
| 269 | IF (EXISTS ${CXSPARSE_INCLUDE}) |
| 270 | MESSAGE("-- Found CXSparse header in: ${CXSPARSE_INCLUDE}") |
| 271 | ELSE (EXISTS ${CXSPARSE_INCLUDE}) |
| 272 | MESSAGE("-- Did not find CXSparse header") |
| 273 | SET(CXSPARSE_FOUND FALSE) |
| 274 | ENDIF (EXISTS ${CXSPARSE_INCLUDE}) |
| 275 | |
| 276 | IF (DEFINED CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 277 | IF (${CXSPARSE}) |
| 278 | IF (NOT ${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 279 | MESSAGE(FATAL_ERROR "-- CXSparse not found.") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 280 | ENDIF (NOT ${CXSPARSE_FOUND}) |
| 281 | ELSE (${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 282 | ADD_DEFINITIONS(-DCERES_NO_CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 283 | ENDIF (${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 284 | ELSE (DEFINED CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 285 | IF (${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 286 | MESSAGE("-- Building with CXSparse support.") |
| 287 | SET(CXSPARSE ON) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 288 | ELSE (${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 289 | MESSAGE("-- Building without CXSparse.") |
| 290 | SET(CXSPARSE OFF) |
| 291 | ADD_DEFINITIONS(-DCERES_NO_CXSPARSE) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 292 | ENDIF (${CXSPARSE_FOUND}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 293 | ENDIF (DEFINED CXSPARSE) |
| 294 | |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 295 | # Google Flags |
| 296 | OPTION(GFLAGS |
| 297 | "Enable Google Flags." |
| 298 | ON) |
| 299 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 300 | IF (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 301 | MESSAGE("-- Check for Google Flags") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 302 | FIND_LIBRARY(GFLAGS_LIB NAMES gflags PATHS ${SEARCH_LIBS}) |
| 303 | IF (NOT EXISTS ${GFLAGS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 304 | MESSAGE(FATAL_ERROR |
| 305 | "Can't find Google Flags. Please specify: " |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 306 | "-DGFLAGS_LIB=...") |
| 307 | ENDIF (NOT EXISTS ${GFLAGS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 308 | MESSAGE("-- Found Google Flags library: ${GFLAGS_LIB}") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 309 | FIND_PATH(GFLAGS_INCLUDE NAMES gflags/gflags.h PATHS ${SEARCH_HEADERS}) |
| 310 | IF (NOT EXISTS ${GFLAGS_INCLUDE}) |
| 311 | MESSAGE(FATAL_ERROR |
| 312 | "Can't find Google Flags. Please specify: " |
| 313 | "-DGFLAGS_INCLUDE=...") |
| 314 | ENDIF (NOT EXISTS ${GFLAGS_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 315 | MESSAGE("-- Found Google Flags header in: ${GFLAGS_INCLUDE}") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 316 | ELSE (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 317 | MESSAGE("-- Google Flags disabled; no tests or tools will be built!") |
| 318 | ADD_DEFINITIONS(-DCERES_NO_GFLAGS) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 319 | ENDIF (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 320 | |
| 321 | # Google Logging |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 322 | IF (NOT ${BUILD_ANDROID}) |
| 323 | MESSAGE("-- Check for Google Log") |
| 324 | FIND_LIBRARY(GLOG_LIB NAMES glog PATHS ${SEARCH_LIBS}) |
| 325 | IF (NOT EXISTS ${GLOG_LIB}) |
| 326 | MESSAGE(FATAL_ERROR |
| 327 | "Can't find Google Log. Please specify: " |
| 328 | "-DGLOG_LIB=...") |
| 329 | ENDIF (NOT EXISTS ${GLOG_LIB}) |
| 330 | MESSAGE("-- Found Google Log library: ${GLOG_LIB}") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 331 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 332 | FIND_PATH(GLOG_INCLUDE NAMES glog/logging.h PATHS ${SEARCH_HEADERS}) |
| 333 | IF (NOT EXISTS ${GLOG_INCLUDE}) |
| 334 | MESSAGE(FATAL_ERROR |
| 335 | "Can't find Google Log. Please specify: " |
| 336 | "-DGLOG_INCLUDE=...") |
| 337 | ENDIF (NOT EXISTS ${GLOG_INCLUDE}) |
| 338 | MESSAGE("-- Found Google Log header in: ${GLOG_INCLUDE}") |
| 339 | ELSE (NOT ${BUILD_ANDROID}) |
| 340 | SET(GLOG_LIB miniglog) |
| 341 | MESSAGE("-- Using minimal Glog substitute for Android (library): ${GLOG_LIB}") |
| 342 | SET(GLOG_INCLUDE internal/ceres/miniglog) |
| 343 | MESSAGE("-- Using minimal Glog substitute for Android (include): ${GLOG_INCLUDE}") |
| 344 | ENDIF (NOT ${BUILD_ANDROID}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 345 | |
| 346 | # Eigen |
| 347 | MESSAGE("-- Check for Eigen 3.0") |
Keir Mierle | f477a38 | 2012-05-01 18:10:48 -0700 | [diff] [blame] | 348 | FIND_PATH(EIGEN_INCLUDE NAMES Eigen/Core PATHS ${EIGEN_SEARCH_HEADERS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 349 | IF (NOT EXISTS ${EIGEN_INCLUDE}) |
Keir Mierle | f477a38 | 2012-05-01 18:10:48 -0700 | [diff] [blame] | 350 | MESSAGE(FATAL_ERROR "Can't find Eigen. Try passing -DEIGEN_INCLUDE=...") |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 351 | ENDIF (NOT EXISTS ${EIGEN_INCLUDE}) |
| 352 | MESSAGE("-- Found Eigen 3.0: ${EIGEN_INCLUDE}") |
| 353 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 354 | # Template specializations for the Schur complement based solvers. If |
| 355 | # compile time, binary size or compiler performance is an issue, you |
| 356 | # may consider disabling this. |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 357 | OPTION(SCHUR_SPECIALIZATIONS |
| 358 | "Enable fixed-size schur specializations." |
| 359 | ON) |
| 360 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 361 | IF (NOT ${SCHUR_SPECIALIZATIONS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 362 | ADD_DEFINITIONS(-DCERES_RESTRICT_SCHUR_SPECIALIZATION) |
Keir Mierle | f10163a | 2012-05-04 21:33:53 -0700 | [diff] [blame] | 363 | MESSAGE("-- Disabling Schur specializations (faster compiles)") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 364 | ENDIF (NOT ${SCHUR_SPECIALIZATIONS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 365 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 366 | # Multithreading using OpenMP |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 367 | OPTION(OPENMP |
| 368 | "Enable threaded solving in Ceres (requires OpenMP)" |
| 369 | ON) |
| 370 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 371 | IF (${OPENMP}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 372 | FIND_PACKAGE(OpenMP) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 373 | IF(${OPENMP_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 374 | MESSAGE("-- Found OpenMP.") |
| 375 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") |
| 376 | ADD_DEFINITIONS(-DCERES_USE_OPENMP) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 377 | ELSE(${OPENMP_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 378 | MESSAGE("-- Can't find OpenMP. Continuing without it.") |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 379 | ENDIF(${OPENMP_FOUND}) |
| 380 | ENDIF (${OPENMP}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 381 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 382 | # Protocol buffers |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 383 | OPTION(PROTOBUF |
| 384 | "Enable protocol buffers support." |
| 385 | ON) |
| 386 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 387 | IF (${PROTOBUF}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 388 | FIND_PACKAGE(Protobuf) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 389 | IF (${PROTOBUF_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 390 | INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS}) |
| 391 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/internal) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 392 | ELSE (${PROTOBUF_FOUND}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 393 | ADD_DEFINITIONS(-DCERES_DONT_HAVE_PROTOCOL_BUFFERS) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 394 | ENDIF (${PROTOBUF_FOUND}) |
| 395 | ELSE (${PROTOBUF}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 396 | ADD_DEFINITIONS(-DCERES_DONT_HAVE_PROTOCOL_BUFFERS) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 397 | ENDIF (${PROTOBUF}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 398 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 399 | |
| 400 | # 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] | 401 | IF ("${UNIX}" AND NOT ${BUILD_ANDROID}) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 402 | # At least on Linux, we need pthreads to be enabled for mutex to compile. |
| 403 | # This may not work on windows or android. |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 404 | FIND_PACKAGE(Threads REQUIRED) |
| 405 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") |
| 406 | ADD_DEFINITIONS(-DCERES_HAVE_PTHREAD) |
| 407 | ADD_DEFINITIONS(-DCERES_HAVE_RWLOCK) |
Keir Mierle | 254f9d3 | 2012-08-02 21:18:49 -0700 | [diff] [blame] | 408 | ENDIF ("${UNIX}" AND NOT ${BUILD_ANDROID}) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 409 | |
| 410 | # Disable threads in mutex.h. Someday, after there is OpenMP support in |
| 411 | # Android, this can get removed. |
| 412 | IF (${BUILD_ANDROID}) |
Keir Mierle | ff71d74 | 2012-08-10 17:05:15 -0700 | [diff] [blame] | 413 | ADD_DEFINITIONS(-DCERES_NO_THREADS) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 414 | ENDIF (${BUILD_ANDROID}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 415 | |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 416 | # Use the std namespace for the hash<> and related templates. This may vary by |
| 417 | # system. |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 418 | IF (MSVC) |
| 419 | # This is known to work with Visual Studio 2010 Express. |
| 420 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std {\"") |
| 421 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}\"") |
| 422 | ELSE (MSVC) |
| 423 | # This is known to work with recent versions of Linux and Mac OS X. |
| 424 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"") |
| 425 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}}\"") |
| 426 | ENDIF (MSVC) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 427 | |
| 428 | INCLUDE_DIRECTORIES( |
| 429 | include |
| 430 | internal |
| 431 | internal/ceres |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 432 | ${GLOG_INCLUDE} |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 433 | ${EIGEN_INCLUDE} |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 434 | ) |
| 435 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 436 | IF (${SUITESPARSE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 437 | INCLUDE_DIRECTORIES(${CHOLMOD_INCLUDE}) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 438 | ENDIF(${SUITESPARSE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 439 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 440 | IF (${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 441 | INCLUDE_DIRECTORIES(${CXSPARSE_INCLUDE}) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 442 | ENDIF(${CXSPARSE}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 443 | |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 444 | IF (${GFLAGS}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 445 | INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE}) |
Sameer Agarwal | d114690 | 2012-05-30 01:40:22 -0700 | [diff] [blame] | 446 | ENDIF (${GFLAGS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 447 | |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 448 | # Change the default build type from Debug to Release, while still |
| 449 | # supporting overriding the build type. |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 450 | # |
| 451 | # The CACHE STRING logic here and elsewhere is needed to force CMake |
| 452 | # to pay attention to the value of these variables. |
| 453 | IF (NOT CMAKE_BUILD_TYPE) |
| 454 | MESSAGE("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.") |
| 455 | SET(CMAKE_BUILD_TYPE Release CACHE STRING |
| 456 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." |
| 457 | FORCE) |
| 458 | ELSE (NOT CMAKE_BUILD_TYPE) |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 459 | IF (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 460 | MESSAGE("\n=================================================================================") |
| 461 | MESSAGE("\n-- Build type: Debug. Performance will be terrible!") |
| 462 | MESSAGE("-- Add -DCMAKE_BUILD_TYPE=Release to the CMake command line to get an optimized build.") |
| 463 | MESSAGE("\n=================================================================================") |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 464 | ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug") |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 465 | ENDIF (NOT CMAKE_BUILD_TYPE) |
| 466 | |
| 467 | # Set the default Ceres flags to an empty string. |
| 468 | SET (CERES_CXX_FLAGS) |
| 469 | |
| 470 | IF (CMAKE_BUILD_TYPE STREQUAL "Release") |
| 471 | IF (CMAKE_COMPILER_IS_GNUCXX) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 472 | IF (${BUILD_ANDROID}) |
| 473 | # TODO(keir): Figure out what flags should go here to make an optimized |
| 474 | # native ARM binary for Android. |
| 475 | ELSE (${BUILD_ANDROID}) |
| 476 | # Linux |
| 477 | IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 478 | SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -march=native -mtune=native") |
| 479 | ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
| 480 | # Mac OS X |
| 481 | IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
| 482 | SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -fast -msse3") |
| 483 | ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
| 484 | ENDIF (${BUILD_ANDROID}) |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 485 | ENDIF (CMAKE_COMPILER_IS_GNUCXX) |
| 486 | SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CERES_CXX_FLAGS}" |
| 487 | CACHE STRING "Release mode flags to the C++ Compiler" FORCE) |
| 488 | ENDIF (CMAKE_BUILD_TYPE STREQUAL "Release") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 489 | |
| 490 | # After the tweaks for the compile settings, disable some warnings on MSVC. |
| 491 | IF (MSVC) |
| 492 | # Disable signed/unsigned int conversion warnings. |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 493 | ADD_DEFINITIONS("/wd4018") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 494 | # Disable warning about using struct/class for the same symobl. |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 495 | ADD_DEFINITIONS("/wd4099") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 496 | # Disable warning about the insecurity of using "std::copy". |
| 497 | ADD_DEFINITIONS("/wd4996") |
| 498 | # Disable performance warning about int-to-bool conversion. |
| 499 | ADD_DEFINITIONS("/wd4800") |
| 500 | # Disable performance warning about fopen insecurity. |
| 501 | ADD_DEFINITIONS("/wd4996") |
| 502 | # Disable warning about int64 to int32 conversion. Disabling |
| 503 | # this warning may not be correct; needs investigation. |
| 504 | # TODO(keir): Investigate these warnings in more detail. |
| 505 | ADD_DEFINITIONS("/wd4244") |
| 506 | # It's not possible to use STL types in DLL interfaces in a portable and |
| 507 | # reliable way. However, that's what happens with Google Log and Google Flags |
| 508 | # on Windows. MSVC gets upset about this and throws warnings that we can't do |
| 509 | # much about. The real solution is to link static versions of Google Log and |
| 510 | # Google Test, but that seems tricky on Windows. So, disable the warning. |
| 511 | ADD_DEFINITIONS("/wd4251") |
| 512 | |
| 513 | # Google Flags doesn't have their DLL import/export stuff set up correctly, |
| 514 | # which results in linker warnings. This is irrelevant for Ceres, so ignore |
| 515 | # the warnings. |
| 516 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049") |
| 517 | ENDIF (MSVC) |
| 518 | |
| 519 | ADD_SUBDIRECTORY(internal/ceres) |
| 520 | ADD_SUBDIRECTORY(examples) |
| 521 | |