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