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) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 32 | CMAKE_POLICY(VERSION 2.8) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 33 | |
| 34 | IF (COMMAND cmake_policy) |
| 35 | CMAKE_POLICY(SET CMP0003 NEW) |
| 36 | ENDIF (COMMAND cmake_policy) |
| 37 | |
| 38 | PROJECT(CERES C CXX) |
| 39 | |
Arnaud Gelas | d2fb5ad | 2012-08-17 10:11:02 +0200 | [diff] [blame] | 40 | # Set up the git hook to make Gerrit Change-Id: lines in commit messages. |
| 41 | SET (LOCAL_GIT_DIRECTORY) |
| 42 | IF (EXISTS ${CMAKE_SOURCE_DIR}/.git) |
| 43 | # .git directory can be found on Unix based system, or on Windows with |
| 44 | # Git Bash (shipped with msysgit) |
| 45 | SET (LOCAL_GIT_DIRECTORY ${CMAKE_SOURCE_DIR}/.git) |
| 46 | ELSE (EXISTS ${CMAKE_SOURCE_DIR}/.git) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 47 | # TODO(keir) Add proper Windows support |
Arnaud Gelas | d2fb5ad | 2012-08-17 10:11:02 +0200 | [diff] [blame] | 48 | ENDIF (EXISTS ${CMAKE_SOURCE_DIR}/.git) |
| 49 | |
| 50 | IF (EXISTS ${LOCAL_GIT_DIRECTORY}) |
| 51 | IF (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) |
| 52 | # Download the hook only if it is not already present |
| 53 | FILE(DOWNLOAD https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg |
| 54 | ${CMAKE_BINARY_DIR}/commit-msg) |
| 55 | |
| 56 | # Make the downloaded file executable, since it is not by default. |
| 57 | FILE(COPY ${CMAKE_BINARY_DIR}/commit-msg |
| 58 | DESTINATION ${LOCAL_GIT_DIRECTORY}/hooks/ |
| 59 | FILE_PERMISSIONS |
| 60 | OWNER_READ OWNER_WRITE OWNER_EXECUTE |
| 61 | GROUP_READ GROUP_WRITE GROUP_EXECUTE |
| 62 | WORLD_READ WORLD_EXECUTE) |
| 63 | ENDIF (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg) |
| 64 | ENDIF (EXISTS ${LOCAL_GIT_DIRECTORY}) |
| 65 | |
Arnaud Gelas | b3fa009 | 2012-08-17 10:31:41 +0200 | [diff] [blame] | 66 | SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 67 | SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 68 | SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 69 | |
Keir Mierle | 05107ba | 2012-07-18 13:50:12 -0700 | [diff] [blame] | 70 | # Important: Always bump the second number (e.g. 1.3.x to 1.4.0) for any |
| 71 | # release that changes the ABI. The ABI changes for almost any modification to |
| 72 | # include/ceres (e.g. the public API). If you are unsure about whether |
| 73 | # something is an ABI change, please ask on the list. |
| 74 | # |
| 75 | # For versions without ABI changes, bump the smallest number in CERES_VERSION, |
| 76 | # but leave the CERES_ABI_VERSION unchanged. |
Pablo Speciale | c51b11c | 2013-03-12 00:56:56 -0700 | [diff] [blame] | 77 | SET(CERES_VERSION_MAJOR 1) |
Sameer Agarwal | 937777a | 2013-04-29 13:57:28 -0700 | [diff] [blame] | 78 | SET(CERES_VERSION_MINOR 6) |
Pablo Speciale | c51b11c | 2013-03-12 00:56:56 -0700 | [diff] [blame] | 79 | SET(CERES_VERSION_PATCH 0) |
| 80 | SET(CERES_VERSION |
| 81 | ${CERES_VERSION_MAJOR}.${CERES_VERSION_MINOR}.${CERES_VERSION_PATCH}) |
Sameer Agarwal | 937777a | 2013-04-29 13:57:28 -0700 | [diff] [blame] | 82 | SET(CERES_ABI_VERSION 1.6.0) |
Keir Mierle | 05107ba | 2012-07-18 13:50:12 -0700 | [diff] [blame] | 83 | |
Sameer Agarwal | 30c5f93 | 2012-05-03 10:44:43 -0700 | [diff] [blame] | 84 | ENABLE_TESTING() |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 85 | |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 86 | OPTION(BUILD_TESTING |
| 87 | "Enable tests" |
| 88 | ON) |
| 89 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 90 | OPTION(BUILD_ANDROID |
| 91 | "Build for Android. Use build_android.sh instead of setting this." |
| 92 | OFF) |
| 93 | |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 94 | # To get a more static build, try the following line on Mac and Linux: |
| 95 | # SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 96 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 97 | # Default locations to search for on various platforms. |
| 98 | LIST(APPEND SEARCH_LIBS /usr/lib) |
| 99 | LIST(APPEND SEARCH_LIBS /usr/local/lib) |
| 100 | LIST(APPEND SEARCH_LIBS /usr/local/homebrew/lib) # Mac OS X |
| 101 | LIST(APPEND SEARCH_LIBS /opt/local/lib) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 102 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 103 | LIST(APPEND SEARCH_HEADERS /usr/include) |
| 104 | LIST(APPEND SEARCH_HEADERS /usr/local/include) |
| 105 | LIST(APPEND SEARCH_HEADERS /usr/local/homebrew/include) # Mac OS X |
| 106 | LIST(APPEND SEARCH_HEADERS /opt/local/include) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 107 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 108 | # Locations to search for Eigen |
| 109 | SET(EIGEN_SEARCH_HEADERS ${SEARCH_HEADERS}) |
| 110 | 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] | 111 | LIST(APPEND EIGEN_SEARCH_HEADERS /usr/local/include/eigen3) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 112 | LIST(APPEND EIGEN_SEARCH_HEADERS /usr/local/homebrew/include/eigen3) # Mac OS X |
| 113 | LIST(APPEND EIGEN_SEARCH_HEADERS /opt/local/var/macports/software/eigen3/opt/local/include/eigen3) # Mac OS X |
| 114 | |
| 115 | # Locations to search for SuiteSparse |
| 116 | SET(SUITESPARSE_SEARCH_LIBS ${SEARCH_LIBS}) |
| 117 | LIST(APPEND SUITESPARSE_SEARCH_LIBS /usr/lib/suitesparse) # Ubuntu |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 118 | LIST(APPEND SUITESPARSE_SEARCH_LIBS /usr/local/lib/suitesparse) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 119 | LIST(APPEND SUITESPARSE_SEARCH_LIBS /opt/local/lib/ufsparse) # Mac OS X |
| 120 | |
| 121 | SET(SUITESPARSE_SEARCH_HEADERS ${SEARCH_HEADERS}) |
| 122 | LIST(APPEND SUITESPARSE_SEARCH_HEADERS /usr/include/suitesparse) # Ubuntu |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 123 | LIST(APPEND SUITESPARSE_SEARCH_HEADERS /usr/local/include/suitesparse) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 124 | LIST(APPEND SUITESPARSE_SEARCH_HEADERS /opt/local/include/ufsparse) # Mac OS X |
| 125 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 126 | SET(CXSPARSE_SEARCH_LIBS ${SEARCH_LIBS}) |
| 127 | SET(CXSPARSE_SEARCH_HEADERS ${SEARCH_HEADERS}) |
| 128 | LIST(APPEND CXSPARSE_SEARCH_HEADERS /usr/include/suitesparse) # Ubuntu |
| 129 | |
Sameer Agarwal | 8140f0f | 2013-03-12 09:45:08 -0700 | [diff] [blame] | 130 | IF ((NOT DEFINED SUITESPARSE) OR (DEFINED SUITESPARSE AND SUITESPARSE)) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 131 | # Check for SuiteSparse dependencies |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 132 | |
Sameer Agarwal | bd82f82 | 2013-07-09 23:19:09 -0700 | [diff] [blame] | 133 | SET(AMD_FOUND TRUE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 134 | FIND_LIBRARY(AMD_LIB NAMES amd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 135 | IF (EXISTS ${AMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 136 | MESSAGE("-- Found AMD library: ${AMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 137 | ELSE (EXISTS ${AMD_LIB}) |
| 138 | MESSAGE("-- Did not find AMD library") |
| 139 | SET(AMD_FOUND FALSE) |
| 140 | ENDIF (EXISTS ${AMD_LIB}) |
| 141 | |
| 142 | FIND_PATH(AMD_INCLUDE NAMES amd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 143 | IF (EXISTS ${AMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 144 | MESSAGE("-- Found AMD header in: ${AMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 145 | ELSE (EXISTS ${AMD_INCLUDE}) |
| 146 | MESSAGE("-- Did not find AMD header") |
| 147 | SET(AMD_FOUND FALSE) |
| 148 | ENDIF (EXISTS ${AMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 149 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 150 | SET(CAMD_FOUND TRUE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 151 | FIND_LIBRARY(CAMD_LIB NAMES camd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 152 | IF (EXISTS ${CAMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 153 | MESSAGE("-- Found CAMD library: ${CAMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 154 | ELSE (EXISTS ${CAMD_LIB}) |
| 155 | MESSAGE("-- Did not find CAMD library") |
| 156 | SET(CAMD_FOUND FALSE) |
| 157 | ENDIF (EXISTS ${CAMD_LIB}) |
| 158 | |
| 159 | FIND_PATH(CAMD_INCLUDE NAMES camd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 160 | IF (EXISTS ${CAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 161 | MESSAGE("-- Found CAMD header in: ${CAMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 162 | ELSE (EXISTS ${CAMD_INCLUDE}) |
| 163 | MESSAGE("-- Did not find CAMD header") |
| 164 | SET(CAMD_FOUND FALSE) |
| 165 | ENDIF (EXISTS ${CAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 166 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 167 | SET(COLAMD_FOUND TRUE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 168 | FIND_LIBRARY(COLAMD_LIB NAMES colamd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 169 | IF (EXISTS ${COLAMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 170 | MESSAGE("-- Found COLAMD library: ${COLAMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 171 | ELSE (EXISTS ${COLAMD_LIB}) |
| 172 | MESSAGE("-- Did not find COLAMD library") |
| 173 | SET(COLAMD_FOUND FALSE) |
| 174 | ENDIF (EXISTS ${COLAMD_LIB}) |
| 175 | |
| 176 | FIND_PATH(COLAMD_INCLUDE NAMES colamd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 177 | IF (EXISTS ${COLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 178 | MESSAGE("-- Found COLAMD header in: ${COLAMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 179 | ELSE (EXISTS ${COLAMD_INCLUDE}) |
| 180 | MESSAGE("-- Did not find COLAMD header") |
| 181 | SET(COLAMD_FOUND FALSE) |
| 182 | ENDIF (EXISTS ${COLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 183 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 184 | SET(CCOLAMD_FOUND TRUE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 185 | FIND_LIBRARY(CCOLAMD_LIB NAMES ccolamd PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 186 | IF (EXISTS ${CCOLAMD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 187 | MESSAGE("-- Found CCOLAMD library: ${CCOLAMD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 188 | ELSE (EXISTS ${CCOLAMD_LIB}) |
| 189 | MESSAGE("-- Did not find CCOLAMD library") |
| 190 | SET(CCOLAMD_FOUND FALSE) |
| 191 | ENDIF (EXISTS ${CCOLAMD_LIB}) |
| 192 | |
| 193 | FIND_PATH(CCOLAMD_INCLUDE NAMES ccolamd.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 194 | IF (EXISTS ${CCOLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 195 | MESSAGE("-- Found CCOLAMD header in: ${CCOLAMD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 196 | ELSE (EXISTS ${CCOLAMD_INCLUDE}) |
| 197 | MESSAGE("-- Did not find CCOLAMD header") |
| 198 | SET(CCOLAMD_FOUND FALSE) |
| 199 | ENDIF (EXISTS ${CCOLAMD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 200 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 201 | SET(CHOLMOD_FOUND TRUE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 202 | FIND_LIBRARY(CHOLMOD_LIB NAMES cholmod PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 203 | IF (EXISTS ${CHOLMOD_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 204 | MESSAGE("-- Found CHOLMOD library: ${CHOLMOD_LIB}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 205 | ELSE (EXISTS ${CHOLMOD_LIB}) |
| 206 | MESSAGE("-- Did not find CHOLMOD library") |
| 207 | SET(CHOLMOD_FOUND FALSE) |
| 208 | ENDIF (EXISTS ${CHOLMOD_LIB}) |
| 209 | |
| 210 | FIND_PATH(CHOLMOD_INCLUDE NAMES cholmod.h PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 211 | IF (EXISTS ${CHOLMOD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 212 | MESSAGE("-- Found CHOLMOD header in: ${CHOLMOD_INCLUDE}") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 213 | ELSE (EXISTS ${CHOLMOD_INCLUDE}) |
| 214 | MESSAGE("-- Did not find CHOLMOD header") |
| 215 | SET(CHOLMOD_FOUND FALSE) |
| 216 | ENDIF (EXISTS ${CHOLMOD_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 217 | |
Sameer Agarwal | 5a97471 | 2013-06-07 22:38:30 -0700 | [diff] [blame] | 218 | SET(SUITESPARSEQR_FOUND TRUE) |
| 219 | FIND_LIBRARY(SUITESPARSEQR_LIB NAMES spqr PATHS ${SUITESPARSE_SEARCH_LIBS}) |
| 220 | IF (EXISTS ${SUITESPARSEQR_LIB}) |
| 221 | MESSAGE("-- Found SUITESPARSEQR library: ${SUITESPARSEQR_LIB}") |
| 222 | ELSE (EXISTS ${SUITESPARSEQR_LIB}) |
| 223 | MESSAGE("-- Did not find SUITESPARSEQR library") |
| 224 | SET(SUITESPARSEQR_FOUND FALSE) |
| 225 | ENDIF (EXISTS ${SUITESPARSEQR_LIB}) |
| 226 | |
| 227 | FIND_PATH(SUITESPARSEQR_INCLUDE NAMES SuiteSparseQR.hpp PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
| 228 | IF (EXISTS ${SUITESPARSEQR_INCLUDE}) |
| 229 | MESSAGE("-- Found SUITESPARSEQR header in: ${SUITESPARSEQR_INCLUDE}") |
| 230 | ELSE (EXISTS ${SUITESPARSEQR_INCLUDE}) |
| 231 | MESSAGE("-- Did not find SUITESPARSEQR header") |
| 232 | SET(SUITESPARSEQR_FOUND FALSE) |
| 233 | ENDIF (EXISTS ${SUITESPARSEQR_INCLUDE}) |
| 234 | |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 235 | # If SuiteSparse version is >= 4 then SuiteSparse_config is required. |
| 236 | # For SuiteSparse 3, UFconfig.h is required. |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 237 | SET(SUITESPARSE_CONFIG_FOUND TRUE) |
Sameer Agarwal | bd82f82 | 2013-07-09 23:19:09 -0700 | [diff] [blame] | 238 | SET(UFCONFIG_FOUND TRUE) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 239 | |
| 240 | FIND_LIBRARY(SUITESPARSE_CONFIG_LIB |
| 241 | NAMES suitesparseconfig |
| 242 | PATHS ${SUITESPARSE_SEARCH_LIBS}) |
| 243 | IF (EXISTS ${SUITESPARSE_CONFIG_LIB}) |
| 244 | MESSAGE("-- Found SuiteSparse_config library: ${SUITESPARSE_CONFIG_LIB}") |
| 245 | ELSE (EXISTS ${SUITESPARSE_CONFIG_LIB}) |
| 246 | MESSAGE("-- Did not find SuiteSparse_config library") |
| 247 | ENDIF (EXISTS ${SUITESPARSE_CONFIG_LIB}) |
| 248 | |
| 249 | FIND_PATH(SUITESPARSE_CONFIG_INCLUDE |
| 250 | NAMES SuiteSparse_config.h |
Sameer Agarwal | 96f25dc | 2012-08-17 15:34:42 -0700 | [diff] [blame] | 251 | PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 252 | IF (EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 253 | MESSAGE("-- Found SuiteSparse_config header in: ${SUITESPARSE_CONFIG_INCLUDE}") |
Sameer Agarwal | bd82f82 | 2013-07-09 23:19:09 -0700 | [diff] [blame] | 254 | SET(UFCONFIG_FOUND FALSE) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 255 | ELSE (EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 256 | MESSAGE("-- Did not find SuiteSparse_config header") |
| 257 | ENDIF (EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 258 | |
| 259 | IF (NOT EXISTS ${SUITESPARSE_CONFIG_LIB} OR NOT EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 260 | SET(SUITESPARSE_CONFIG_FOUND FALSE) |
Sameer Agarwal | bd82f82 | 2013-07-09 23:19:09 -0700 | [diff] [blame] | 261 | FIND_PATH(UFCONFIG_INCLUDE |
| 262 | NAMES UFconfig.h |
| 263 | PATHS ${SUITESPARSE_SEARCH_HEADERS}) |
| 264 | IF (EXISTS ${UFCONFIG_INCLUDE}) |
| 265 | MESSAGE("-- Found UFconfig header in: ${UFCONFIG_INCLUDE}") |
| 266 | ELSE (EXISTS ${UFCONFIG_INCLUDE}) |
| 267 | MESSAGE("-- Did not find UFconfig header") |
| 268 | SET(UFCONFIG_FOUND FALSE) |
| 269 | ENDIF (EXISTS ${UFCONFIG_INCLUDE}) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 270 | ENDIF (NOT EXISTS ${SUITESPARSE_CONFIG_LIB} OR NOT EXISTS ${SUITESPARSE_CONFIG_INCLUDE}) |
| 271 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 272 | FIND_LIBRARY(METIS_LIB NAMES metis PATHS ${SUITESPARSE_SEARCH_LIBS}) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 273 | IF (EXISTS ${METIS_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 274 | MESSAGE("-- Found METIS library: ${METIS_LIB}") |
| 275 | ELSE (EXISTS ${METIS_LIB}) |
| 276 | MESSAGE("-- Did not find METIS library") |
| 277 | ENDIF (EXISTS ${METIS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 278 | |
Sameer Agarwal | 5a97471 | 2013-06-07 22:38:30 -0700 | [diff] [blame] | 279 | # SuiteSparseQR may be compiled with Intel Threading Building Blocks. |
| 280 | SET(TBB_FOUND TRUE) |
| 281 | FIND_LIBRARY(TBB_LIB NAMES tbb PATHS ${SEARCH_LIBS}) |
| 282 | IF (EXISTS ${TBB_LIB}) |
| 283 | MESSAGE("-- Found TBB library: ${TBB_LIB}") |
| 284 | ELSE (EXISTS ${TBB_LIB}) |
| 285 | MESSAGE("-- Did not find TBB library") |
| 286 | SET(TBB_FOUND FALSE) |
| 287 | ENDIF (EXISTS ${TBB_LIB}) |
| 288 | |
| 289 | FIND_LIBRARY(TBB_MALLOC_LIB NAMES tbbmalloc PATHS ${SEARCH_LIBS}) |
| 290 | IF (EXISTS ${TBB_MALLOC_LIB}) |
| 291 | MESSAGE("-- Found TBB Malloc library: ${TBB_MALLOC_LIB}") |
| 292 | ELSE (EXISTS ${TBB_MALLOC_LIB}) |
| 293 | MESSAGE("-- Did not find TBB library") |
| 294 | SET(TBB_FOUND FALSE) |
| 295 | ENDIF (EXISTS ${TBB_MALLOC_LIB}) |
| 296 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 297 | SET(BLAS_AND_LAPACK_FOUND TRUE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 298 | IF (APPLE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 299 | # Mac OS X has LAPACK/BLAS bundled in a framework called |
| 300 | # "vecLib". Search for that instead of for the normal "lapack" |
| 301 | # library. |
| 302 | FIND_LIBRARY(LAPACK_LIB NAMES vecLib) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 303 | ELSE (APPLE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 304 | FIND_LIBRARY(BLAS_LIB NAMES blas) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 305 | IF (EXISTS ${BLAS_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 306 | MESSAGE("-- Found BLAS library: ${BLAS_LIB}") |
| 307 | ELSE (EXISTS ${BLAS_LIB}) |
| 308 | MESSAGE("-- Did not find BLAS library") |
| 309 | SET(BLAS_AND_LAPACK_FOUND FALSE) |
| 310 | ENDIF (EXISTS ${BLAS_LIB}) |
| 311 | FIND_LIBRARY(LAPACK_LIB NAMES lapack) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 312 | ENDIF (APPLE) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 313 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 314 | IF (EXISTS ${LAPACK_LIB}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 315 | MESSAGE("-- Found LAPACK library: ${LAPACK_LIB}") |
| 316 | ELSE (EXISTS ${LAPACK_LIB}) |
| 317 | SET(BLAS_AND_LAPACK_FOUND FALSE) |
| 318 | MESSAGE("-- Did not find LAPACK library") |
| 319 | ENDIF (EXISTS ${LAPACK_LIB}) |
Keir Mierle | 92d5ab5 | 2012-05-01 18:33:08 -0700 | [diff] [blame] | 320 | |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 321 | # We don't use SET(SUITESPARSE_FOUND ${AMD_FOUND} ...) in order to |
| 322 | # be able to check whether SuiteSparse is available withou expanding |
| 323 | # SUITESPARSE_FOUND with ${}. This means further checks could be: |
| 324 | # |
| 325 | # IF (SUITESPARSE_FOUND) |
| 326 | # |
| 327 | # and not: |
| 328 | # |
| 329 | # IF (${SUITESPARSE_FOUND}) |
| 330 | # |
| 331 | IF (${AMD_FOUND} AND |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 332 | ${CAMD_FOUND} AND |
| 333 | ${COLAMD_FOUND} AND |
| 334 | ${CCOLAMD_FOUND} AND |
| 335 | ${CHOLMOD_FOUND} AND |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 336 | (${SUITESPARSE_CONFIG_FOUND} OR ${UFCONFIG_FOUND}) AND |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 337 | ${BLAS_AND_LAPACK_FOUND}) |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 338 | SET(SUITESPARSE_FOUND TRUE) |
| 339 | ELSE () |
| 340 | SET(SUITESPARSE_FOUND FALSE) |
| 341 | ENDIF () |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 342 | |
Sameer Agarwal | 8140f0f | 2013-03-12 09:45:08 -0700 | [diff] [blame] | 343 | ENDIF ((NOT DEFINED SUITESPARSE) OR (DEFINED SUITESPARSE AND SUITESPARSE)) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 344 | # By default, if all of SuiteSparse's dependencies are found, Ceres is |
| 345 | # built with SuiteSparse support. -DSUITESPARSE=ON/OFF can be used to |
| 346 | # enable/disable SuiteSparse explicitly. |
| 347 | IF (DEFINED SUITESPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 348 | IF (SUITESPARSE) |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 349 | IF (NOT SUITESPARSE_FOUND) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 350 | MESSAGE(FATAL_ERROR "One or more of SuiteSparse's dependencies was not found") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 351 | ENDIF (NOT SUITESPARSE_FOUND) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 352 | ELSE (SUITESPARSE) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 353 | ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 354 | ENDIF (SUITESPARSE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 355 | ELSE (DEFINED SUITESPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 356 | IF (SUITESPARSE_FOUND) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 357 | MESSAGE("-- Found all SuiteSparse dependencies. Building with SuiteSparse") |
| 358 | SET(SUITESPARSE ON) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 359 | ELSE (SUITESPARSE_FOUND) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 360 | MESSAGE("-- Did not find all SuiteSparse dependencies. Building without SuiteSparse") |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 361 | SET(SUITESPARSE OFF) |
| 362 | ADD_DEFINITIONS(-DCERES_NO_SUITESPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 363 | ENDIF (SUITESPARSE_FOUND) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 364 | ENDIF (DEFINED SUITESPARSE) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 365 | |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 366 | # By default, if all of CXSparse's dependencies are found, Ceres is |
| 367 | # built with CXSparse support. -DCXSPARSE=ON/OFF can be used to |
| 368 | # enable/disable CXSparse explicitly. |
Sameer Agarwal | 8140f0f | 2013-03-12 09:45:08 -0700 | [diff] [blame] | 369 | IF ((NOT DEFINED CXSPARSE) OR (DEFINED CXSPARSE AND CXSPARSE)) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 370 | |
Sameer Agarwal | bd82f82 | 2013-07-09 23:19:09 -0700 | [diff] [blame] | 371 | SET(CXSPARSE_FOUND ON) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 372 | FIND_LIBRARY(CXSPARSE_LIB NAMES cxsparse PATHS ${CXSPARSE_SEARCH_LIBS}) |
| 373 | IF (EXISTS ${CXSPARSE_LIB}) |
| 374 | MESSAGE("-- Found CXSparse library in: ${CXSPARSE_LIB}") |
| 375 | ELSE (EXISTS ${CXSPARSE_LIB}) |
| 376 | MESSAGE("-- Did not find CXSparse header") |
| 377 | SET(CXSPARSE_FOUND FALSE) |
| 378 | ENDIF (EXISTS ${CXSPARSE_LIB}) |
| 379 | |
| 380 | FIND_PATH(CXSPARSE_INCLUDE NAMES cs.h PATHS ${CXSPARSE_SEARCH_HEADERS}) |
| 381 | IF (EXISTS ${CXSPARSE_INCLUDE}) |
| 382 | MESSAGE("-- Found CXSparse header in: ${CXSPARSE_INCLUDE}") |
| 383 | ELSE (EXISTS ${CXSPARSE_INCLUDE}) |
| 384 | MESSAGE("-- Did not find CXSparse header") |
| 385 | SET(CXSPARSE_FOUND FALSE) |
| 386 | ENDIF (EXISTS ${CXSPARSE_INCLUDE}) |
Sameer Agarwal | 8140f0f | 2013-03-12 09:45:08 -0700 | [diff] [blame] | 387 | ENDIF ((NOT DEFINED CXSPARSE) OR (DEFINED CXSPARSE AND CXSPARSE)) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 388 | |
| 389 | IF (DEFINED CXSPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 390 | IF (CXSPARSE) |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 391 | IF (NOT CXSPARSE_FOUND) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 392 | MESSAGE(FATAL_ERROR "-- CXSparse not found.") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 393 | ENDIF (NOT CXSPARSE_FOUND) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 394 | ELSE (CXSPARSE) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 395 | ADD_DEFINITIONS(-DCERES_NO_CXSPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 396 | ENDIF (CXSPARSE) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 397 | ELSE (DEFINED CXSPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 398 | IF (CXSPARSE_FOUND) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 399 | MESSAGE("-- Building with CXSparse support.") |
| 400 | SET(CXSPARSE ON) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 401 | ELSE (CXSPARSE_FOUND) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 402 | MESSAGE("-- Building without CXSparse.") |
| 403 | SET(CXSPARSE OFF) |
| 404 | ADD_DEFINITIONS(-DCERES_NO_CXSPARSE) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 405 | ENDIF (CXSPARSE_FOUND) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 406 | ENDIF (DEFINED CXSPARSE) |
| 407 | |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 408 | # Google Flags |
| 409 | OPTION(GFLAGS |
| 410 | "Enable Google Flags." |
| 411 | ON) |
| 412 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 413 | IF (GFLAGS) |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 414 | FIND_LIBRARY(GFLAGS_LIB NAMES gflags PATHS ${SEARCH_LIBS}) |
| 415 | IF (NOT EXISTS ${GFLAGS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 416 | MESSAGE(FATAL_ERROR |
| 417 | "Can't find Google Flags. Please specify: " |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 418 | "-DGFLAGS_LIB=...") |
| 419 | ENDIF (NOT EXISTS ${GFLAGS_LIB}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 420 | MESSAGE("-- Found Google Flags library: ${GFLAGS_LIB}") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 421 | FIND_PATH(GFLAGS_INCLUDE NAMES gflags/gflags.h PATHS ${SEARCH_HEADERS}) |
| 422 | IF (NOT EXISTS ${GFLAGS_INCLUDE}) |
| 423 | MESSAGE(FATAL_ERROR |
| 424 | "Can't find Google Flags. Please specify: " |
| 425 | "-DGFLAGS_INCLUDE=...") |
| 426 | ENDIF (NOT EXISTS ${GFLAGS_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 427 | MESSAGE("-- Found Google Flags header in: ${GFLAGS_INCLUDE}") |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 428 | ELSE (GFLAGS) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 429 | MESSAGE("-- Google Flags disabled; no tests or tools will be built!") |
| 430 | ADD_DEFINITIONS(-DCERES_NO_GFLAGS) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 431 | ENDIF (GFLAGS) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 432 | |
| 433 | # Google Logging |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 434 | IF (NOT BUILD_ANDROID) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 435 | FIND_LIBRARY(GLOG_LIB NAMES glog PATHS ${SEARCH_LIBS}) |
| 436 | IF (NOT EXISTS ${GLOG_LIB}) |
| 437 | MESSAGE(FATAL_ERROR |
| 438 | "Can't find Google Log. Please specify: " |
| 439 | "-DGLOG_LIB=...") |
| 440 | ENDIF (NOT EXISTS ${GLOG_LIB}) |
| 441 | MESSAGE("-- Found Google Log library: ${GLOG_LIB}") |
Sameer Agarwal | aa9526d | 2012-05-08 21:22:09 -0700 | [diff] [blame] | 442 | |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 443 | FIND_PATH(GLOG_INCLUDE NAMES glog/logging.h PATHS ${SEARCH_HEADERS}) |
| 444 | IF (NOT EXISTS ${GLOG_INCLUDE}) |
| 445 | MESSAGE(FATAL_ERROR |
| 446 | "Can't find Google Log. Please specify: " |
| 447 | "-DGLOG_INCLUDE=...") |
| 448 | ENDIF (NOT EXISTS ${GLOG_INCLUDE}) |
| 449 | MESSAGE("-- Found Google Log header in: ${GLOG_INCLUDE}") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 450 | ELSE (NOT BUILD_ANDROID) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 451 | SET(GLOG_LIB miniglog) |
| 452 | MESSAGE("-- Using minimal Glog substitute for Android (library): ${GLOG_LIB}") |
| 453 | SET(GLOG_INCLUDE internal/ceres/miniglog) |
| 454 | MESSAGE("-- Using minimal Glog substitute for Android (include): ${GLOG_INCLUDE}") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 455 | ENDIF (NOT BUILD_ANDROID) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 456 | |
| 457 | # Eigen |
Keir Mierle | f477a38 | 2012-05-01 18:10:48 -0700 | [diff] [blame] | 458 | FIND_PATH(EIGEN_INCLUDE NAMES Eigen/Core PATHS ${EIGEN_SEARCH_HEADERS}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 459 | IF (NOT EXISTS ${EIGEN_INCLUDE}) |
Keir Mierle | f477a38 | 2012-05-01 18:10:48 -0700 | [diff] [blame] | 460 | MESSAGE(FATAL_ERROR "Can't find Eigen. Try passing -DEIGEN_INCLUDE=...") |
Sameer Agarwal | bd82f82 | 2013-07-09 23:19:09 -0700 | [diff] [blame] | 461 | ELSE (NOT EXISTS ${EIGEN_INCLUDE}) |
| 462 | MESSAGE("-- Found Eigen 3.x: ${EIGEN_INCLUDE}") |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 463 | ENDIF (NOT EXISTS ${EIGEN_INCLUDE}) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 464 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 465 | # Template specializations for the Schur complement based solvers. If |
| 466 | # compile time, binary size or compiler performance is an issue, you |
| 467 | # may consider disabling this. |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 468 | OPTION(SCHUR_SPECIALIZATIONS |
| 469 | "Enable fixed-size schur specializations." |
| 470 | ON) |
| 471 | |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 472 | IF (NOT SCHUR_SPECIALIZATIONS) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 473 | ADD_DEFINITIONS(-DCERES_RESTRICT_SCHUR_SPECIALIZATION) |
Keir Mierle | f10163a | 2012-05-04 21:33:53 -0700 | [diff] [blame] | 474 | MESSAGE("-- Disabling Schur specializations (faster compiles)") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 475 | ENDIF (NOT SCHUR_SPECIALIZATIONS) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 476 | |
Sameer Agarwal | 8140f0f | 2013-03-12 09:45:08 -0700 | [diff] [blame] | 477 | # Line search minimizer is useful for large scale problems or when |
| 478 | # sparse linear algebra libraries are not available. If compile time, |
| 479 | # binary size or compiler performance is an issue, consider disabling |
| 480 | # this. |
| 481 | OPTION(LINE_SEARCH_MINIMIZER |
| 482 | "Enable the line search minimizer." |
| 483 | ON) |
| 484 | |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 485 | IF (NOT LINE_SEARCH_MINIMIZER) |
Sameer Agarwal | 296fa9b | 2013-04-02 09:44:15 -0700 | [diff] [blame] | 486 | ADD_DEFINITIONS(-DCERES_NO_LINE_SEARCH_MINIMIZER) |
| 487 | MESSAGE("-- Disabling line search minimizer") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 488 | ENDIF (NOT LINE_SEARCH_MINIMIZER) |
Sameer Agarwal | 8140f0f | 2013-03-12 09:45:08 -0700 | [diff] [blame] | 489 | |
Sameer Agarwal | 296fa9b | 2013-04-02 09:44:15 -0700 | [diff] [blame] | 490 | OPTION(CUSTOM_BLAS |
| 491 | "Use handcoded BLAS routines (usually faster) instead of Eigen." |
| 492 | ON) |
| 493 | |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 494 | IF (NOT CUSTOM_BLAS) |
Sameer Agarwal | 296fa9b | 2013-04-02 09:44:15 -0700 | [diff] [blame] | 495 | ADD_DEFINITIONS(-DCERES_NO_CUSTOM_BLAS) |
| 496 | MESSAGE("-- Disabling custom blas") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 497 | ENDIF (NOT CUSTOM_BLAS) |
Sameer Agarwal | 296fa9b | 2013-04-02 09:44:15 -0700 | [diff] [blame] | 498 | |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 499 | # Multithreading using OpenMP |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 500 | OPTION(OPENMP |
| 501 | "Enable threaded solving in Ceres (requires OpenMP)" |
| 502 | ON) |
| 503 | |
Sameer Agarwal | 9f4552b | 2013-07-09 00:10:08 -0700 | [diff] [blame] | 504 | IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
| 505 | SET(OPENMP_FOUND FALSE) |
| 506 | ELSE (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
| 507 | IF (OPENMP) |
| 508 | FIND_PACKAGE(OpenMP) |
| 509 | ENDIF (OPENMP) |
| 510 | ENDIF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 511 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 512 | IF (OPENMP_FOUND) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 513 | MESSAGE("-- Found OpenMP.") |
| 514 | ADD_DEFINITIONS(-DCERES_USE_OPENMP) |
| 515 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 516 | IF (UNIX) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 517 | # At least on Linux, we need pthreads to be enabled for mutex to |
| 518 | # compile. This may not work on Windows or Android. |
| 519 | FIND_PACKAGE(Threads REQUIRED) |
| 520 | SET(STATIC_LIBRARY_FLAGS |
| 521 | "${STATIC_LIBRARY_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") |
| 522 | SET(CMAKE_SHARED_LINKER_FLAGS |
| 523 | "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") |
| 524 | ADD_DEFINITIONS(-DCERES_HAVE_PTHREAD) |
| 525 | ADD_DEFINITIONS(-DCERES_HAVE_RWLOCK) |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 526 | ENDIF (UNIX) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 527 | ELSE (OPENMP_FOUND) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 528 | MESSAGE("-- Can't find OpenMP. Disabling multithreading.") |
| 529 | ADD_DEFINITIONS(-DCERES_NO_THREADS) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 530 | ENDIF (OPENMP_FOUND) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 531 | |
| 532 | # Disable threads in mutex.h. Someday, after there is OpenMP support in |
| 533 | # Android, this can get removed. Also turn on a workaround for an NDK bug. |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 534 | IF (BUILD_ANDROID) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 535 | ADD_DEFINITIONS(-DCERES_NO_THREADS) |
| 536 | ADD_DEFINITIONS(-DCERES_WORK_AROUND_ANDROID_NDK_COMPILER_BUG) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 537 | ENDIF (BUILD_ANDROID) |
Sameer Agarwal | 36f4cd2 | 2013-04-21 09:42:26 -0700 | [diff] [blame] | 538 | |
Keir Mierle | d216490 | 2012-08-15 19:04:50 -0700 | [diff] [blame] | 539 | OPTION(DISABLE_TR1 |
| 540 | "Don't use TR1. This replaces some hash tables with sets. Slower." |
| 541 | OFF) |
| 542 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 543 | IF (DISABLE_TR1) |
Keir Mierle | d216490 | 2012-08-15 19:04:50 -0700 | [diff] [blame] | 544 | MESSAGE("-- Replacing unordered_map/set with map/set (warning: slower!)") |
| 545 | ADD_DEFINITIONS(-DCERES_NO_TR1) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 546 | ELSE (DISABLE_TR1) |
Keir Mierle | d216490 | 2012-08-15 19:04:50 -0700 | [diff] [blame] | 547 | MESSAGE("-- Using normal TR1 unordered_map/set") |
| 548 | # Use the std namespace for the hash<> and related templates. This may vary by |
| 549 | # system. |
| 550 | IF (MSVC) |
Sergey Sharybin | f806576 | 2013-05-31 23:48:06 +0600 | [diff] [blame] | 551 | IF (MSVC90) |
| 552 | # Special case for Visual Studio 2008. |
| 553 | # Newer versions have got tr1 symbols in another namespace, |
| 554 | # and this is being handled in Else branch of this condition. |
| 555 | # Probably Visual studio 2003 and 2005 also shall be handled here, |
| 556 | # but don't have by hand to verify and most likely they're not |
| 557 | # used by Ceres users anyway. |
| 558 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"") |
| 559 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}}\"") |
| 560 | ELSE (MSVC90) |
| 561 | # This is known to work with Visual Studio 2010 Express. |
| 562 | # Further, for as long Visual Studio 2012 didn't move tr1 to |
| 563 | # just another namespace, the same define will work for it as well. |
| 564 | # Hopefully all further versions will also keep working with this define. |
| 565 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std {\"") |
| 566 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}\"") |
| 567 | ENDIF(MSVC90) |
Keir Mierle | d216490 | 2012-08-15 19:04:50 -0700 | [diff] [blame] | 568 | ELSE (MSVC) |
| 569 | # This is known to work with recent versions of Linux and Mac OS X. |
| 570 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_START=namespace std { namespace tr1 {\"") |
| 571 | ADD_DEFINITIONS("\"-DCERES_HASH_NAMESPACE_END=}}\"") |
| 572 | ENDIF (MSVC) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 573 | ENDIF (DISABLE_TR1) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 574 | |
| 575 | INCLUDE_DIRECTORIES( |
| 576 | include |
| 577 | internal |
| 578 | internal/ceres |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 579 | ${GLOG_INCLUDE} |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 580 | ${EIGEN_INCLUDE} |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 581 | ) |
| 582 | |
Arnaud Gelas | 3d644b7 | 2012-08-16 17:33:21 +0200 | [diff] [blame] | 583 | FILE(GLOB CERES_HDRS ${CMAKE_SOURCE_DIR}/include/ceres/*.h) |
| 584 | INSTALL(FILES ${CERES_HDRS} DESTINATION include/ceres) |
| 585 | |
| 586 | FILE(GLOB CERES_PUBLIC_INTERNAL_HDRS ${CMAKE_SOURCE_DIR}/include/ceres/internal/*.h) |
| 587 | INSTALL(FILES ${CERES_PUBLIC_INTERNAL_HDRS} DESTINATION include/ceres/internal) |
| 588 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 589 | IF (SUITESPARSE) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 590 | INCLUDE_DIRECTORIES(${AMD_INCLUDE}) |
| 591 | INCLUDE_DIRECTORIES(${CAMD_INCLUDE}) |
| 592 | INCLUDE_DIRECTORIES(${COLAMD_INCLUDE}) |
| 593 | INCLUDE_DIRECTORIES(${CCOLAMD_INCLUDE}) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 594 | INCLUDE_DIRECTORIES(${CHOLMOD_INCLUDE}) |
Sameer Agarwal | 5a97471 | 2013-06-07 22:38:30 -0700 | [diff] [blame] | 595 | INCLUDE_DIRECTORIES(${SUITESPARSEQR_INCLUDE}) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 596 | IF (SUITESPARSE_CONFIG_FOUND) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 597 | INCLUDE_DIRECTORIES(${SUITESPARSE_CONFIG_INCLUDE}) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 598 | ENDIF (SUITESPARSE_CONFIG_FOUND) |
| 599 | IF (UFCONFIG_FOUND) |
Markus Moll | c497bd6 | 2012-08-17 14:40:13 +0200 | [diff] [blame] | 600 | INCLUDE_DIRECTORIES(${UFCONFIG_INCLUDE}) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 601 | ENDIF (UFCONFIG_FOUND) |
| 602 | ENDIF (SUITESPARSE) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 603 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 604 | IF (CXSPARSE) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 605 | INCLUDE_DIRECTORIES(${CXSPARSE_INCLUDE}) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 606 | ENDIF (CXSPARSE) |
Sameer Agarwal | b051873 | 2012-05-29 00:27:57 -0700 | [diff] [blame] | 607 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 608 | IF (GFLAGS) |
Sameer Agarwal | daa9824 | 2012-05-11 11:26:38 -0700 | [diff] [blame] | 609 | INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE}) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 610 | ENDIF (GFLAGS) |
Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 611 | |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 612 | # Change the default build type from Debug to Release, while still |
| 613 | # supporting overriding the build type. |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 614 | # |
| 615 | # The CACHE STRING logic here and elsewhere is needed to force CMake |
| 616 | # to pay attention to the value of these variables. |
| 617 | IF (NOT CMAKE_BUILD_TYPE) |
| 618 | MESSAGE("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.") |
| 619 | SET(CMAKE_BUILD_TYPE Release CACHE STRING |
| 620 | "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." |
| 621 | FORCE) |
| 622 | ELSE (NOT CMAKE_BUILD_TYPE) |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 623 | IF (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 624 | MESSAGE("\n=================================================================================") |
| 625 | MESSAGE("\n-- Build type: Debug. Performance will be terrible!") |
| 626 | MESSAGE("-- Add -DCMAKE_BUILD_TYPE=Release to the CMake command line to get an optimized build.") |
| 627 | MESSAGE("\n=================================================================================") |
Sameer Agarwal | 8e2420e | 2012-05-31 17:00:58 -0700 | [diff] [blame] | 628 | ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug") |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 629 | ENDIF (NOT CMAKE_BUILD_TYPE) |
| 630 | |
| 631 | # Set the default Ceres flags to an empty string. |
| 632 | SET (CERES_CXX_FLAGS) |
| 633 | |
| 634 | IF (CMAKE_BUILD_TYPE STREQUAL "Release") |
| 635 | IF (CMAKE_COMPILER_IS_GNUCXX) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 636 | IF (BUILD_ANDROID) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 637 | # TODO(keir): Figure out what flags should go here to make an optimized |
| 638 | # native ARM binary for Android. |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 639 | ELSE (BUILD_ANDROID) |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 640 | # Linux |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 641 | IF (CMAKE_SYSTEM_NAME MATCHES "Linux") |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 642 | SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -march=native -mtune=native") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 643 | ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux") |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 644 | # Mac OS X |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 645 | IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 646 | SET (CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -fast -msse3") |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 647 | ENDIF (CMAKE_SYSTEM_NAME MATCHES "Darwin") |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 648 | ENDIF (BUILD_ANDROID) |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 649 | ENDIF (CMAKE_COMPILER_IS_GNUCXX) |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 650 | IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
Sameer Agarwal | 395b4e9 | 2013-05-23 11:01:16 -0700 | [diff] [blame] | 651 | # Use of -O4 requires use of gold linker & LLVM-gold plugin, which might |
| 652 | # well not be present / in use and without which files will compile, but |
Alex Stewart | 3702068 | 2013-05-12 20:06:04 +0100 | [diff] [blame] | 653 | # not link ('file not recognized') so explicitly check for support |
| 654 | INCLUDE(CheckCXXCompilerFlag) |
| 655 | CHECK_CXX_COMPILER_FLAG("-O4" HAVE_LTO_SUPPORT) |
| 656 | IF (HAVE_LTO_SUPPORT) |
| 657 | MESSAGE(STATUS "Enabling link-time optimization (-O4)") |
| 658 | SET(CERES_CXX_FLAGS "${CERES_CXX_FLAGS} -O4") |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 659 | ELSE () |
Alex Stewart | 3702068 | 2013-05-12 20:06:04 +0100 | [diff] [blame] | 660 | MESSAGE(STATUS "Compiler/linker does not support link-time optimization (-O4), disabling.") |
| 661 | ENDIF (HAVE_LTO_SUPPORT) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 662 | ENDIF () |
Sameer Agarwal | 4845bc4 | 2012-06-05 21:32:57 -0700 | [diff] [blame] | 663 | ENDIF (CMAKE_BUILD_TYPE STREQUAL "Release") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 664 | |
Sameer Agarwal | 24fb32b | 2013-04-20 09:02:06 -0700 | [diff] [blame] | 665 | SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CERES_CXX_FLAGS}") |
| 666 | |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 667 | # After the tweaks for the compile settings, disable some warnings on MSVC. |
| 668 | IF (MSVC) |
| 669 | # Disable signed/unsigned int conversion warnings. |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 670 | ADD_DEFINITIONS("/wd4018") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 671 | # Disable warning about using struct/class for the same symobl. |
Keir Mierle | aefb8a8 | 2012-07-28 13:23:55 -0700 | [diff] [blame] | 672 | ADD_DEFINITIONS("/wd4099") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 673 | # Disable warning about the insecurity of using "std::copy". |
| 674 | ADD_DEFINITIONS("/wd4996") |
| 675 | # Disable performance warning about int-to-bool conversion. |
| 676 | ADD_DEFINITIONS("/wd4800") |
| 677 | # Disable performance warning about fopen insecurity. |
| 678 | ADD_DEFINITIONS("/wd4996") |
| 679 | # Disable warning about int64 to int32 conversion. Disabling |
| 680 | # this warning may not be correct; needs investigation. |
| 681 | # TODO(keir): Investigate these warnings in more detail. |
| 682 | ADD_DEFINITIONS("/wd4244") |
| 683 | # It's not possible to use STL types in DLL interfaces in a portable and |
| 684 | # reliable way. However, that's what happens with Google Log and Google Flags |
| 685 | # on Windows. MSVC gets upset about this and throws warnings that we can't do |
| 686 | # much about. The real solution is to link static versions of Google Log and |
| 687 | # Google Test, but that seems tricky on Windows. So, disable the warning. |
| 688 | ADD_DEFINITIONS("/wd4251") |
| 689 | |
| 690 | # Google Flags doesn't have their DLL import/export stuff set up correctly, |
| 691 | # which results in linker warnings. This is irrelevant for Ceres, so ignore |
| 692 | # the warnings. |
| 693 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4049") |
Petter Strandmark | b7ba934 | 2013-02-19 12:52:58 +0100 | [diff] [blame] | 694 | |
| 695 | # Tuple sizes of 10 are used by Gtest. |
| 696 | ADD_DEFINITIONS("-D_VARIADIC_MAX=10") |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 697 | ENDIF (MSVC) |
| 698 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 699 | IF (UNIX) |
Sameer Agarwal | 395b4e9 | 2013-05-23 11:01:16 -0700 | [diff] [blame] | 700 | # GCC is not strict enough by default, so enable most of the warnings. |
Keir Mierle | 97ca0fb | 2012-09-18 15:52:36 -0700 | [diff] [blame] | 701 | SET(CMAKE_CXX_FLAGS |
Sameer Agarwal | 1ab7fde | 2013-07-08 10:03:49 -0700 | [diff] [blame] | 702 | "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers") |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 703 | ENDIF (UNIX) |
Keir Mierle | 97ca0fb | 2012-09-18 15:52:36 -0700 | [diff] [blame] | 704 | |
Sameer Agarwal | 3d6eceb | 2013-04-02 21:45:48 -0700 | [diff] [blame] | 705 | # Use a larger inlining threshold for Clang, since it hobbles Eigen, |
| 706 | # resulting in an unreasonably slow version of the blas routines. The |
| 707 | # -Qunused-arguments is needed because CMake passes the inline |
| 708 | # threshold to the linker and clang complains about it and dies. |
Sergey Sharybin | 72cc457 | 2013-06-19 20:59:08 +0600 | [diff] [blame] | 709 | IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
Sameer Agarwal | 3d6eceb | 2013-04-02 21:45:48 -0700 | [diff] [blame] | 710 | SET(CMAKE_CXX_FLAGS |
| 711 | "${CMAKE_CXX_FLAGS} -Qunused-arguments -mllvm -inline-threshold=600 -Wno-return-type-c-linkage") |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 712 | ENDIF () |
Taylor Braun-Jones | b73148b | 2013-02-25 02:34:00 -0500 | [diff] [blame] | 713 | |
Keir Mierle | efe7ac6 | 2012-06-24 22:25:28 -0700 | [diff] [blame] | 714 | ADD_SUBDIRECTORY(internal/ceres) |
Arnaud Gelas | b12b906 | 2012-08-15 16:27:38 +0200 | [diff] [blame] | 715 | |
| 716 | OPTION(BUILD_DOCUMENTATION |
Pablo Speciale | c51b11c | 2013-03-12 00:56:56 -0700 | [diff] [blame] | 717 | "Build User's Guide (html)" |
Arnaud Gelas | b12b906 | 2012-08-15 16:27:38 +0200 | [diff] [blame] | 718 | OFF) |
| 719 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 720 | IF (BUILD_DOCUMENTATION) |
Arnaud Gelas | b12b906 | 2012-08-15 16:27:38 +0200 | [diff] [blame] | 721 | MESSAGE("-- Documentation building is enabled") |
| 722 | |
Pablo Speciale | c51b11c | 2013-03-12 00:56:56 -0700 | [diff] [blame] | 723 | # Make CMake aware of the cmake folder, in order to find 'FindSphinx.cmake' |
| 724 | SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") |
| 725 | |
| 726 | # Generate the User's Guide (html). |
Arnaud Gelas | b12b906 | 2012-08-15 16:27:38 +0200 | [diff] [blame] | 727 | # The corresponding target is UserGuide, but is included in ALL. |
| 728 | ADD_SUBDIRECTORY(docs) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 729 | ENDIF (BUILD_DOCUMENTATION) |
Arnaud Gelas | 7316609 | 2012-08-20 15:40:41 +0200 | [diff] [blame] | 730 | |
| 731 | OPTION(BUILD_EXAMPLES "Build examples" ON) |
| 732 | |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 733 | IF (BUILD_EXAMPLES) |
Arnaud Gelas | 7316609 | 2012-08-20 15:40:41 +0200 | [diff] [blame] | 734 | MESSAGE("-- Build the examples.") |
| 735 | ADD_SUBDIRECTORY(examples) |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 736 | ELSE (BUILD_EXAMPLES) |
Arnaud Gelas | 7316609 | 2012-08-20 15:40:41 +0200 | [diff] [blame] | 737 | MESSAGE("-- Do not build any example.") |
Joydeep Biswas | aa20a6d | 2013-05-15 09:38:03 -0400 | [diff] [blame] | 738 | ENDIF (BUILD_EXAMPLES) |
Arnaud Gelas | 9ad27e8 | 2012-08-21 09:56:30 +0200 | [diff] [blame] | 739 | |
| 740 | # Add an uninstall target to remove all installed files. |
| 741 | CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" |
| 742 | "${CMAKE_BINARY_DIR}/cmake/uninstall.cmake" |
| 743 | IMMEDIATE @ONLY) |
| 744 | |
| 745 | ADD_CUSTOM_TARGET(uninstall |
| 746 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/uninstall.cmake) |
Pablo Speciale | 16dbf11 | 2013-03-11 14:44:02 -0700 | [diff] [blame] | 747 | |
Pablo Speciale | 0ff3bb3 | 2013-05-23 17:52:21 -0700 | [diff] [blame] | 748 | # Set up install directories. INCLUDE_INSTALL_DIR, LIB_INSTALL_DIR and |
| 749 | # CMAKECONFIG_INSTALL_DIR must not be absolute paths. |
Pablo Speciale | 16dbf11 | 2013-03-11 14:44:02 -0700 | [diff] [blame] | 750 | SET(INCLUDE_INSTALL_DIR include) |
Pablo Speciale | 0ff3bb3 | 2013-05-23 17:52:21 -0700 | [diff] [blame] | 751 | SET(LIB_INSTALL_DIR lib) |
| 752 | SET(CMAKECONFIG_INSTALL_DIR share/Ceres) |
Pablo Speciale | 16dbf11 | 2013-03-11 14:44:02 -0700 | [diff] [blame] | 753 | |
| 754 | # This "exports" all targets which have been put into the export set |
| 755 | # "CeresExport". This means that CMake generates a file with the given |
| 756 | # filename, which can later on be loaded by projects using this package. |
| 757 | # This file contains ADD_LIBRARY(bar IMPORTED) statements for each target |
| 758 | # in the export set, so when loaded later on CMake will create "imported" |
| 759 | # library targets from these, which can be used in many ways in the same way |
| 760 | # as a normal library target created via a normal ADD_LIBRARY(). |
| 761 | INSTALL(EXPORT CeresExport |
| 762 | DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE CeresTargets.cmake) |
| 763 | |
| 764 | # Figure out the relative path from the installed Config.cmake file to the |
| 765 | # install prefix (which may be at runtime different from the chosen |
| 766 | # CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere) |
| 767 | # This relative path will be configured into the CeresConfig.cmake. |
| 768 | FILE(RELATIVE_PATH relInstallDir |
| 769 | ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) |
| 770 | |
| 771 | # Create a CeresConfig.cmake file. <name>Config.cmake files are searched by |
| 772 | # FIND_PACKAGE() automatically. We configure that file so that we can put any |
| 773 | # information we want in it, e.g. version numbers, include directories, etc. |
| 774 | CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in" |
| 775 | "${CMAKE_CURRENT_BINARY_DIR}/CeresConfig.cmake" @ONLY) |
| 776 | |
| 777 | # Additionally, when CMake has found a CeresConfig.cmake, it can check for a |
| 778 | # CeresConfigVersion.cmake in the same directory when figuring out the version |
| 779 | # of the package when a version has been specified in the FIND_PACKAGE() call, |
| 780 | # e.g. FIND_PACKAGE(Ceres [1.4.2] REQUIRED). The version argument is optional. |
| 781 | CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfigVersion.cmake.in" |
| 782 | "${CMAKE_CURRENT_BINARY_DIR}/CeresConfigVersion.cmake" @ONLY) |
| 783 | |
| 784 | # Install these two files into the same directory as the generated exports-file. |
| 785 | INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/CeresConfig.cmake" |
| 786 | "${CMAKE_CURRENT_BINARY_DIR}/CeresConfigVersion.cmake" |
| 787 | "${CMAKE_SOURCE_DIR}/cmake/depend.cmake" |
| 788 | DESTINATION ${CMAKECONFIG_INSTALL_DIR}) |