feat(3rdparty): add eigen and ceres

This commit is contained in:
John Zhao
2019-01-03 16:25:18 +08:00
parent c6fd9db827
commit 6773d8eb7a
747 changed files with 375754 additions and 1 deletions

View File

@@ -0,0 +1,76 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Authors: keir@google.com (Keir Mierle)
# alexs.mac@gmail.com (Alex Stewart)
# Set up the git hook to make Gerrit Change-Id: lines in commit messages.
function(ADD_GERRIT_COMMIT_HOOK)
unset (LOCAL_GIT_DIRECTORY)
if (EXISTS ${CMAKE_SOURCE_DIR}/.git)
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
# .git directory can be found on Unix based system, or on Windows with
# Git Bash (shipped with msysgit).
set (LOCAL_GIT_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
else(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
# .git is a file, this means Ceres is a git submodule of another project
# and our .git file contains the path to the git directory which manages
# Ceres, so we should add the gerrit hook there.
file(READ ${CMAKE_SOURCE_DIR}/.git GIT_SUBMODULE_FILE_CONTENTS)
# Strip any trailing newline characters, s/t we get a valid path.
string(REGEX REPLACE "gitdir:[ ]*([^$].*)[\n].*" "${CMAKE_SOURCE_DIR}/\\1"
GIT_SUBMODULE_GIT_DIRECTORY_PATH "${GIT_SUBMODULE_FILE_CONTENTS}")
get_filename_component(GIT_SUBMODULE_GIT_DIRECTORY_PATH
"${GIT_SUBMODULE_GIT_DIRECTORY_PATH}" ABSOLUTE)
if (EXISTS ${GIT_SUBMODULE_GIT_DIRECTORY_PATH}
AND IS_DIRECTORY ${GIT_SUBMODULE_GIT_DIRECTORY_PATH})
set(LOCAL_GIT_DIRECTORY "${GIT_SUBMODULE_GIT_DIRECTORY_PATH}")
endif()
endif()
else (EXISTS ${CMAKE_SOURCE_DIR}/.git)
# TODO(keir) Add proper Windows support.
endif (EXISTS ${CMAKE_SOURCE_DIR}/.git)
if (EXISTS ${LOCAL_GIT_DIRECTORY})
if (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg)
message(STATUS "Detected Ceres being used as a git submodule, adding "
"commit hook for Gerrit to: ${LOCAL_GIT_DIRECTORY}")
# Download the hook only if it is not already present.
file(DOWNLOAD https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg
${CMAKE_BINARY_DIR}/commit-msg)
# Make the downloaded file executable, since it is not by default.
file(COPY ${CMAKE_BINARY_DIR}/commit-msg
DESTINATION ${LOCAL_GIT_DIRECTORY}/hooks/
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif (NOT EXISTS ${LOCAL_GIT_DIRECTORY}/hooks/commit-msg)
endif (EXISTS ${LOCAL_GIT_DIRECTORY})
endfunction()

View File

@@ -0,0 +1,61 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
# Append item(s) to a property on a declared CMake target:
#
# append_target_property(target property item_to_append1
# [... item_to_appendN])
#
# The set_target_properties() CMake function will overwrite the contents of the
# specified target property. This function instead appends to it, so can
# be called multiple times with the same target & property to iteratively
# populate it.
function(append_target_property TARGET PROPERTY)
if (NOT TARGET ${TARGET})
message(FATAL_ERROR "Invalid target: ${TARGET} cannot append: ${ARGN} "
"to property: ${PROPERTY}")
endif()
if (NOT PROPERTY)
message(FATAL_ERROR "Invalid property to update for target: ${TARGET}")
endif()
# Get the initial state of the specified property for the target s/t
# we can append to it (not overwrite it).
get_target_property(INITIAL_PROPERTY_STATE ${TARGET} ${PROPERTY})
if (NOT INITIAL_PROPERTY_STATE)
# Ensure that if the state is unset, we do not insert the XXX-NOTFOUND
# returned by CMake into the property.
set(INITIAL_PROPERTY_STATE "")
endif()
# Delistify (remove ; separators) the potentially set of items to append
# to the specified target property.
string(REPLACE ";" " " ITEMS_TO_APPEND "${ARGN}")
set_target_properties(${TARGET} PROPERTIES ${PROPERTY}
"${INITIAL_PROPERTY_STATE} ${ITEMS_TO_APPEND}")
endfunction()

View File

@@ -0,0 +1,303 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Authors: pablo.speciale@gmail.com (Pablo Speciale)
# alexs.mac@gmail.com (Alex Stewart)
#
# Config file for Ceres Solver - Find Ceres & dependencies.
#
# This file is used by CMake when find_package(Ceres) is invoked and either
# the directory containing this file either is present in CMAKE_MODULE_PATH
# (if Ceres was installed), or exists in the local CMake package registry if
# the Ceres build directory was exported.
#
# This module defines the following variables:
#
# Ceres_FOUND / CERES_FOUND: True if Ceres has been successfully
# found. Both variables are set as although
# FindPackage() only references Ceres_FOUND
# in Config mode, given the conventions for
# <package>_FOUND when FindPackage() is
# called in Module mode, users could
# reasonably expect to use CERES_FOUND
# instead.
#
# CERES_VERSION: Version of Ceres found.
#
# CERES_INCLUDE_DIRS: Include directories for Ceres and the
# dependencies which appear in the Ceres public
# API and are thus required to use Ceres.
#
# CERES_LIBRARIES: Libraries for Ceres and all
# dependencies against which Ceres was
# compiled. This will not include any optional
# dependencies that were disabled when Ceres was
# compiled.
#
# The following variables are also defined for legacy compatibility
# only. Any new code should not use them as they do not conform to
# the standard CMake FindPackage naming conventions.
#
# CERES_INCLUDES = ${CERES_INCLUDE_DIRS}.
# Called if we failed to find Ceres or any of its required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(CERES_REPORT_NOT_FOUND REASON_MSG)
# FindPackage() only references Ceres_FOUND, and requires it to be
# explicitly set FALSE to denote not found (not merely undefined).
set(Ceres_FOUND FALSE)
set(CERES_FOUND FALSE)
unset(CERES_INCLUDE_DIRS)
unset(CERES_LIBRARIES)
# Reset the CMake module path to its state when this script was called.
set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH})
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by
# FindPackage() use the camelcase library name, not uppercase.
if (Ceres_FIND_QUIETLY)
message(STATUS "Failed to find Ceres - " ${REASON_MSG} ${ARGN})
else (Ceres_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error
# that prevents generation, but continues configuration.
message(SEND_ERROR "Failed to find Ceres - " ${REASON_MSG} ${ARGN})
endif ()
return()
endmacro(CERES_REPORT_NOT_FOUND)
# If Ceres was not installed, then by definition it was exported
# from a build directory.
set(CERES_WAS_INSTALLED @SETUP_CERES_CONFIG_FOR_INSTALLATION@)
# Record the state of the CMake module path when this script was
# called so that we can ensure that we leave it in the same state on
# exit as it was on entry, but modify it locally.
set(CALLERS_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
# Get the (current, i.e. installed) directory containing this file.
get_filename_component(CERES_CURRENT_CONFIG_DIR
"${CMAKE_CURRENT_LIST_FILE}" PATH)
if (CERES_WAS_INSTALLED)
# Reset CMake module path to the installation directory of this
# script, thus we will use the FindPackage() scripts shipped with
# Ceres to find Ceres' dependencies, even if the user has equivalently
# named FindPackage() scripts in their project.
set(CMAKE_MODULE_PATH ${CERES_CURRENT_CONFIG_DIR})
# Build the absolute root install directory as a relative path
# (determined when Ceres was configured & built) from the current
# install directory for this this file. This allows for the install
# tree to be relocated, after Ceres was built, outside of CMake.
get_filename_component(CURRENT_ROOT_INSTALL_DIR
${CERES_CURRENT_CONFIG_DIR}/@INSTALL_ROOT_REL_CONFIG_INSTALL_DIR@
ABSOLUTE)
if (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR})
ceres_report_not_found(
"Ceres install root: ${CURRENT_ROOT_INSTALL_DIR}, "
"determined from relative path from CeresConfig.cmake install location: "
"${CERES_CURRENT_CONFIG_DIR}, does not exist. Either the install "
"directory was deleted, or the install tree was only partially relocated "
"outside of CMake after Ceres was built.")
endif (NOT EXISTS ${CURRENT_ROOT_INSTALL_DIR})
# Set the include directories for Ceres (itself).
set(CERES_INCLUDE_DIR "${CURRENT_ROOT_INSTALL_DIR}/include")
if (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h)
ceres_report_not_found(
"Ceres install root: ${CURRENT_ROOT_INSTALL_DIR}, "
"determined from relative path from CeresConfig.cmake install location: "
"${CERES_CURRENT_CONFIG_DIR}, does not contain Ceres headers. "
"Either the install directory was deleted, or the install tree was only "
"partially relocated outside of CMake after Ceres was built.")
endif (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h)
list(APPEND CERES_INCLUDE_DIRS ${CERES_INCLUDE_DIR})
else(CERES_WAS_INSTALLED)
# Ceres was exported from the build tree.
set(CERES_EXPORTED_BUILD_DIR ${CERES_CURRENT_CONFIG_DIR})
get_filename_component(CERES_EXPORTED_SOURCE_DIR
${CERES_EXPORTED_BUILD_DIR}/@INSTALL_ROOT_REL_CONFIG_INSTALL_DIR@
ABSOLUTE)
if (NOT EXISTS ${CERES_EXPORTED_SOURCE_DIR})
ceres_report_not_found(
"Ceres exported source directory: ${CERES_EXPORTED_SOURCE_DIR}, "
"determined from relative path from CeresConfig.cmake exported build "
"directory: ${CERES_EXPORTED_BUILD_DIR} does not exist.")
endif()
# Reset CMake module path to the cmake directory in the Ceres source
# tree which was exported, thus we will use the FindPackage() scripts shipped
# with Ceres to find Ceres' dependencies, even if the user has equivalently
# named FindPackage() scripts in their project.
set(CMAKE_MODULE_PATH ${CERES_EXPORTED_SOURCE_DIR}/cmake)
# Set the include directories for Ceres (itself).
set(CERES_INCLUDE_DIR "${CERES_EXPORTED_SOURCE_DIR}/include")
if (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h)
ceres_report_not_found(
"Ceres exported source directory: ${CERES_EXPORTED_SOURCE_DIR}, "
"determined from relative path from CeresConfig.cmake exported build "
"directory: ${CERES_EXPORTED_BUILD_DIR}, does not contain Ceres headers.")
endif (NOT EXISTS ${CERES_INCLUDE_DIR}/ceres/ceres.h)
list(APPEND CERES_INCLUDE_DIRS ${CERES_INCLUDE_DIR})
# Append the path to the configured config.h in the exported build directory
# to the Ceres include directories.
set(CERES_CONFIG_FILE
${CERES_EXPORTED_BUILD_DIR}/config/ceres/internal/config.h)
if (NOT EXISTS ${CERES_CONFIG_FILE})
ceres_report_not_found(
"Ceres exported build directory: ${CERES_EXPORTED_BUILD_DIR}, "
"does not contain required configured Ceres config.h, it is not here: "
"${CERES_CONFIG_FILE}.")
endif (NOT EXISTS ${CERES_CONFIG_FILE})
list(APPEND CERES_INCLUDE_DIRS ${CERES_EXPORTED_BUILD_DIR}/config)
endif(CERES_WAS_INSTALLED)
# Set the version.
set(CERES_VERSION @CERES_VERSION@ )
# Eigen.
# Flag set during configuration and build of Ceres.
set(CERES_EIGEN_VERSION @EIGEN_VERSION@)
# Append the locations of Eigen when Ceres was built to the search path hints.
list(APPEND EIGEN_INCLUDE_DIR_HINTS @EIGEN_INCLUDE_DIR@)
# Search quietly to control the timing of the error message if not found. The
# search should be for an exact match, but for usability reasons do a soft
# match and reject with an explanation below.
find_package(Eigen ${CERES_EIGEN_VERSION} QUIET)
if (EIGEN_FOUND)
if (NOT EIGEN_VERSION VERSION_EQUAL CERES_EIGEN_VERSION)
# CMake's VERSION check in FIND_PACKAGE() will accept any version >= the
# specified version. However, only version = is supported. Improve
# usability by explaining why we don't accept non-exact version matching.
ceres_report_not_found("Found Eigen dependency, but the version of Eigen "
"found (${EIGEN_VERSION}) does not exactly match the version of Eigen "
"Ceres was compiled with (${CERES_EIGEN_VERSION}). This can cause subtle "
"bugs by triggering violations of the One Definition Rule. See the "
"Wikipedia article http://en.wikipedia.org/wiki/One_Definition_Rule "
"for more details")
endif ()
message(STATUS "Found required Ceres dependency: "
"Eigen version ${CERES_EIGEN_VERSION} in ${EIGEN_INCLUDE_DIRS}")
else (EIGEN_FOUND)
ceres_report_not_found("Missing required Ceres "
"dependency: Eigen version ${CERES_EIGEN_VERSION}, please set "
"EIGEN_INCLUDE_DIR.")
endif (EIGEN_FOUND)
list(APPEND CERES_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
# Glog.
# Flag set during configuration and build of Ceres.
set(CERES_USES_MINIGLOG @MINIGLOG@)
if (CERES_USES_MINIGLOG)
set(MINIGLOG_INCLUDE_DIR ${CERES_INCLUDE_DIR}/ceres/internal/miniglog)
if (NOT EXISTS ${MINIGLOG_INCLUDE_DIR})
ceres_report_not_found(
"Ceres include directory: "
"${CERES_INCLUDE_DIR} does not include miniglog, but Ceres was "
"compiled with MINIGLOG enabled (in place of Glog).")
endif (NOT EXISTS ${MINIGLOG_INCLUDE_DIR})
list(APPEND CERES_INCLUDE_DIRS ${MINIGLOG_INCLUDE_DIR})
# Output message at standard log level (not the lower STATUS) so that
# the message is output in GUI during configuration to warn user.
message("-- Found Ceres compiled with miniglog substitute "
"for glog, beware this will likely cause problems if glog is later linked.")
else (CERES_USES_MINIGLOG)
# Append the locations of glog when Ceres was built to the search path hints.
list(APPEND GLOG_INCLUDE_DIR_HINTS @GLOG_INCLUDE_DIR@)
get_filename_component(CERES_BUILD_GLOG_LIBRARY_DIR @GLOG_LIBRARY@ PATH)
list(APPEND GLOG_LIBRARY_DIR_HINTS ${CERES_BUILD_GLOG_LIBRARY_DIR})
# Search quietly s/t we control the timing of the error message if not found.
find_package(Glog QUIET)
if (GLOG_FOUND)
message(STATUS "Found required Ceres dependency: "
"Glog in ${GLOG_INCLUDE_DIRS}")
else (GLOG_FOUND)
ceres_report_not_found("Missing required Ceres "
"dependency: Glog, please set GLOG_INCLUDE_DIR.")
endif (GLOG_FOUND)
list(APPEND CERES_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS})
endif (CERES_USES_MINIGLOG)
# Import exported Ceres targets, if they have not already been imported.
if (NOT TARGET ceres AND NOT Ceres_BINARY_DIR)
include(${CERES_CURRENT_CONFIG_DIR}/CeresTargets.cmake)
endif (NOT TARGET ceres AND NOT Ceres_BINARY_DIR)
# Set the expected XX_LIBRARIES variable for FindPackage().
set(CERES_LIBRARIES ceres)
# Make user aware of any compile flags that will be added to their targets
# which use Ceres (i.e. flags exported in the Ceres target). Only CMake
# versions >= 2.8.12 support target_compile_options().
if (TARGET ${CERES_LIBRARIES} AND
NOT CMAKE_VERSION VERSION_LESS "2.8.12")
get_target_property(CERES_INTERFACE_COMPILE_OPTIONS
${CERES_LIBRARIES} INTERFACE_COMPILE_OPTIONS)
if (CERES_WAS_INSTALLED)
set(CERES_LOCATION "${CURRENT_ROOT_INSTALL_DIR}")
else()
set(CERES_LOCATION "${CERES_EXPORTED_BUILD_DIR}")
endif()
# Check for -std=c++11 flags.
if (CERES_INTERFACE_COMPILE_OPTIONS MATCHES ".*std=c\\+\\+11.*")
message(STATUS "Ceres version ${CERES_VERSION} detected here: "
"${CERES_LOCATION} was built with C++11. Ceres target will add "
"C++11 flags to compile options for targets using it.")
endif()
endif()
# Set legacy include directories variable for backwards compatibility.
set(CERES_INCLUDES ${CERES_INCLUDE_DIRS})
# Reset CMake module path to its state when this script was called.
set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH})
# As we use CERES_REPORT_NOT_FOUND() to abort, if we reach this point we have
# found Ceres and all required dependencies.
if (CERES_WAS_INSTALLED)
message(STATUS "Found Ceres version: ${CERES_VERSION} "
"installed in: ${CURRENT_ROOT_INSTALL_DIR}")
else (CERES_WAS_INSTALLED)
message(STATUS "Found Ceres version: ${CERES_VERSION} "
"exported from build directory: ${CERES_EXPORTED_BUILD_DIR}")
endif()
# Set CERES_FOUND to be equivalent to Ceres_FOUND, which is set to
# TRUE by FindPackage() if this file is found and run, and after which
# Ceres_FOUND is not (explicitly, i.e. undefined does not count) set
# to FALSE.
set(CERES_FOUND TRUE)

View File

@@ -0,0 +1,50 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: pablo.speciale@gmail.com (Pablo Speciale)
#
# FIND_PACKAGE() searches for a <package>Config.cmake file and an associated
# <package>Version.cmake file, which it loads to check the version number.
#
# This file can be used with CONFIGURE_FILE() to generate such a file for a
# project with very basic logic.
#
# It sets PACKAGE_VERSION_EXACT if the current version string and the requested
# version string are exactly the same and it sets PACKAGE_VERSION_COMPATIBLE
# if the current version is >= requested version.
set(PACKAGE_VERSION @CERES_VERSION@)
if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif ("${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
endif ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")

View File

@@ -0,0 +1,115 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
# This must take place outside of CONFIGURE_CERES_CONFIG() in order that
# we can determine where *this* file is, and thus the relative path to
# config.h.in. Inside of CONFIGURE_CERES_CONFIG(), CMAKE_CURRENT_LIST_DIR
# refers to the caller of CONFIGURE_CERES_CONFIG(), not this file.
set(CERES_CONFIG_IN_FILE "${CMAKE_CURRENT_LIST_DIR}/config.h.in")
# CreateCeresConfig.cmake - Create the config.h for Ceres.
#
# This function configures the Ceres config.h file based on the current
# compile options and copies it into the specified location. It should be
# called before Ceres is built so that the correct config.h is used when
# Ceres is compiled.
#
# INPUTS:
# CURRENT_CERES_COMPILE_OPTIONS: List of currently enabled Ceres compile
# options. These are compared against the
# full list of valid options, which are read
# from config.h.in. Any options present
# which are not part of the valid set will
# invoke an error. Any valid option present
# will be enabled in the resulting config.h,
# all other options will be disabled.
#
# CERES_CONFIG_OUTPUT_DIRECTORY: Path to output directory in which to save
# the configured config.h. Typically this
# will be <src>/include/ceres/internal.
function(CREATE_CERES_CONFIG CURRENT_CERES_COMPILE_OPTIONS CERES_CONFIG_OUTPUT_DIRECTORY)
# Create the specified output directory if it does not exist.
if (NOT EXISTS "${CERES_CONFIG_OUTPUT_DIRECTORY}")
message(STATUS "Creating configured Ceres config.h output directory: "
"${CERES_CONFIG_OUTPUT_DIRECTORY}")
file(MAKE_DIRECTORY "${CERES_CONFIG_OUTPUT_DIRECTORY}")
endif()
if (EXISTS "${CERES_CONFIG_OUTPUT_DIRECTORY}" AND
NOT IS_DIRECTORY "${CERES_CONFIG_OUTPUT_DIRECTORY}")
message(FATAL_ERROR "Ceres Bug: Specified CERES_CONFIG_OUTPUT_DIRECTORY: "
"${CERES_CONFIG_OUTPUT_DIRECTORY} exists, but is not a directory.")
endif()
# Read all possible configurable compile options from config.h.in, this avoids
# us having to hard-code in this file what the valid options are.
file(READ ${CERES_CONFIG_IN_FILE} CERES_CONFIG_IN_CONTENTS)
string(REGEX MATCHALL "@[^@ $]+@"
ALL_CONFIGURABLE_CERES_OPTIONS "${CERES_CONFIG_IN_CONTENTS}")
# Removing @ symbols at beginning and end of each option.
string(REPLACE "@" ""
ALL_CONFIGURABLE_CERES_OPTIONS "${ALL_CONFIGURABLE_CERES_OPTIONS}")
# Ensure that there are no repetitions in the current compile options.
list(REMOVE_DUPLICATES CURRENT_CERES_COMPILE_OPTIONS)
foreach (CERES_OPTION ${ALL_CONFIGURABLE_CERES_OPTIONS})
# Try and find the option in the list of current compile options, if it
# is present, then the option is enabled, otherwise it is disabled.
list(FIND CURRENT_CERES_COMPILE_OPTIONS ${CERES_OPTION} OPTION_ENABLED)
# list(FIND ..) returns -1 if the element was not in the list, but CMake
# interprets if (VAR) to be true if VAR is any non-zero number, even
# negative ones, hence we have to explicitly check for >= 0.
if (OPTION_ENABLED GREATER -1)
message(STATUS "Enabling ${CERES_OPTION} in Ceres config.h")
set(${CERES_OPTION} "#define ${CERES_OPTION}")
# Remove the item from the list of current options so that we can identify
# any options that were in CURRENT_CERES_COMPILE_OPTIONS, but not in
# ALL_CONFIGURABLE_CERES_OPTIONS (which is an error).
list(REMOVE_ITEM CURRENT_CERES_COMPILE_OPTIONS ${CERES_OPTION})
else()
set(${CERES_OPTION} "// #define ${CERES_OPTION}")
endif()
endforeach()
# CURRENT_CERES_COMPILE_OPTIONS should now be an empty list, any elements
# remaining were not present in ALL_CONFIGURABLE_CERES_OPTIONS read from
# config.h.in.
if (CURRENT_CERES_COMPILE_OPTIONS)
message(FATAL_ERROR "Ceres Bug: CURRENT_CERES_COMPILE_OPTIONS contained "
"the following options which were not present in config.h.in: "
"${CURRENT_CERES_COMPILE_OPTIONS}")
endif()
configure_file(${CERES_CONFIG_IN_FILE}
"${CERES_CONFIG_OUTPUT_DIRECTORY}/config.h" @ONLY)
endfunction()

View File

@@ -0,0 +1,228 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
#
# FindCXSparse.cmake - Find CXSparse libraries & dependencies.
#
# This module defines the following variables which should be referenced
# by the caller to use the library.
#
# CXSPARSE_FOUND: TRUE iff CXSparse and all dependencies have been found.
# CXSPARSE_INCLUDE_DIRS: Include directories for CXSparse.
# CXSPARSE_LIBRARIES: Libraries for CXSparse and all dependencies.
#
# CXSPARSE_VERSION: Extracted from cs.h.
# CXSPARSE_MAIN_VERSION: Equal to 3 if CXSPARSE_VERSION = 3.1.2
# CXSPARSE_SUB_VERSION: Equal to 1 if CXSPARSE_VERSION = 3.1.2
# CXSPARSE_SUBSUB_VERSION: Equal to 2 if CXSPARSE_VERSION = 3.1.2
#
# The following variables control the behaviour of this module:
#
# CXSPARSE_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for CXSparse includes,
# e.g: /timbuktu/include.
# CXSPARSE_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for CXSparse libraries, e.g: /timbuktu/lib.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead). These variables
# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# CXSPARSE_INCLUDE_DIR: Include directory for CXSparse, not including the
# include directory of any dependencies.
# CXSPARSE_LIBRARY: CXSparse library, not including the libraries of any
# dependencies.
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when
# FindCXSparse was invoked.
macro(CXSPARSE_RESET_FIND_LIBRARY_PREFIX)
if (MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
endmacro(CXSPARSE_RESET_FIND_LIBRARY_PREFIX)
# Called if we failed to find CXSparse or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(CXSPARSE_REPORT_NOT_FOUND REASON_MSG)
unset(CXSPARSE_FOUND)
unset(CXSPARSE_INCLUDE_DIRS)
unset(CXSPARSE_LIBRARIES)
# Make results of search visible in the CMake GUI if CXSparse has not
# been found so that user does not have to toggle to advanced view.
mark_as_advanced(CLEAR CXSPARSE_INCLUDE_DIR
CXSPARSE_LIBRARY)
cxsparse_reset_find_library_prefix()
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if (CXSparse_FIND_QUIETLY)
message(STATUS "Failed to find CXSparse - " ${REASON_MSG} ${ARGN})
elseif (CXSparse_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find CXSparse - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message("-- Failed to find CXSparse - " ${REASON_MSG} ${ARGN})
endif ()
endmacro(CXSPARSE_REPORT_NOT_FOUND)
# Handle possible presence of lib prefix for libraries on MSVC, see
# also CXSPARSE_RESET_FIND_LIBRARY_PREFIX().
if (MSVC)
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
# s/t we can set it back before returning.
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The empty string in this list is important, it represents the case when
# the libraries have no prefix (shared libraries / DLLs).
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
# Search user-installed locations first, so that we prefer user installs
# to system installs where both exist.
#
# TODO: Add standard Windows search locations for CXSparse.
list(APPEND CXSPARSE_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include)
list(APPEND CXSPARSE_CHECK_LIBRARY_DIRS
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
/opt/local/lib
/usr/lib)
# Search supplied hint directories first if supplied.
find_path(CXSPARSE_INCLUDE_DIR
NAMES cs.h
PATHS ${CXSPARSE_INCLUDE_DIR_HINTS}
${CXSPARSE_CHECK_INCLUDE_DIRS})
if (NOT CXSPARSE_INCLUDE_DIR OR
NOT EXISTS ${CXSPARSE_INCLUDE_DIR})
cxsparse_report_not_found(
"Could not find CXSparse include directory, set CXSPARSE_INCLUDE_DIR "
"to directory containing cs.h")
endif (NOT CXSPARSE_INCLUDE_DIR OR
NOT EXISTS ${CXSPARSE_INCLUDE_DIR})
find_library(CXSPARSE_LIBRARY NAMES cxsparse
PATHS ${CXSPARSE_LIBRARY_DIR_HINTS}
${CXSPARSE_CHECK_LIBRARY_DIRS})
if (NOT CXSPARSE_LIBRARY OR
NOT EXISTS ${CXSPARSE_LIBRARY})
cxsparse_report_not_found(
"Could not find CXSparse library, set CXSPARSE_LIBRARY "
"to full path to libcxsparse.")
endif (NOT CXSPARSE_LIBRARY OR
NOT EXISTS ${CXSPARSE_LIBRARY})
# Mark internally as found, then verify. CXSPARSE_REPORT_NOT_FOUND() unsets
# if called.
set(CXSPARSE_FOUND TRUE)
# Extract CXSparse version from cs.h
if (CXSPARSE_INCLUDE_DIR)
set(CXSPARSE_VERSION_FILE ${CXSPARSE_INCLUDE_DIR}/cs.h)
if (NOT EXISTS ${CXSPARSE_VERSION_FILE})
cxsparse_report_not_found(
"Could not find file: ${CXSPARSE_VERSION_FILE} "
"containing version information in CXSparse install located at: "
"${CXSPARSE_INCLUDE_DIR}.")
else (NOT EXISTS ${CXSPARSE_VERSION_FILE})
file(READ ${CXSPARSE_INCLUDE_DIR}/cs.h CXSPARSE_VERSION_FILE_CONTENTS)
string(REGEX MATCH "#define CS_VER [0-9]+"
CXSPARSE_MAIN_VERSION "${CXSPARSE_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "#define CS_VER ([0-9]+)" "\\1"
CXSPARSE_MAIN_VERSION "${CXSPARSE_MAIN_VERSION}")
string(REGEX MATCH "#define CS_SUBVER [0-9]+"
CXSPARSE_SUB_VERSION "${CXSPARSE_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "#define CS_SUBVER ([0-9]+)" "\\1"
CXSPARSE_SUB_VERSION "${CXSPARSE_SUB_VERSION}")
string(REGEX MATCH "#define CS_SUBSUB [0-9]+"
CXSPARSE_SUBSUB_VERSION "${CXSPARSE_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "#define CS_SUBSUB ([0-9]+)" "\\1"
CXSPARSE_SUBSUB_VERSION "${CXSPARSE_SUBSUB_VERSION}")
# This is on a single line s/t CMake does not interpret it as a list of
# elements and insert ';' separators which would result in 3.;1.;2 nonsense.
set(CXSPARSE_VERSION "${CXSPARSE_MAIN_VERSION}.${CXSPARSE_SUB_VERSION}.${CXSPARSE_SUBSUB_VERSION}")
endif (NOT EXISTS ${CXSPARSE_VERSION_FILE})
endif (CXSPARSE_INCLUDE_DIR)
# Catch the case when the caller has set CXSPARSE_LIBRARY in the cache / GUI and
# thus FIND_LIBRARY was not called, but specified library is invalid, otherwise
# we would report CXSparse as found.
# TODO: This regex for CXSparse library is pretty primitive, we use lowercase
# for comparison to handle Windows using CamelCase library names, could
# this check be better?
string(TOLOWER "${CXSPARSE_LIBRARY}" LOWERCASE_CXSPARSE_LIBRARY)
if (CXSPARSE_LIBRARY AND
EXISTS ${CXSPARSE_LIBRARY} AND
NOT "${LOWERCASE_CXSPARSE_LIBRARY}" MATCHES ".*cxsparse[^/]*")
cxsparse_report_not_found(
"Caller defined CXSPARSE_LIBRARY: "
"${CXSPARSE_LIBRARY} does not match CXSparse.")
endif (CXSPARSE_LIBRARY AND
EXISTS ${CXSPARSE_LIBRARY} AND
NOT "${LOWERCASE_CXSPARSE_LIBRARY}" MATCHES ".*cxsparse[^/]*")
# Set standard CMake FindPackage variables if found.
if (CXSPARSE_FOUND)
set(CXSPARSE_INCLUDE_DIRS ${CXSPARSE_INCLUDE_DIR})
set(CXSPARSE_LIBRARIES ${CXSPARSE_LIBRARY})
endif (CXSPARSE_FOUND)
cxsparse_reset_find_library_prefix()
# Handle REQUIRED / QUIET optional arguments and version.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CXSparse
REQUIRED_VARS CXSPARSE_INCLUDE_DIRS CXSPARSE_LIBRARIES
VERSION_VAR CXSPARSE_VERSION)
# Only mark internal variables as advanced if we found CXSparse, otherwise
# leave them visible in the standard GUI for the user to set manually.
if (CXSPARSE_FOUND)
mark_as_advanced(FORCE CXSPARSE_INCLUDE_DIR
CXSPARSE_LIBRARY)
endif (CXSPARSE_FOUND)

View File

@@ -0,0 +1,166 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
#
# FindEigen.cmake - Find Eigen library, version >= 3.
#
# This module defines the following variables:
#
# EIGEN_FOUND: TRUE iff Eigen is found.
# EIGEN_INCLUDE_DIRS: Include directories for Eigen.
#
# EIGEN_VERSION: Extracted from Eigen/src/Core/util/Macros.h
# EIGEN_WORLD_VERSION: Equal to 3 if EIGEN_VERSION = 3.2.0
# EIGEN_MAJOR_VERSION: Equal to 2 if EIGEN_VERSION = 3.2.0
# EIGEN_MINOR_VERSION: Equal to 0 if EIGEN_VERSION = 3.2.0
#
# The following variables control the behaviour of this module:
#
# EIGEN_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for eigen includes, e.g: /timbuktu/eigen3.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead). These variables
# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# EIGEN_INCLUDE_DIR: Include directory for CXSparse, not including the
# include directory of any dependencies.
# Called if we failed to find Eigen or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(EIGEN_REPORT_NOT_FOUND REASON_MSG)
unset(EIGEN_FOUND)
unset(EIGEN_INCLUDE_DIRS)
# Make results of search visible in the CMake GUI if Eigen has not
# been found so that user does not have to toggle to advanced view.
mark_as_advanced(CLEAR EIGEN_INCLUDE_DIR)
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if (Eigen_FIND_QUIETLY)
message(STATUS "Failed to find Eigen - " ${REASON_MSG} ${ARGN})
elseif (Eigen_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find Eigen - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message("-- Failed to find Eigen - " ${REASON_MSG} ${ARGN})
endif ()
endmacro(EIGEN_REPORT_NOT_FOUND)
# Search user-installed locations first, so that we prefer user installs
# to system installs where both exist.
#
# TODO: Add standard Windows search locations for Eigen.
list(APPEND EIGEN_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include)
# Additional suffixes to try appending to each search path.
list(APPEND EIGEN_CHECK_PATH_SUFFIXES
eigen3 # Default root directory for Eigen.
Eigen/include/eigen3 ) # Windows (for C:/Program Files prefix).
# Search supplied hint directories first if supplied.
find_path(EIGEN_INCLUDE_DIR
NAMES Eigen/Core
PATHS ${EIGEN_INCLUDE_DIR_HINTS}
${EIGEN_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES ${EIGEN_CHECK_PATH_SUFFIXES})
if (NOT EIGEN_INCLUDE_DIR OR
NOT EXISTS ${EIGEN_INCLUDE_DIR})
eigen_report_not_found(
"Could not find eigen3 include directory, set EIGEN_INCLUDE_DIR to "
"path to eigen3 include directory, e.g. /usr/local/include/eigen3.")
endif (NOT EIGEN_INCLUDE_DIR OR
NOT EXISTS ${EIGEN_INCLUDE_DIR})
# Mark internally as found, then verify. EIGEN_REPORT_NOT_FOUND() unsets
# if called.
set(EIGEN_FOUND TRUE)
# Extract Eigen version from Eigen/src/Core/util/Macros.h
if (EIGEN_INCLUDE_DIR)
set(EIGEN_VERSION_FILE ${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h)
if (NOT EXISTS ${EIGEN_VERSION_FILE})
eigen_report_not_found(
"Could not find file: ${EIGEN_VERSION_FILE} "
"containing version information in Eigen install located at: "
"${EIGEN_INCLUDE_DIR}.")
else (NOT EXISTS ${EIGEN_VERSION_FILE})
file(READ ${EIGEN_VERSION_FILE} EIGEN_VERSION_FILE_CONTENTS)
string(REGEX MATCH "#define EIGEN_WORLD_VERSION [0-9]+"
EIGEN_WORLD_VERSION "${EIGEN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "#define EIGEN_WORLD_VERSION ([0-9]+)" "\\1"
EIGEN_WORLD_VERSION "${EIGEN_WORLD_VERSION}")
string(REGEX MATCH "#define EIGEN_MAJOR_VERSION [0-9]+"
EIGEN_MAJOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "#define EIGEN_MAJOR_VERSION ([0-9]+)" "\\1"
EIGEN_MAJOR_VERSION "${EIGEN_MAJOR_VERSION}")
string(REGEX MATCH "#define EIGEN_MINOR_VERSION [0-9]+"
EIGEN_MINOR_VERSION "${EIGEN_VERSION_FILE_CONTENTS}")
string(REGEX REPLACE "#define EIGEN_MINOR_VERSION ([0-9]+)" "\\1"
EIGEN_MINOR_VERSION "${EIGEN_MINOR_VERSION}")
# This is on a single line s/t CMake does not interpret it as a list of
# elements and insert ';' separators which would result in 3.;2.;0 nonsense.
set(EIGEN_VERSION "${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}")
endif (NOT EXISTS ${EIGEN_VERSION_FILE})
endif (EIGEN_INCLUDE_DIR)
# Set standard CMake FindPackage variables if found.
if (EIGEN_FOUND)
set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR})
endif (EIGEN_FOUND)
# Handle REQUIRED / QUIET optional arguments and version.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen
REQUIRED_VARS EIGEN_INCLUDE_DIRS
VERSION_VAR EIGEN_VERSION)
# Only mark internal variables as advanced if we found Eigen, otherwise
# leave it visible in the standard GUI for the user to set manually.
if (EIGEN_FOUND)
mark_as_advanced(FORCE EIGEN_INCLUDE_DIR)
endif (EIGEN_FOUND)

View File

@@ -0,0 +1,581 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
#
# FindGflags.cmake - Find Google gflags logging library.
#
# This module will attempt to find gflags, either via an exported CMake
# configuration (generated by gflags >= 2.1 which are built with CMake), or
# by performing a standard search for all gflags components. The order of
# precedence for these two methods of finding gflags is controlled by:
# GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION.
#
# This module defines the following variables:
#
# GFLAGS_FOUND: TRUE iff gflags is found.
# GFLAGS_INCLUDE_DIRS: Include directories for gflags.
# GFLAGS_LIBRARIES: Libraries required to link gflags.
# GFLAGS_NAMESPACE: The namespace in which gflags is defined. In versions of
# gflags < 2.1, this was google, for versions >= 2.1 it is
# by default gflags, although can be configured when building
# gflags to be something else (i.e. google for legacy
# compatibility).
#
# The following variables control the behaviour of this module when an exported
# gflags CMake configuration is not found.
#
# GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION: TRUE/FALSE, iff TRUE then
# then prefer using an exported CMake configuration
# generated by gflags >= 2.1 over searching for the
# gflags components manually. Otherwise (FALSE)
# ignore any exported gflags CMake configurations and
# always perform a manual search for the components.
# Default: TRUE iff user does not define this variable
# before we are called, and does NOT specify either
# GFLAGS_INCLUDE_DIR_HINTS or GFLAGS_LIBRARY_DIR_HINTS
# otherwise FALSE.
# GFLAGS_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for gflags includes, e.g: /timbuktu/include.
# GFLAGS_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for gflags libraries, e.g: /timbuktu/lib.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead). These variables
# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# GFLAGS_INCLUDE_DIR: Include directory for gflags, not including the
# include directory of any dependencies.
# GFLAGS_LIBRARY: gflags library, not including the libraries of any
# dependencies.
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when FindGflags was
# invoked, necessary for MSVC.
macro(GFLAGS_RESET_FIND_LIBRARY_PREFIX)
if (MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
endmacro(GFLAGS_RESET_FIND_LIBRARY_PREFIX)
# Called if we failed to find gflags or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(GFLAGS_REPORT_NOT_FOUND REASON_MSG)
unset(GFLAGS_FOUND)
unset(GFLAGS_INCLUDE_DIRS)
unset(GFLAGS_LIBRARIES)
# Do not use unset, as we want to keep GFLAGS_NAMESPACE in the cache,
# but simply clear its value.
set(GFLAGS_NAMESPACE "" CACHE STRING
"gflags namespace (google or gflags)" FORCE)
# Make results of search visible in the CMake GUI if gflags has not
# been found so that user does not have to toggle to advanced view.
mark_as_advanced(CLEAR GFLAGS_INCLUDE_DIR
GFLAGS_LIBRARY
GFLAGS_NAMESPACE)
gflags_reset_find_library_prefix()
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if (Gflags_FIND_QUIETLY)
message(STATUS "Failed to find gflags - " ${REASON_MSG} ${ARGN})
elseif (Gflags_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find gflags - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message("-- Failed to find gflags - " ${REASON_MSG} ${ARGN})
endif ()
endmacro(GFLAGS_REPORT_NOT_FOUND)
# Verify that all variable names passed as arguments are defined (can be empty
# but must be defined) or raise a fatal error.
macro(GFLAGS_CHECK_VARS_DEFINED)
foreach(CHECK_VAR ${ARGN})
if (NOT DEFINED ${CHECK_VAR})
message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.")
endif()
endforeach()
endmacro(GFLAGS_CHECK_VARS_DEFINED)
# Use check_cxx_source_compiles() to compile trivial test programs to determine
# the gflags namespace. This works on all OSs except Windows. If using Visual
# Studio, it fails because msbuild forces check_cxx_source_compiles() to use
# CMAKE_BUILD_TYPE=Debug for the test project, which usually breaks detection
# because MSVC requires that the test project use the same build type as gflags,
# which would normally be built in Release.
#
# Defines: GFLAGS_NAMESPACE in the caller's scope with the detected namespace,
# which is blank (empty string, will test FALSE is CMake conditionals)
# if detection failed.
function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE)
# Verify that all required variables are defined.
gflags_check_vars_defined(
GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
# Ensure that GFLAGS_NAMESPACE is always unset on completion unless
# we explicitly set if after having the correct namespace.
set(GFLAGS_NAMESPACE "" PARENT_SCOPE)
include(CheckCXXSourceCompiles)
# Setup include path & link library for gflags for CHECK_CXX_SOURCE_COMPILES.
set(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES})
# First try the (older) google namespace. Note that the output variable
# MUST be unique to the build type as otherwise the test is not repeated as
# it is assumed to have already been performed.
check_cxx_source_compiles(
"#include <gflags/gflags.h>
int main(int argc, char * argv[]) {
google::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}"
GFLAGS_IN_GOOGLE_NAMESPACE)
if (GFLAGS_IN_GOOGLE_NAMESPACE)
set(GFLAGS_NAMESPACE google PARENT_SCOPE)
return()
endif()
# Try (newer) gflags namespace instead. Note that the output variable
# MUST be unique to the build type as otherwise the test is not repeated as
# it is assumed to have already been performed.
set(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES})
check_cxx_source_compiles(
"#include <gflags/gflags.h>
int main(int argc, char * argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}"
GFLAGS_IN_GFLAGS_NAMESPACE)
if (GFLAGS_IN_GFLAGS_NAMESPACE)
set(GFLAGS_NAMESPACE gflags PARENT_SCOPE)
return()
endif (GFLAGS_IN_GFLAGS_NAMESPACE)
endfunction(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE)
# Use regex on the gflags headers to attempt to determine the gflags namespace.
# Checks both gflags.h (contained namespace on versions < 2.1.2) and
# gflags_declare.h, which contains the namespace on versions >= 2.1.2.
# In general, this method should only be used when
# GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE() cannot be used, or has
# failed.
#
# Defines: GFLAGS_NAMESPACE in the caller's scope with the detected namespace,
# which is blank (empty string, will test FALSE is CMake conditionals)
# if detection failed.
function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX)
# Verify that all required variables are defined.
gflags_check_vars_defined(GFLAGS_INCLUDE_DIR)
# Ensure that GFLAGS_NAMESPACE is always undefined on completion unless
# we explicitly set if after having the correct namespace.
set(GFLAGS_NAMESPACE "" PARENT_SCOPE)
# Scan gflags.h to identify what namespace gflags was built with. On
# versions of gflags < 2.1.2, gflags.h was configured with the namespace
# directly, on >= 2.1.2, gflags.h uses the GFLAGS_NAMESPACE #define which
# is defined in gflags_declare.h, we try each location in turn.
set(GFLAGS_HEADER_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
if (NOT EXISTS ${GFLAGS_HEADER_FILE})
gflags_report_not_found(
"Could not find file: ${GFLAGS_HEADER_FILE} "
"containing namespace information in gflags install located at: "
"${GFLAGS_INCLUDE_DIR}.")
endif()
file(READ ${GFLAGS_HEADER_FILE} GFLAGS_HEADER_FILE_CONTENTS)
string(REGEX MATCH "namespace [A-Za-z]+"
GFLAGS_NAMESPACE "${GFLAGS_HEADER_FILE_CONTENTS}")
string(REGEX REPLACE "namespace ([A-Za-z]+)" "\\1"
GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}")
if (NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to extract gflags namespace from header file: "
"${GFLAGS_HEADER_FILE}.")
endif (NOT GFLAGS_NAMESPACE)
if (GFLAGS_NAMESPACE STREQUAL "google" OR
GFLAGS_NAMESPACE STREQUAL "gflags")
# Found valid gflags namespace from gflags.h.
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE)
return()
endif()
# Failed to find gflags namespace from gflags.h, gflags is likely a new
# version, check gflags_declare.h, which in newer versions (>= 2.1.2) contains
# the GFLAGS_NAMESPACE #define, which is then referenced in gflags.h.
set(GFLAGS_DECLARE_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags_declare.h)
if (NOT EXISTS ${GFLAGS_DECLARE_FILE})
gflags_report_not_found(
"Could not find file: ${GFLAGS_DECLARE_FILE} "
"containing namespace information in gflags install located at: "
"${GFLAGS_INCLUDE_DIR}.")
endif()
file(READ ${GFLAGS_DECLARE_FILE} GFLAGS_DECLARE_FILE_CONTENTS)
string(REGEX MATCH "#define GFLAGS_NAMESPACE [A-Za-z]+"
GFLAGS_NAMESPACE "${GFLAGS_DECLARE_FILE_CONTENTS}")
string(REGEX REPLACE "#define GFLAGS_NAMESPACE ([A-Za-z]+)" "\\1"
GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}")
if (NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to extract gflags namespace from declare file: "
"${GFLAGS_DECLARE_FILE}.")
endif (NOT GFLAGS_NAMESPACE)
if (GFLAGS_NAMESPACE STREQUAL "google" OR
GFLAGS_NAMESPACE STREQUAL "gflags")
# Found valid gflags namespace from gflags.h.
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE)
return()
endif()
endfunction(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX)
# -----------------------------------------------------------------
# By default, if the user has expressed no preference for using an exported
# gflags CMake configuration over performing a search for the installed
# components, and has not specified any hints for the search locations, then
# prefer a gflags exported configuration if available.
if (NOT DEFINED GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION
AND NOT GFLAGS_INCLUDE_DIR_HINTS
AND NOT GFLAGS_LIBRARY_DIR_HINTS)
message(STATUS "No preference for use of exported gflags CMake configuration "
"set, and no hints for include/library directories provided. "
"Defaulting to preferring an installed/exported gflags CMake configuration "
"if available.")
set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE)
endif()
if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
# Try to find an exported CMake configuration for gflags, as generated by
# gflags versions >= 2.1.
#
# We search twice, s/t we can invert the ordering of precedence used by
# find_package() for exported package build directories, and installed
# packages (found via CMAKE_SYSTEM_PREFIX_PATH), listed as items 6) and 7)
# respectively in [1].
#
# By default, exported build directories are (in theory) detected first, and
# this is usually the case on Windows. However, on OS X & Linux, the install
# path (/usr/local) is typically present in the PATH environment variable
# which is checked in item 4) in [1] (i.e. before both of the above, unless
# NO_SYSTEM_ENVIRONMENT_PATH is passed). As such on those OSs installed
# packages are usually detected in preference to exported package build
# directories.
#
# To ensure a more consistent response across all OSs, and as users usually
# want to prefer an installed version of a package over a locally built one
# where both exist (esp. as the exported build directory might be removed
# after installation), we first search with NO_CMAKE_PACKAGE_REGISTRY which
# means any build directories exported by the user are ignored, and thus
# installed directories are preferred. If this fails to find the package
# we then research again, but without NO_CMAKE_PACKAGE_REGISTRY, so any
# exported build directories will now be detected.
#
# To prevent confusion on Windows, we also pass NO_CMAKE_BUILDS_PATH (which
# is item 5) in [1]), to not preferentially use projects that were built
# recently with the CMake GUI to ensure that we always prefer an installed
# version if available.
#
# [1] http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_package
find_package(gflags QUIET
NO_MODULE
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_BUILDS_PATH)
if (gflags_FOUND)
message(STATUS "Found installed version of gflags: ${gflags_DIR}")
else(gflags_FOUND)
# Failed to find an installed version of gflags, repeat search allowing
# exported build directories.
message(STATUS "Failed to find installed gflags CMake configuration, "
"searching for gflags build directories exported with CMake.")
# Again pass NO_CMAKE_BUILDS_PATH, as we know that gflags is exported and
# do not want to treat projects built with the CMake GUI preferentially.
find_package(gflags QUIET
NO_MODULE
NO_CMAKE_BUILDS_PATH)
if (gflags_FOUND)
message(STATUS "Found exported gflags build directory: ${gflags_DIR}")
endif(gflags_FOUND)
endif(gflags_FOUND)
set(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION ${gflags_FOUND})
# gflags v2.1 - 2.1.2 shipped with a bug in their gflags-config.cmake [1]
# whereby gflags_LIBRARIES = "gflags", but there was no imported target
# called "gflags", they were called: gflags[_nothreads]-[static/shared].
# As this causes linker errors when gflags is not installed in a location
# on the current library paths, detect if this problem is present and
# fix it.
#
# [1] https://github.com/gflags/gflags/issues/110
if (gflags_FOUND)
# NOTE: This is not written as additional conditions in the outer
# if (gflags_FOUND) as the NOT TARGET "${gflags_LIBRARIES}"
# condition causes problems if gflags is not found.
if (${gflags_VERSION} VERSION_LESS 2.1.3 AND
NOT TARGET "${gflags_LIBRARIES}")
message(STATUS "Detected broken gflags install in: ${gflags_DIR}, "
"version: ${gflags_VERSION} <= 2.1.2 which defines gflags_LIBRARIES = "
"${gflags_LIBRARIES} which is not an imported CMake target, see: "
"https://github.com/gflags/gflags/issues/110. Attempting to fix by "
"detecting correct gflags target.")
# Ordering here expresses preference for detection, specifically we do not
# want to use the _nothreads variants if the full library is available.
list(APPEND CHECK_GFLAGS_IMPORTED_TARGET_NAMES
gflags-shared gflags-static
gflags_nothreads-shared gflags_nothreads-static)
foreach(CHECK_GFLAGS_TARGET ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES})
if (TARGET ${CHECK_GFLAGS_TARGET})
message(STATUS "Found valid gflags target: ${CHECK_GFLAGS_TARGET}, "
"updating gflags_LIBRARIES.")
set(gflags_LIBRARIES ${CHECK_GFLAGS_TARGET})
break()
endif()
endforeach()
if (NOT TARGET ${gflags_LIBRARIES})
message(STATUS "Failed to fix detected broken gflags install in: "
"${gflags_DIR}, version: ${gflags_VERSION} <= 2.1.2, none of the "
"imported targets for gflags: ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES} "
"are defined. Will continue with a manual search for gflags "
"components. We recommend you build/install a version of gflags > "
"2.1.2 (or master).")
set(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION FALSE)
endif()
endif()
endif()
if (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
message(STATUS "Detected gflags version: ${gflags_VERSION}")
set(GFLAGS_FOUND ${gflags_FOUND})
set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
# gflags does not export the namespace in their CMake configuration, so
# use our function to determine what it should be, as it can be either
# gflags or google dependent upon version & configuration.
#
# NOTE: We use the regex method to determine the namespace here, as
# check_cxx_source_compiles() will not use imported targets, which
# is what gflags will be in this case.
gflags_check_gflags_namespace_using_regex()
if (NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to determine gflags namespace using regex for gflags "
"version: ${gflags_VERSION} exported here: ${gflags_DIR} using CMake.")
endif (NOT GFLAGS_NAMESPACE)
else (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
message(STATUS "Failed to find an installed/exported CMake configuration "
"for gflags, will perform search for installed gflags components.")
endif (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
endif(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
if (NOT GFLAGS_FOUND)
# Either failed to find an exported gflags CMake configuration, or user
# told us not to use one. Perform a manual search for all gflags components.
# Handle possible presence of lib prefix for libraries on MSVC, see
# also GFLAGS_RESET_FIND_LIBRARY_PREFIX().
if (MSVC)
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
# s/t we can set it back before returning.
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The empty string in this list is important, it represents the case when
# the libraries have no prefix (shared libraries / DLLs).
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
# Search user-installed locations first, so that we prefer user installs
# to system installs where both exist.
list(APPEND GFLAGS_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include)
list(APPEND GFLAGS_CHECK_PATH_SUFFIXES
gflags/include # Windows (for C:/Program Files prefix).
gflags/Include ) # Windows (for C:/Program Files prefix).
list(APPEND GFLAGS_CHECK_LIBRARY_DIRS
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
/opt/local/lib
/usr/lib)
list(APPEND GFLAGS_CHECK_LIBRARY_SUFFIXES
gflags/lib # Windows (for C:/Program Files prefix).
gflags/Lib ) # Windows (for C:/Program Files prefix).
# Search supplied hint directories first if supplied.
find_path(GFLAGS_INCLUDE_DIR
NAMES gflags/gflags.h
PATHS ${GFLAGS_INCLUDE_DIR_HINTS}
${GFLAGS_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES ${GFLAGS_CHECK_PATH_SUFFIXES})
if (NOT GFLAGS_INCLUDE_DIR OR
NOT EXISTS ${GFLAGS_INCLUDE_DIR})
gflags_report_not_found(
"Could not find gflags include directory, set GFLAGS_INCLUDE_DIR "
"to directory containing gflags/gflags.h")
endif (NOT GFLAGS_INCLUDE_DIR OR
NOT EXISTS ${GFLAGS_INCLUDE_DIR})
find_library(GFLAGS_LIBRARY NAMES gflags
PATHS ${GFLAGS_LIBRARY_DIR_HINTS}
${GFLAGS_CHECK_LIBRARY_DIRS}
PATH_SUFFIXES ${GFLAGS_CHECK_LIBRARY_SUFFIXES})
if (NOT GFLAGS_LIBRARY OR
NOT EXISTS ${GFLAGS_LIBRARY})
gflags_report_not_found(
"Could not find gflags library, set GFLAGS_LIBRARY "
"to full path to libgflags.")
endif (NOT GFLAGS_LIBRARY OR
NOT EXISTS ${GFLAGS_LIBRARY})
# gflags typically requires a threading library (which is OS dependent), note
# that this defines the CMAKE_THREAD_LIBS_INIT variable. If we are able to
# detect threads, we assume that gflags requires it.
find_package(Threads QUIET)
set(GFLAGS_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
# On Windows (including MinGW), the Shlwapi library is used by gflags if
# available.
if (WIN32)
include(CheckIncludeFileCXX)
check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI)
if (HAVE_SHLWAPI)
list(APPEND GFLAGS_LINK_LIBRARIES shlwapi.lib)
endif(HAVE_SHLWAPI)
endif (WIN32)
# Mark internally as found, then verify. GFLAGS_REPORT_NOT_FOUND() unsets
# if called.
set(GFLAGS_FOUND TRUE)
# Identify what namespace gflags was built with.
if (GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE)
# To handle Windows peculiarities / CMake bugs on MSVC we try two approaches
# to detect the gflags namespace:
#
# 1) Try to use check_cxx_source_compiles() to compile a trivial program
# with the two choices for the gflags namespace.
#
# 2) [In the event 1) fails] Use regex on the gflags headers to try to
# determine the gflags namespace. Whilst this is less robust than 1),
# it does avoid any interaction with msbuild.
gflags_check_gflags_namespace_using_try_compile()
if (NOT GFLAGS_NAMESPACE)
# Failed to determine gflags namespace using check_cxx_source_compiles()
# method, try and obtain it using regex on the gflags headers instead.
message(STATUS "Failed to find gflags namespace using using "
"check_cxx_source_compiles(), trying namespace regex instead, "
"this is expected on Windows.")
gflags_check_gflags_namespace_using_regex()
if (NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to determine gflags namespace either by "
"check_cxx_source_compiles(), or namespace regex.")
endif (NOT GFLAGS_NAMESPACE)
endif (NOT GFLAGS_NAMESPACE)
endif (GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE)
# Make the GFLAGS_NAMESPACE a cache variable s/t the user can view it, and could
# overwrite it in the CMake GUI.
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" CACHE STRING
"gflags namespace (google or gflags)" FORCE)
# gflags does not seem to provide any record of the version in its
# source tree, thus cannot extract version.
# Catch case when caller has set GFLAGS_NAMESPACE in the cache / GUI
# with an invalid value.
if (GFLAGS_NAMESPACE AND
NOT GFLAGS_NAMESPACE STREQUAL "google" AND
NOT GFLAGS_NAMESPACE STREQUAL "gflags")
gflags_report_not_found(
"Caller defined GFLAGS_NAMESPACE:"
" ${GFLAGS_NAMESPACE} is not valid, not google or gflags.")
endif ()
# Catch case when caller has set GFLAGS_INCLUDE_DIR in the cache / GUI and
# thus FIND_[PATH/LIBRARY] are not called, but specified locations are
# invalid, otherwise we would report the library as found.
if (GFLAGS_INCLUDE_DIR AND
NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
gflags_report_not_found(
"Caller defined GFLAGS_INCLUDE_DIR:"
" ${GFLAGS_INCLUDE_DIR} does not contain gflags/gflags.h header.")
endif (GFLAGS_INCLUDE_DIR AND
NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
# TODO: This regex for gflags library is pretty primitive, we use lowercase
# for comparison to handle Windows using CamelCase library names, could
# this check be better?
string(TOLOWER "${GFLAGS_LIBRARY}" LOWERCASE_GFLAGS_LIBRARY)
if (GFLAGS_LIBRARY AND
NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*")
gflags_report_not_found(
"Caller defined GFLAGS_LIBRARY: "
"${GFLAGS_LIBRARY} does not match gflags.")
endif (GFLAGS_LIBRARY AND
NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*")
gflags_reset_find_library_prefix()
endif(NOT GFLAGS_FOUND)
# Set standard CMake FindPackage variables if found.
if (GFLAGS_FOUND)
set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES})
endif (GFLAGS_FOUND)
# Handle REQUIRED / QUIET optional arguments.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Gflags DEFAULT_MSG
GFLAGS_INCLUDE_DIRS GFLAGS_LIBRARIES GFLAGS_NAMESPACE)
# Only mark internal variables as advanced if we found gflags, otherwise
# leave them visible in the standard GUI for the user to set manually.
if (GFLAGS_FOUND)
mark_as_advanced(FORCE GFLAGS_INCLUDE_DIR
GFLAGS_LIBRARY
GFLAGS_NAMESPACE
gflags_DIR) # Autogenerated by find_package(gflags)
endif (GFLAGS_FOUND)

View File

@@ -0,0 +1,209 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
#
# FindGlog.cmake - Find Google glog logging library.
#
# This module defines the following variables:
#
# GLOG_FOUND: TRUE iff glog is found.
# GLOG_INCLUDE_DIRS: Include directories for glog.
# GLOG_LIBRARIES: Libraries required to link glog.
#
# The following variables control the behaviour of this module:
#
# GLOG_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for glog includes, e.g: /timbuktu/include.
# GLOG_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for glog libraries, e.g: /timbuktu/lib.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead). These variables
# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# GLOG_INCLUDE_DIR: Include directory for glog, not including the
# include directory of any dependencies.
# GLOG_LIBRARY: glog library, not including the libraries of any
# dependencies.
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when
# FindGlog was invoked.
macro(GLOG_RESET_FIND_LIBRARY_PREFIX)
if (MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
endmacro(GLOG_RESET_FIND_LIBRARY_PREFIX)
# Called if we failed to find glog or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(GLOG_REPORT_NOT_FOUND REASON_MSG)
unset(GLOG_FOUND)
unset(GLOG_INCLUDE_DIRS)
unset(GLOG_LIBRARIES)
# Make results of search visible in the CMake GUI if glog has not
# been found so that user does not have to toggle to advanced view.
mark_as_advanced(CLEAR GLOG_INCLUDE_DIR
GLOG_LIBRARY)
glog_reset_find_library_prefix()
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if (Glog_FIND_QUIETLY)
message(STATUS "Failed to find glog - " ${REASON_MSG} ${ARGN})
elseif (Glog_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message("-- Failed to find glog - " ${REASON_MSG} ${ARGN})
endif ()
endmacro(GLOG_REPORT_NOT_FOUND)
# Handle possible presence of lib prefix for libraries on MSVC, see
# also GLOG_RESET_FIND_LIBRARY_PREFIX().
if (MSVC)
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
# s/t we can set it back before returning.
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The empty string in this list is important, it represents the case when
# the libraries have no prefix (shared libraries / DLLs).
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
# Search user-installed locations first, so that we prefer user installs
# to system installs where both exist.
list(APPEND GLOG_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include)
# Windows (for C:/Program Files prefix).
list(APPEND GLOG_CHECK_PATH_SUFFIXES
glog/include
glog/Include
Glog/include
Glog/Include)
list(APPEND GLOG_CHECK_LIBRARY_DIRS
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
/opt/local/lib
/usr/lib)
# Windows (for C:/Program Files prefix).
list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES
glog/lib
glog/Lib
Glog/lib
Glog/Lib)
# Search supplied hint directories first if supplied.
find_path(GLOG_INCLUDE_DIR
NAMES glog/logging.h
PATHS ${GLOG_INCLUDE_DIR_HINTS}
${GLOG_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES ${GLOG_CHECK_PATH_SUFFIXES})
if (NOT GLOG_INCLUDE_DIR OR
NOT EXISTS ${GLOG_INCLUDE_DIR})
glog_report_not_found(
"Could not find glog include directory, set GLOG_INCLUDE_DIR "
"to directory containing glog/logging.h")
endif (NOT GLOG_INCLUDE_DIR OR
NOT EXISTS ${GLOG_INCLUDE_DIR})
find_library(GLOG_LIBRARY NAMES glog
PATHS ${GLOG_LIBRARY_DIR_HINTS}
${GLOG_CHECK_LIBRARY_DIRS}
PATH_SUFFIXES ${GLOG_CHECK_LIBRARY_SUFFIXES})
if (NOT GLOG_LIBRARY OR
NOT EXISTS ${GLOG_LIBRARY})
glog_report_not_found(
"Could not find glog library, set GLOG_LIBRARY "
"to full path to libglog.")
endif (NOT GLOG_LIBRARY OR
NOT EXISTS ${GLOG_LIBRARY})
# Mark internally as found, then verify. GLOG_REPORT_NOT_FOUND() unsets
# if called.
set(GLOG_FOUND TRUE)
# Glog does not seem to provide any record of the version in its
# source tree, thus cannot extract version.
# Catch case when caller has set GLOG_INCLUDE_DIR in the cache / GUI and
# thus FIND_[PATH/LIBRARY] are not called, but specified locations are
# invalid, otherwise we would report the library as found.
if (GLOG_INCLUDE_DIR AND
NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h)
glog_report_not_found(
"Caller defined GLOG_INCLUDE_DIR:"
" ${GLOG_INCLUDE_DIR} does not contain glog/logging.h header.")
endif (GLOG_INCLUDE_DIR AND
NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h)
# TODO: This regex for glog library is pretty primitive, we use lowercase
# for comparison to handle Windows using CamelCase library names, could
# this check be better?
string(TOLOWER "${GLOG_LIBRARY}" LOWERCASE_GLOG_LIBRARY)
if (GLOG_LIBRARY AND
NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*")
glog_report_not_found(
"Caller defined GLOG_LIBRARY: "
"${GLOG_LIBRARY} does not match glog.")
endif (GLOG_LIBRARY AND
NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*")
# Set standard CMake FindPackage variables if found.
if (GLOG_FOUND)
set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
set(GLOG_LIBRARIES ${GLOG_LIBRARY})
endif (GLOG_FOUND)
glog_reset_find_library_prefix()
# Handle REQUIRED / QUIET optional arguments.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Glog DEFAULT_MSG
GLOG_INCLUDE_DIRS GLOG_LIBRARIES)
# Only mark internal variables as advanced if we found glog, otherwise
# leave them visible in the standard GUI for the user to set manually.
if (GLOG_FOUND)
mark_as_advanced(FORCE GLOG_INCLUDE_DIR
GLOG_LIBRARY)
endif (GLOG_FOUND)

View File

@@ -0,0 +1,108 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: sergey.vfx@gmail.com (Sergey Sharybin)
#
# FindSharedPtr.cmake - Find shared pointer header and namespace.
#
# This module defines the following variables:
#
# SHARED_PTR_FOUND: TRUE if shared_ptr found.
# SHARED_PTR_TR1_MEMORY_HEADER: True if <tr1/memory> header is to be used
# for the shared_ptr object, otherwise use <memory>.
# SHARED_PTR_TR1_NAMESPACE: TRUE if shared_ptr is defined in std::tr1 namespace,
# otherwise it's assumed to be defined in std namespace.
macro(FIND_SHARED_PTR)
# To support CXX11 option, clear the results of all check_xxx() functions
# s/t we always perform the checks each time, otherwise CMake fails to
# detect that the tests should be performed again after CXX11 is toggled.
unset(HAVE_STD_MEMORY_HEADER CACHE)
unset(HAVE_SHARED_PTR_IN_STD_NAMESPACE CACHE)
unset(HAVE_SHARED_PTR_IN_TR1_NAMESPACE CACHE)
unset(HAVE_TR1_MEMORY_HEADER CACHE)
unset(HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER CACHE)
set(SHARED_PTR_FOUND FALSE)
check_include_file_cxx(memory HAVE_STD_MEMORY_HEADER)
if (HAVE_STD_MEMORY_HEADER)
# Finding the memory header doesn't mean that shared_ptr is in std
# namespace.
#
# In particular, MSVC 2008 has shared_ptr declared in std::tr1. In
# order to support this, we do an extra check to see which namespace
# should be used.
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <memory>
int main() {
std::shared_ptr<int> int_ptr;
return 0;
}"
HAVE_SHARED_PTR_IN_STD_NAMESPACE)
if (HAVE_SHARED_PTR_IN_STD_NAMESPACE)
message("-- Found shared_ptr in std namespace using <memory> header.")
set(SHARED_PTR_FOUND TRUE)
else (HAVE_SHARED_PTR_IN_STD_NAMESPACE)
check_cxx_source_compiles("#include <memory>
int main() {
std::tr1::shared_ptr<int> int_ptr;
return 0;
}"
HAVE_SHARED_PTR_IN_TR1_NAMESPACE)
if (HAVE_SHARED_PTR_IN_TR1_NAMESPACE)
message("-- Found shared_ptr in std::tr1 namespace using <memory> header.")
set(SHARED_PTR_TR1_NAMESPACE TRUE)
set(SHARED_PTR_FOUND TRUE)
endif (HAVE_SHARED_PTR_IN_TR1_NAMESPACE)
endif (HAVE_SHARED_PTR_IN_STD_NAMESPACE)
endif (HAVE_STD_MEMORY_HEADER)
if (NOT SHARED_PTR_FOUND)
# Further, gcc defines shared_ptr in std::tr1 namespace and
# <tr1/memory> is to be included for this. And what makes things
# even more tricky is that gcc does have <memory> header, so
# all the checks above wouldn't find shared_ptr.
check_include_file_cxx("tr1/memory" HAVE_TR1_MEMORY_HEADER)
if (HAVE_TR1_MEMORY_HEADER)
check_cxx_source_compiles("#include <tr1/memory>
int main() {
std::tr1::shared_ptr<int> int_ptr;
return 0;
}"
HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER)
if (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER)
message("-- Found shared_ptr in std::tr1 namespace using <tr1/memory> header.")
set(SHARED_PTR_TR1_MEMORY_HEADER TRUE)
set(SHARED_PTR_TR1_NAMESPACE TRUE)
set(SHARED_PTR_FOUND TRUE)
endif (HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER)
endif (HAVE_TR1_MEMORY_HEADER)
endif (NOT SHARED_PTR_FOUND)
endmacro(FIND_SHARED_PTR)

View File

@@ -0,0 +1,66 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: pablo.speciale@gmail.com (Pablo Speciale)
#
# Find the Sphinx documentation generator
#
# This modules defines
# SPHINX_EXECUTABLE
# SPHINX_FOUND
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
PATHS
/usr/bin
/usr/local/bin
/opt/local/bin
DOC "Sphinx documentation generator")
if (NOT SPHINX_EXECUTABLE)
set(_Python_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
foreach (_version ${_Python_VERSIONS})
set(_sphinx_NAMES sphinx-build-${_version})
find_program(SPHINX_EXECUTABLE
NAMES ${_sphinx_NAMES}
PATHS
/usr/bin
/usr/local/bin
/opt/local/bin
DOC "Sphinx documentation generator")
endforeach ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE)
mark_as_advanced(SPHINX_EXECUTABLE)

View File

@@ -0,0 +1,651 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
#
# FindSuiteSparse.cmake - Find SuiteSparse libraries & dependencies.
#
# This module defines the following variables:
#
# SUITESPARSE_FOUND: TRUE iff SuiteSparse and all dependencies have been found.
# SUITESPARSE_INCLUDE_DIRS: Include directories for all SuiteSparse components.
# SUITESPARSE_LIBRARIES: Libraries for all SuiteSparse component libraries and
# dependencies.
# SUITESPARSE_VERSION: Extracted from UFconfig.h (<= v3) or
# SuiteSparse_config.h (>= v4).
# SUITESPARSE_MAIN_VERSION: Equal to 4 if SUITESPARSE_VERSION = 4.2.1
# SUITESPARSE_SUB_VERSION: Equal to 2 if SUITESPARSE_VERSION = 4.2.1
# SUITESPARSE_SUBSUB_VERSION: Equal to 1 if SUITESPARSE_VERSION = 4.2.1
#
# SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION: TRUE iff running
# on Ubuntu, SUITESPARSE_VERSION is 3.4.0 and found SuiteSparse is a system
# install, in which case found version of SuiteSparse cannot be used to link
# a shared library due to a bug (static linking is unaffected).
#
# The following variables control the behaviour of this module:
#
# SUITESPARSE_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for SuiteSparse includes,
# e.g: /timbuktu/include.
# SUITESPARSE_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for SuiteSparse libraries,
# e.g: /timbuktu/lib.
#
# The following variables define the presence / includes & libraries for the
# SuiteSparse components searched for, the SUITESPARSE_XX variables are the
# union of the variables for all components.
#
# == Symmetric Approximate Minimum Degree (AMD)
# AMD_FOUND
# AMD_INCLUDE_DIR
# AMD_LIBRARY
#
# == Constrained Approximate Minimum Degree (CAMD)
# CAMD_FOUND
# CAMD_INCLUDE_DIR
# CAMD_LIBRARY
#
# == Column Approximate Minimum Degree (COLAMD)
# COLAMD_FOUND
# COLAMD_INCLUDE_DIR
# COLAMD_LIBRARY
#
# Constrained Column Approximate Minimum Degree (CCOLAMD)
# CCOLAMD_FOUND
# CCOLAMD_INCLUDE_DIR
# CCOLAMD_LIBRARY
#
# == Sparse Supernodal Cholesky Factorization and Update/Downdate (CHOLMOD)
# CHOLMOD_FOUND
# CHOLMOD_INCLUDE_DIR
# CHOLMOD_LIBRARY
#
# == Multifrontal Sparse QR (SuiteSparseQR)
# SUITESPARSEQR_FOUND
# SUITESPARSEQR_INCLUDE_DIR
# SUITESPARSEQR_LIBRARY
#
# == Common configuration for all but CSparse (SuiteSparse version >= 4).
# SUITESPARSE_CONFIG_FOUND
# SUITESPARSE_CONFIG_INCLUDE_DIR
# SUITESPARSE_CONFIG_LIBRARY
#
# == Common configuration for all but CSparse (SuiteSparse version < 4).
# UFCONFIG_FOUND
# UFCONFIG_INCLUDE_DIR
#
# Optional SuiteSparse Dependencies:
#
# == Serial Graph Partitioning and Fill-reducing Matrix Ordering (METIS)
# METIS_FOUND
# METIS_LIBRARY
#
# == Intel Thread Building Blocks (TBB)
# TBB_FOUND
# TBB_LIBRARIES
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when
# FindSuiteSparse was invoked.
macro(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX)
if (MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
endmacro(SUITESPARSE_RESET_FIND_LIBRARY_PREFIX)
# Called if we failed to find SuiteSparse or any of it's required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
macro(SUITESPARSE_REPORT_NOT_FOUND REASON_MSG)
unset(SUITESPARSE_FOUND)
unset(SUITESPARSE_INCLUDE_DIRS)
unset(SUITESPARSE_LIBRARIES)
unset(SUITESPARSE_VERSION)
unset(SUITESPARSE_MAIN_VERSION)
unset(SUITESPARSE_SUB_VERSION)
unset(SUITESPARSE_SUBSUB_VERSION)
# Do NOT unset SUITESPARSE_FOUND_REQUIRED_VARS here, as it is used by
# FindPackageHandleStandardArgs() to generate the automatic error message on
# failure which highlights which components are missing.
suitesparse_reset_find_library_prefix()
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if (SuiteSparse_FIND_QUIETLY)
message(STATUS "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN})
elseif (SuiteSparse_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message("-- Failed to find SuiteSparse - " ${REASON_MSG} ${ARGN})
endif (SuiteSparse_FIND_QUIETLY)
# Do not call RETURN(), s/t we keep processing if not called with REQUIRED.
endmacro(SUITESPARSE_REPORT_NOT_FOUND)
# Handle possible presence of lib prefix for libraries on MSVC, see
# also SUITESPARSE_RESET_FIND_LIBRARY_PREFIX().
if (MSVC)
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
# s/t we can set it back before returning.
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The empty string in this list is important, it represents the case when
# the libraries have no prefix (shared libraries / DLLs).
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
endif (MSVC)
# Specify search directories for include files and libraries (this is the union
# of the search directories for all OSs). Search user-specified hint
# directories first if supplied, and search user-installed locations first
# so that we prefer user installs to system installs where both exist.
list(APPEND SUITESPARSE_CHECK_INCLUDE_DIRS
${SUITESPARSE_INCLUDE_DIR_HINTS}
/opt/local/include
/opt/local/include/ufsparse # Mac OS X
/usr/local/homebrew/include # Mac OS X
/usr/local/include
/usr/local/include/suitesparse
/usr/include/suitesparse # Ubuntu
/usr/include)
list(APPEND SUITESPARSE_CHECK_LIBRARY_DIRS
${SUITESPARSE_LIBRARY_DIR_HINTS}
/opt/local/lib
/opt/local/lib/ufsparse # Mac OS X
/usr/local/homebrew/lib # Mac OS X
/usr/local/lib
/usr/local/lib/suitesparse
/usr/lib/suitesparse # Ubuntu
/usr/lib)
# Given the number of components of SuiteSparse, and to ensure that the
# automatic failure message generated by FindPackageHandleStandardArgs()
# when not all required components are found is helpful, we maintain a list
# of all variables that must be defined for SuiteSparse to be considered found.
unset(SUITESPARSE_FOUND_REQUIRED_VARS)
# BLAS.
find_package(BLAS QUIET)
if (NOT BLAS_FOUND)
suitesparse_report_not_found(
"Did not find BLAS library (required for SuiteSparse).")
endif (NOT BLAS_FOUND)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS BLAS_FOUND)
# LAPACK.
find_package(LAPACK QUIET)
if (NOT LAPACK_FOUND)
suitesparse_report_not_found(
"Did not find LAPACK library (required for SuiteSparse).")
endif (NOT LAPACK_FOUND)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS LAPACK_FOUND)
# AMD.
set(AMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS AMD_FOUND)
find_library(AMD_LIBRARY NAMES amd
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${AMD_LIBRARY})
message(STATUS "Found AMD library: ${AMD_LIBRARY}")
else (EXISTS ${AMD_LIBRARY})
suitesparse_report_not_found(
"Did not find AMD library (required SuiteSparse component).")
set(AMD_FOUND FALSE)
endif (EXISTS ${AMD_LIBRARY})
mark_as_advanced(AMD_LIBRARY)
find_path(AMD_INCLUDE_DIR NAMES amd.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${AMD_INCLUDE_DIR})
message(STATUS "Found AMD header in: ${AMD_INCLUDE_DIR}")
else (EXISTS ${AMD_INCLUDE_DIR})
suitesparse_report_not_found(
"Did not find AMD header (required SuiteSparse component).")
set(AMD_FOUND FALSE)
endif (EXISTS ${AMD_INCLUDE_DIR})
mark_as_advanced(AMD_INCLUDE_DIR)
# CAMD.
set(CAMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CAMD_FOUND)
find_library(CAMD_LIBRARY NAMES camd
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${CAMD_LIBRARY})
message(STATUS "Found CAMD library: ${CAMD_LIBRARY}")
else (EXISTS ${CAMD_LIBRARY})
suitesparse_report_not_found(
"Did not find CAMD library (required SuiteSparse component).")
set(CAMD_FOUND FALSE)
endif (EXISTS ${CAMD_LIBRARY})
mark_as_advanced(CAMD_LIBRARY)
find_path(CAMD_INCLUDE_DIR NAMES camd.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${CAMD_INCLUDE_DIR})
message(STATUS "Found CAMD header in: ${CAMD_INCLUDE_DIR}")
else (EXISTS ${CAMD_INCLUDE_DIR})
suitesparse_report_not_found(
"Did not find CAMD header (required SuiteSparse component).")
set(CAMD_FOUND FALSE)
endif (EXISTS ${CAMD_INCLUDE_DIR})
mark_as_advanced(CAMD_INCLUDE_DIR)
# COLAMD.
set(COLAMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS COLAMD_FOUND)
find_library(COLAMD_LIBRARY NAMES colamd
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${COLAMD_LIBRARY})
message(STATUS "Found COLAMD library: ${COLAMD_LIBRARY}")
else (EXISTS ${COLAMD_LIBRARY})
suitesparse_report_not_found(
"Did not find COLAMD library (required SuiteSparse component).")
set(COLAMD_FOUND FALSE)
endif (EXISTS ${COLAMD_LIBRARY})
mark_as_advanced(COLAMD_LIBRARY)
find_path(COLAMD_INCLUDE_DIR NAMES colamd.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${COLAMD_INCLUDE_DIR})
message(STATUS "Found COLAMD header in: ${COLAMD_INCLUDE_DIR}")
else (EXISTS ${COLAMD_INCLUDE_DIR})
suitesparse_report_not_found(
"Did not find COLAMD header (required SuiteSparse component).")
set(COLAMD_FOUND FALSE)
endif (EXISTS ${COLAMD_INCLUDE_DIR})
mark_as_advanced(COLAMD_INCLUDE_DIR)
# CCOLAMD.
set(CCOLAMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CCOLAMD_FOUND)
find_library(CCOLAMD_LIBRARY NAMES ccolamd
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${CCOLAMD_LIBRARY})
message(STATUS "Found CCOLAMD library: ${CCOLAMD_LIBRARY}")
else (EXISTS ${CCOLAMD_LIBRARY})
suitesparse_report_not_found(
"Did not find CCOLAMD library (required SuiteSparse component).")
set(CCOLAMD_FOUND FALSE)
endif (EXISTS ${CCOLAMD_LIBRARY})
mark_as_advanced(CCOLAMD_LIBRARY)
find_path(CCOLAMD_INCLUDE_DIR NAMES ccolamd.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${CCOLAMD_INCLUDE_DIR})
message(STATUS "Found CCOLAMD header in: ${CCOLAMD_INCLUDE_DIR}")
else (EXISTS ${CCOLAMD_INCLUDE_DIR})
suitesparse_report_not_found(
"Did not find CCOLAMD header (required SuiteSparse component).")
set(CCOLAMD_FOUND FALSE)
endif (EXISTS ${CCOLAMD_INCLUDE_DIR})
mark_as_advanced(CCOLAMD_INCLUDE_DIR)
# CHOLMOD.
set(CHOLMOD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CHOLMOD_FOUND)
find_library(CHOLMOD_LIBRARY NAMES cholmod
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${CHOLMOD_LIBRARY})
message(STATUS "Found CHOLMOD library: ${CHOLMOD_LIBRARY}")
else (EXISTS ${CHOLMOD_LIBRARY})
suitesparse_report_not_found(
"Did not find CHOLMOD library (required SuiteSparse component).")
set(CHOLMOD_FOUND FALSE)
endif (EXISTS ${CHOLMOD_LIBRARY})
mark_as_advanced(CHOLMOD_LIBRARY)
find_path(CHOLMOD_INCLUDE_DIR NAMES cholmod.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${CHOLMOD_INCLUDE_DIR})
message(STATUS "Found CHOLMOD header in: ${CHOLMOD_INCLUDE_DIR}")
else (EXISTS ${CHOLMOD_INCLUDE_DIR})
suitesparse_report_not_found(
"Did not find CHOLMOD header (required SuiteSparse component).")
set(CHOLMOD_FOUND FALSE)
endif (EXISTS ${CHOLMOD_INCLUDE_DIR})
mark_as_advanced(CHOLMOD_INCLUDE_DIR)
# SuiteSparseQR.
set(SUITESPARSEQR_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSEQR_FOUND)
find_library(SUITESPARSEQR_LIBRARY NAMES spqr
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${SUITESPARSEQR_LIBRARY})
message(STATUS "Found SuiteSparseQR library: ${SUITESPARSEQR_LIBRARY}")
else (EXISTS ${SUITESPARSEQR_LIBRARY})
suitesparse_report_not_found(
"Did not find SuiteSparseQR library (required SuiteSparse component).")
set(SUITESPARSEQR_FOUND FALSE)
endif (EXISTS ${SUITESPARSEQR_LIBRARY})
mark_as_advanced(SUITESPARSEQR_LIBRARY)
find_path(SUITESPARSEQR_INCLUDE_DIR NAMES SuiteSparseQR.hpp
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${SUITESPARSEQR_INCLUDE_DIR})
message(STATUS "Found SuiteSparseQR header in: ${SUITESPARSEQR_INCLUDE_DIR}")
else (EXISTS ${SUITESPARSEQR_INCLUDE_DIR})
suitesparse_report_not_found(
"Did not find SUITESPARSEQR header (required SuiteSparse component).")
set(SUITESPARSEQR_FOUND FALSE)
endif (EXISTS ${SUITESPARSEQR_INCLUDE_DIR})
mark_as_advanced(SUITESPARSEQR_INCLUDE_DIR)
if (SUITESPARSEQR_FOUND)
# SuiteSparseQR may be compiled with Intel Threading Building Blocks,
# we assume that if TBB is installed, SuiteSparseQR was compiled with
# support for it, this will do no harm if it wasn't.
set(TBB_FOUND TRUE)
find_library(TBB_LIBRARIES NAMES tbb
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${TBB_LIBRARIES})
message(STATUS "Found Intel Thread Building Blocks (TBB) library: "
"${TBB_LIBRARIES}, assuming SuiteSparseQR was compiled with TBB.")
else (EXISTS ${TBB_LIBRARIES})
message(STATUS "Did not find Intel TBB library, assuming SuiteSparseQR was "
"not compiled with TBB.")
set(TBB_FOUND FALSE)
endif (EXISTS ${TBB_LIBRARIES})
mark_as_advanced(TBB_LIBRARIES)
if (TBB_FOUND)
find_library(TBB_MALLOC_LIB NAMES tbbmalloc
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${TBB_MALLOC_LIB})
message(STATUS "Found Intel Thread Building Blocks (TBB) Malloc library: "
"${TBB_MALLOC_LIB}")
# Append TBB malloc library to TBB libraries list whilst retaining
# any CMake generated help string (cache variable).
list(APPEND TBB_LIBRARIES ${TBB_MALLOC_LIB})
get_property(HELP_STRING CACHE TBB_LIBRARIES PROPERTY HELPSTRING)
set(TBB_LIBRARIES "${TBB_LIBRARIES}" CACHE STRING "${HELP_STRING}")
# Add the TBB libraries to the SuiteSparseQR libraries (the only
# libraries to optionally depend on TBB).
list(APPEND SUITESPARSEQR_LIBRARY ${TBB_LIBRARIES})
else (EXISTS ${TBB_MALLOC_LIB})
# If we cannot find all required TBB components do not include it as
# a dependency.
message(STATUS "Did not find Intel Thread Building Blocks (TBB) Malloc "
"Library, discarding TBB as a dependency.")
set(TBB_FOUND FALSE)
endif (EXISTS ${TBB_MALLOC_LIB})
mark_as_advanced(TBB_MALLOC_LIB)
endif (TBB_FOUND)
endif(SUITESPARSEQR_FOUND)
# UFconfig / SuiteSparse_config.
#
# If SuiteSparse version is >= 4 then SuiteSparse_config is required.
# For SuiteSparse 3, UFconfig.h is required.
find_library(SUITESPARSE_CONFIG_LIBRARY NAMES suitesparseconfig
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${SUITESPARSE_CONFIG_LIBRARY})
message(STATUS "Found SuiteSparse_config library: "
"${SUITESPARSE_CONFIG_LIBRARY}")
endif (EXISTS ${SUITESPARSE_CONFIG_LIBRARY})
mark_as_advanced(SUITESPARSE_CONFIG_LIBRARY)
find_path(SUITESPARSE_CONFIG_INCLUDE_DIR NAMES SuiteSparse_config.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR})
message(STATUS "Found SuiteSparse_config header in: "
"${SUITESPARSE_CONFIG_INCLUDE_DIR}")
endif (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR})
mark_as_advanced(SUITESPARSE_CONFIG_INCLUDE_DIR)
set(SUITESPARSE_CONFIG_FOUND FALSE)
set(UFCONFIG_FOUND FALSE)
if (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND
EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR})
set(SUITESPARSE_CONFIG_FOUND TRUE)
# SuiteSparse_config (SuiteSparse version >= 4) requires librt library for
# timing by default when compiled on Linux or Unix, but not on OSX (which
# does not have librt).
if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE)
find_library(LIBRT_LIBRARY NAMES rt
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (LIBRT_LIBRARY)
message(STATUS "Adding librt: ${LIBRT_LIBRARY} to "
"SuiteSparse_config libraries (required on Linux & Unix [not OSX] if "
"SuiteSparse is compiled with timing).")
else (LIBRT_LIBRARY)
message(STATUS "Could not find librt, but found SuiteSparse_config, "
"assuming that SuiteSparse was compiled without timing.")
endif (LIBRT_LIBRARY)
mark_as_advanced(LIBRT_LIBRARY)
list(APPEND SUITESPARSE_CONFIG_LIBRARY ${LIBRT_LIBRARY})
endif (CMAKE_SYSTEM_NAME MATCHES "Linux" OR UNIX AND NOT APPLE)
else (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND
EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR})
# Failed to find SuiteSparse_config (>= v4 installs), instead look for
# UFconfig header which should be present in < v4 installs.
set(SUITESPARSE_CONFIG_FOUND FALSE)
find_path(UFCONFIG_INCLUDE_DIR NAMES UFconfig.h
PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
if (EXISTS ${UFCONFIG_INCLUDE_DIR})
message(STATUS "Found UFconfig header in: ${UFCONFIG_INCLUDE_DIR}")
set(UFCONFIG_FOUND TRUE)
endif (EXISTS ${UFCONFIG_INCLUDE_DIR})
mark_as_advanced(UFCONFIG_INCLUDE_DIR)
endif (EXISTS ${SUITESPARSE_CONFIG_LIBRARY} AND
EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR})
if (NOT SUITESPARSE_CONFIG_FOUND AND
NOT UFCONFIG_FOUND)
suitesparse_report_not_found(
"Failed to find either: SuiteSparse_config header & library (should be "
"present in all SuiteSparse >= v4 installs), or UFconfig header (should "
"be present in all SuiteSparse < v4 installs).")
endif (NOT SUITESPARSE_CONFIG_FOUND AND
NOT UFCONFIG_FOUND)
# Extract the SuiteSparse version from the appropriate header (UFconfig.h for
# <= v3, SuiteSparse_config.h for >= v4).
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSE_VERSION)
if (UFCONFIG_FOUND)
# SuiteSparse version <= 3.
set(SUITESPARSE_VERSION_FILE ${UFCONFIG_INCLUDE_DIR}/UFconfig.h)
if (NOT EXISTS ${SUITESPARSE_VERSION_FILE})
suitesparse_report_not_found(
"Could not find file: ${SUITESPARSE_VERSION_FILE} containing version "
"information for <= v3 SuiteSparse installs, but UFconfig was found "
"(only present in <= v3 installs).")
else (NOT EXISTS ${SUITESPARSE_VERSION_FILE})
file(READ ${SUITESPARSE_VERSION_FILE} UFCONFIG_CONTENTS)
string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+"
SUITESPARSE_MAIN_VERSION "${UFCONFIG_CONTENTS}")
string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1"
SUITESPARSE_MAIN_VERSION "${SUITESPARSE_MAIN_VERSION}")
string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+"
SUITESPARSE_SUB_VERSION "${UFCONFIG_CONTENTS}")
string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1"
SUITESPARSE_SUB_VERSION "${SUITESPARSE_SUB_VERSION}")
string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+"
SUITESPARSE_SUBSUB_VERSION "${UFCONFIG_CONTENTS}")
string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1"
SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_SUBSUB_VERSION}")
# This is on a single line s/t CMake does not interpret it as a list of
# elements and insert ';' separators which would result in 4.;2.;1 nonsense.
set(SUITESPARSE_VERSION
"${SUITESPARSE_MAIN_VERSION}.${SUITESPARSE_SUB_VERSION}.${SUITESPARSE_SUBSUB_VERSION}")
endif (NOT EXISTS ${SUITESPARSE_VERSION_FILE})
endif (UFCONFIG_FOUND)
if (SUITESPARSE_CONFIG_FOUND)
# SuiteSparse version >= 4.
set(SUITESPARSE_VERSION_FILE
${SUITESPARSE_CONFIG_INCLUDE_DIR}/SuiteSparse_config.h)
if (NOT EXISTS ${SUITESPARSE_VERSION_FILE})
suitesparse_report_not_found(
"Could not find file: ${SUITESPARSE_VERSION_FILE} containing version "
"information for >= v4 SuiteSparse installs, but SuiteSparse_config was "
"found (only present in >= v4 installs).")
else (NOT EXISTS ${SUITESPARSE_VERSION_FILE})
file(READ ${SUITESPARSE_VERSION_FILE} SUITESPARSE_CONFIG_CONTENTS)
string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+"
SUITESPARSE_MAIN_VERSION "${SUITESPARSE_CONFIG_CONTENTS}")
string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1"
SUITESPARSE_MAIN_VERSION "${SUITESPARSE_MAIN_VERSION}")
string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+"
SUITESPARSE_SUB_VERSION "${SUITESPARSE_CONFIG_CONTENTS}")
string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1"
SUITESPARSE_SUB_VERSION "${SUITESPARSE_SUB_VERSION}")
string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+"
SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_CONFIG_CONTENTS}")
string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1"
SUITESPARSE_SUBSUB_VERSION "${SUITESPARSE_SUBSUB_VERSION}")
# This is on a single line s/t CMake does not interpret it as a list of
# elements and insert ';' separators which would result in 4.;2.;1 nonsense.
set(SUITESPARSE_VERSION
"${SUITESPARSE_MAIN_VERSION}.${SUITESPARSE_SUB_VERSION}.${SUITESPARSE_SUBSUB_VERSION}")
endif (NOT EXISTS ${SUITESPARSE_VERSION_FILE})
endif (SUITESPARSE_CONFIG_FOUND)
# METIS (Optional dependency).
find_library(METIS_LIBRARY NAMES metis
PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
if (EXISTS ${METIS_LIBRARY})
message(STATUS "Found METIS library: ${METIS_LIBRARY}.")
set(METIS_FOUND TRUE)
else (EXISTS ${METIS_LIBRARY})
message(STATUS "Did not find METIS library (optional SuiteSparse dependency)")
set(METIS_FOUND FALSE)
endif (EXISTS ${METIS_LIBRARY})
mark_as_advanced(METIS_LIBRARY)
# Only mark SuiteSparse as found if all required components and dependencies
# have been found.
set(SUITESPARSE_FOUND TRUE)
foreach(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS})
if (NOT ${REQUIRED_VAR})
set(SUITESPARSE_FOUND FALSE)
endif (NOT ${REQUIRED_VAR})
endforeach(REQUIRED_VAR ${SUITESPARSE_FOUND_REQUIRED_VARS})
if (SUITESPARSE_FOUND)
list(APPEND SUITESPARSE_INCLUDE_DIRS
${AMD_INCLUDE_DIR}
${CAMD_INCLUDE_DIR}
${COLAMD_INCLUDE_DIR}
${CCOLAMD_INCLUDE_DIR}
${CHOLMOD_INCLUDE_DIR}
${SUITESPARSEQR_INCLUDE_DIR})
# Handle config separately, as otherwise at least one of them will be set
# to NOTFOUND which would cause any check on SUITESPARSE_INCLUDE_DIRS to fail.
if (SUITESPARSE_CONFIG_FOUND)
list(APPEND SUITESPARSE_INCLUDE_DIRS
${SUITESPARSE_CONFIG_INCLUDE_DIR})
endif (SUITESPARSE_CONFIG_FOUND)
if (UFCONFIG_FOUND)
list(APPEND SUITESPARSE_INCLUDE_DIRS
${UFCONFIG_INCLUDE_DIR})
endif (UFCONFIG_FOUND)
# As SuiteSparse includes are often all in the same directory, remove any
# repetitions.
list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIRS)
# Important: The ordering of these libraries is *NOT* arbitrary, as these
# could potentially be static libraries their link ordering is important.
list(APPEND SUITESPARSE_LIBRARIES
${SUITESPARSEQR_LIBRARY}
${CHOLMOD_LIBRARY}
${CCOLAMD_LIBRARY}
${CAMD_LIBRARY}
${COLAMD_LIBRARY}
${AMD_LIBRARY}
${LAPACK_LIBRARIES}
${BLAS_LIBRARIES})
if (SUITESPARSE_CONFIG_FOUND)
list(APPEND SUITESPARSE_LIBRARIES
${SUITESPARSE_CONFIG_LIBRARY})
endif (SUITESPARSE_CONFIG_FOUND)
if (METIS_FOUND)
list(APPEND SUITESPARSE_LIBRARIES
${METIS_LIBRARY})
endif (METIS_FOUND)
endif()
# Determine if we are running on Ubuntu with the package install of SuiteSparse
# which is broken and does not support linking a shared library.
set(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION FALSE)
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND
SUITESPARSE_VERSION VERSION_EQUAL 3.4.0)
find_program(LSB_RELEASE_EXECUTABLE lsb_release)
if (LSB_RELEASE_EXECUTABLE)
# Any even moderately recent Ubuntu release (likely to be affected by
# this bug) should have lsb_release, if it isn't present we are likely
# on a different Linux distribution (should be fine).
execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -si
OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND
SUITESPARSE_LIBRARIES MATCHES "/usr/lib/libamd")
# We are on Ubuntu, and the SuiteSparse version matches the broken
# system install version and is a system install.
set(SUITESPARSE_IS_BROKEN_SHARED_LINKING_UBUNTU_SYSTEM_VERSION TRUE)
message(STATUS "Found system install of SuiteSparse "
"${SUITESPARSE_VERSION} running on Ubuntu, which has a known bug "
"preventing linking of shared libraries (static linking unaffected).")
endif (LSB_DISTRIBUTOR_ID MATCHES "Ubuntu" AND
SUITESPARSE_LIBRARIES MATCHES "/usr/lib/libamd")
endif (LSB_RELEASE_EXECUTABLE)
endif (CMAKE_SYSTEM_NAME MATCHES "Linux" AND
SUITESPARSE_VERSION VERSION_EQUAL 3.4.0)
suitesparse_reset_find_library_prefix()
# Handle REQUIRED and QUIET arguments to FIND_PACKAGE
include(FindPackageHandleStandardArgs)
if (SUITESPARSE_FOUND)
find_package_handle_standard_args(SuiteSparse
REQUIRED_VARS ${SUITESPARSE_FOUND_REQUIRED_VARS}
VERSION_VAR SUITESPARSE_VERSION
FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse.")
else (SUITESPARSE_FOUND)
# Do not pass VERSION_VAR to FindPackageHandleStandardArgs() if we failed to
# find SuiteSparse to avoid a confusing autogenerated failure message
# that states 'not found (missing: FOO) (found version: x.y.z)'.
find_package_handle_standard_args(SuiteSparse
REQUIRED_VARS ${SUITESPARSE_FOUND_REQUIRED_VARS}
FAIL_MESSAGE "Failed to find some/all required components of SuiteSparse.")
endif (SUITESPARSE_FOUND)

View File

@@ -0,0 +1,94 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
#
# FindUnorderedMap.cmake - Find unordered_map header and namespace.
#
# This module defines the following variables:
#
# UNORDERED_MAP_FOUND: TRUE if unordered_map is found.
# HAVE_UNORDERED_MAP_IN_STD_NAMESPACE: Use <unordered_map> & std.
# HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE: Use <unordered_map> & std::tr1.
# HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE: <tr1/unordered_map> & std::tr1.
macro(FIND_UNORDERED_MAP)
# To support CXX11 option, clear the results of all check_xxx() functions
# s/t we always perform the checks each time, otherwise CMake fails to
# detect that the tests should be performed again after CXX11 is toggled.
unset(HAVE_STD_UNORDERED_MAP_HEADER CACHE)
unset(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE CACHE)
unset(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE CACHE)
unset(HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE CACHE)
set(UNORDERED_MAP_FOUND FALSE)
include(CheckIncludeFileCXX)
check_include_file_cxx(unordered_map HAVE_STD_UNORDERED_MAP_HEADER)
if (HAVE_STD_UNORDERED_MAP_HEADER)
# Finding the unordered_map header doesn't mean that unordered_map
# is in std namespace.
#
# In particular, MSVC 2008 has unordered_map declared in std::tr1.
# In order to support this, we do an extra check to see which
# namespace should be used.
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <unordered_map>
int main() {
std::unordered_map<int, int> map;
return 0;
}"
HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
if (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
set(UNORDERED_MAP_FOUND TRUE)
message("-- Found unordered_map/set in std namespace.")
else (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
check_cxx_source_compiles("#include <unordered_map>
int main() {
std::tr1::unordered_map<int, int> map;
return 0;
}"
HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
if (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
set(UNORDERED_MAP_FOUND TRUE)
message("-- Found unordered_map/set in std::tr1 namespace.")
else (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
message("-- Found <unordered_map> but cannot find either "
"std::unordered_map or std::tr1::unordered_map.")
endif (HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
endif (HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
else (HAVE_STD_UNORDERED_MAP_HEADER)
check_include_file_cxx("tr1/unordered_map"
HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE)
if (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE)
set(UNORDERED_MAP_FOUND TRUE)
message("-- Found tr1/unordered_map/set in std::tr1 namespace.")
else (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE)
message("-- Unable to find <unordered_map> or <tr1/unordered_map>.")
endif (HAVE_TR1_UNORDERED_MAP_IN_TR1_NAMESPACE)
endif (HAVE_STD_UNORDERED_MAP_HEADER)
endmacro(FIND_UNORDERED_MAP)

View File

@@ -0,0 +1,43 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: alexs.mac@gmail.com (Alex Stewart)
# By default, there is no easy way in CMake to set the value of a cache
# variable without reinitialising it, which involves resetting its
# associated help string. This is particularly annoying for CMake options
# where they need to programmatically updated.
#
# This function automates this process by getting the current help string
# for the cache variable to update, then reinitialising it with the new
# value, but with the original help string.
function(UPDATE_CACHE_VARIABLE VAR_NAME VALUE)
get_property(HELP_STRING CACHE ${VAR_NAME} PROPERTY HELPSTRING)
get_property(VAR_TYPE CACHE ${VAR_NAME} PROPERTY TYPE)
set(${VAR_NAME} ${VALUE} CACHE ${VAR_TYPE} "${HELP_STRING}" FORCE)
endfunction()

View File

@@ -0,0 +1,91 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2015 Google Inc. All rights reserved.
// http://ceres-solver.org/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Author: alexs.mac@gmail.com (Alex Stewart)
// Configuration options for Ceres.
//
// Do not edit this file, it was automatically configured by CMake when
// Ceres was compiled with the relevant configuration for the machine
// on which Ceres was compiled.
//
// Ceres Developers: All options should have the same name as their mapped
// CMake options, in the preconfigured version of this file
// all options should be enclosed in '@'.
#ifndef CERES_PUBLIC_INTERNAL_CONFIG_H_
#define CERES_PUBLIC_INTERNAL_CONFIG_H_
// If defined, use the LGPL code in Eigen.
@CERES_USE_EIGEN_SPARSE@
// If defined, Ceres was compiled without LAPACK.
@CERES_NO_LAPACK@
// If defined, Ceres was compiled without SuiteSparse.
@CERES_NO_SUITESPARSE@
// If defined, Ceres was compiled without CXSparse.
@CERES_NO_CXSPARSE@
// If defined, Ceres was compiled without Schur specializations.
@CERES_RESTRICT_SCHUR_SPECIALIZATION@
// If defined, Ceres was compiled to use Eigen instead of hardcoded BLAS
// routines.
@CERES_NO_CUSTOM_BLAS@
// If defined, Ceres was compiled with C++11.
@CERES_USE_CXX11@
// If defined, Ceres was compiled without multithreading support.
@CERES_NO_THREADS@
// If defined Ceres was compiled with OpenMP multithreading support.
@CERES_USE_OPENMP@
// Additionally defined on *nix if Ceres was compiled with OpenMP support,
// as in this case pthreads is also required.
@CERES_HAVE_PTHREAD@
@CERES_HAVE_RWLOCK@
// Which version of unordered map was used when Ceres was compiled. Exactly
// one of these will be defined for any given build.
@CERES_STD_UNORDERED_MAP@
@CERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE@
@CERES_TR1_UNORDERED_MAP@
@CERES_NO_UNORDERED_MAP@
// If defined, the memory header is in <tr1/memory>, otherwise <memory>.
@CERES_TR1_MEMORY_HEADER@
// If defined shared_ptr is in std::tr1 namespace, otherwise std.
@CERES_TR1_SHARED_PTR@
// If defined, Ceres was built as a shared library.
@CERES_USING_SHARED_LIBRARY@
#endif // CERES_PUBLIC_INTERNAL_CONFIG_H_

View File

@@ -0,0 +1,320 @@
# This file is part of the ios-cmake project. It was retrieved from
# https://github.com/cristeab/ios-cmake.git, which is a fork of
# https://code.google.com/p/ios-cmake/. Which in turn is based off of
# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
# are included with CMake 2.8.4
#
# The ios-cmake project is licensed under the new BSD license.
#
# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
# Kitware, Inc., Insight Software Consortium. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# This file is based off of the Platform/Darwin.cmake and
# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
# It has been altered for iOS development.
#
# Updated by Alex Stewart (alexs.mac@gmail.com).
# The following variables control the behaviour of this toolchain:
#
# IOS_PLATFORM: OS (default) or SIMULATOR or SIMULATOR64
# OS = Build for iPhoneOS.
# SIMULATOR = Build for x86 i386 iPhone Simulator.
# SIMULATOR64 = Build for x86 x86_64 iPhone Simulator.
# CMAKE_OSX_SYSROOT: Path to the iOS SDK to use. By default this is
# automatically determined from IOS_PLATFORM and xcodebuild, but
# can also be manually specified (although this should not be required).
# CMAKE_IOS_DEVELOPER_ROOT: Path to the Developer directory for the iOS platform
# being compiled for. By default this is automatically determined from
# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
# not be required).
#
# This toolchain defines the following variables for use externally:
#
# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
# IOS_SDK_VERSION: Version of iOS SDK being used.
# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from
# IOS_PLATFORM).
#
# This toolchain defines the following macros for use externally:
#
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
# A convenience macro for setting xcode specific properties on targets
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1").
#
# find_host_package (PROGRAM ARGS)
# A macro used to find executable programs on the host system, not within the
# iOS environment. Thanks to the android-cmake project for providing the
# command.
# Get the Xcode version being used.
execute_process(COMMAND xcodebuild -version
OUTPUT_VARIABLE XCODE_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")
message(STATUS "Building with Xcode version: ${XCODE_VERSION}")
# Default to building for iPhoneOS if not specified otherwise, and we cannot
# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
# determine the value of IOS_PLATFORM from the root project, as
# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
if (NOT DEFINED IOS_PLATFORM)
if (CMAKE_OSX_ARCHITECTURES)
if (CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*")
set(IOS_PLATFORM "OS")
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(IOS_PLATFORM "SIMULATOR")
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(IOS_PLATFORM "SIMULATOR64")
endif()
endif()
if (NOT IOS_PLATFORM)
set(IOS_PLATFORM "OS")
endif()
endif()
set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING
"Type of iOS platform for which to build.")
# Determine the platform name and architectures for use in xcodebuild commands
# from the specified IOS_PLATFORM name.
if (IOS_PLATFORM STREQUAL "OS")
set(XCODE_IOS_PLATFORM iphoneos)
set(IOS_ARCH armv7 armv7s arm64)
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
set(XCODE_IOS_PLATFORM iphonesimulator)
set(IOS_ARCH i386)
elseif(IOS_PLATFORM STREQUAL "SIMULATOR64")
set(XCODE_IOS_PLATFORM iphonesimulator)
set(IOS_ARCH x86_64)
else()
message(FATAL_ERROR "Invalid IOS_PLATFORM: ${IOS_PLATFORM}")
endif()
message(STATUS "Configuring iOS build for platform: ${IOS_PLATFORM}, "
"architecture(s): ${IOS_ARCH}")
# If user did not specify the SDK root to use, then query xcodebuild for it.
if (NOT CMAKE_OSX_SYSROOT)
execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}")
endif()
if (NOT EXISTS ${CMAKE_OSX_SYSROOT})
message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
"does not exist.")
endif()
# Get the SDK version information.
execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
OUTPUT_VARIABLE IOS_SDK_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Find the Developer root for the specific iOS platform being compiled for
# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
# this information from xcrun or xcodebuild.
if (NOT CMAKE_IOS_DEVELOPER_ROOT)
get_filename_component(IOS_PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
get_filename_component(CMAKE_IOS_DEVELOPER_ROOT ${IOS_PLATFORM_SDK_DIR} PATH)
endif()
if (NOT EXISTS ${CMAKE_IOS_DEVELOPER_ROOT})
message(FATAL_ERROR "Invalid CMAKE_IOS_DEVELOPER_ROOT: "
"${CMAKE_IOS_DEVELOPER_ROOT} does not exist.")
endif()
# Find the C & C++ compilers for the specified SDK.
if (NOT CMAKE_C_COMPILER)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
OUTPUT_VARIABLE CMAKE_C_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
endif()
if (NOT CMAKE_CXX_COMPILER)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
endif()
# Find (Apple's) libtool.
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
OUTPUT_VARIABLE IOS_LIBTOOL
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using libtool: ${IOS_LIBTOOL}")
# Configure libtool to be used instead of ar + ranlib to build static libraries.
# This is required on Xcode 7+, but should also work on previous versions of
# Xcode.
set(CMAKE_C_CREATE_STATIC_LIBRARY
"${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
"${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
# Get the version of Darwin (OS X) of the host.
execute_process(COMMAND uname -r
OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Standard settings.
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_VERSION ${IOS_SDK_VERSION})
set(UNIX TRUE)
set(APPLE TRUE)
set(IOS TRUE)
# Force unset of OS X-specific deployment target (otherwise autopopulated),
# required as of cmake 2.8.10.
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING
"Must be empty for iOS builds." FORCE)
# Set the architectures for which to build.
set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
# Skip the platform compiler checks for cross compiling.
set(CMAKE_CXX_COMPILER_FORCED TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)
# All iOS/Darwin specific settings - some may be redundant.
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
set(CMAKE_SHARED_MODULE_PREFIX "lib")
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
set(CMAKE_MODULE_EXISTS 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
# Specify minimum version as latest SDK version. Note that only Xcode 7+
# supports the newer more specific: -m${XCODE_IOS_PLATFORM}-version-min flags,
# older versions of Xcode use: -m(ios/ios-simulator)-version-min instead.
if (XCODE_VERSION VERSION_LESS 7.0)
if (IOS_PLATFORM STREQUAL "OS")
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mios-version-min=${IOS_SDK_VERSION}")
else()
# SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mios-simulator-version-min=${IOS_SDK_VERSION}")
endif()
else()
# Xcode 7.0+ uses flags we can build directly from XCODE_IOS_PLATFORM.
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-m${XCODE_IOS_PLATFORM}-version-min=${IOS_SDK_VERSION}")
endif()
set(CMAKE_C_FLAGS
"${XCODE_IOS_PLATFORM_VERSION_FLAGS} -fobjc-abi-version=2 -fobjc-arc ${CMAKE_C_FLAGS}")
# Hidden visibilty is required for C++ on iOS.
set(CMAKE_CXX_FLAGS
"${XCODE_IOS_PLATFORM_VERSION_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fobjc-abi-version=2 -fobjc-arc ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
set(CMAKE_CXX_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
# In order to ensure that the updated compiler flags are used in try_compile()
# tests, we have to forcibly set them in the CMake cache, not merely set them
# in the local scope.
list(APPEND VARS_TO_FORCE_IN_CACHE
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
CMAKE_CXX_RELEASE
CMAKE_C_LINK_FLAGS
CMAKE_CXX_LINK_FLAGS)
foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "" FORCE)
endforeach()
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
# Hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old
# build tree (where install_name_tool was hardcoded) and where
# CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't fail in
# CMakeFindBinUtils.cmake (because it isn't rerun) hardcode
# CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did
# before, Alex.
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
# Set the find root to the iOS developer roots and to user defined paths.
set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_OSX_SYSROOT}
${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root" FORCE)
# Default to searching for frameworks first.
set(CMAKE_FIND_FRAMEWORK FIRST)
# Set up the default search directories for frameworks.
set(CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks
${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks)
# Only search the specified iOS SDK, not the remainder of the host filesystem.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# This little macro lets you set any XCode specific property.
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
set_property(TARGET ${TARGET} PROPERTY
XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
endmacro(set_xcode_property)
# This macro lets you find executable programs on the host system.
macro(find_host_package)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
set(IOS FALSE)
find_package(${ARGN})
set(IOS TRUE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endmacro(find_host_package)

View File

@@ -0,0 +1,97 @@
# Ceres Solver - A fast non-linear least squares minimizer
# Copyright 2015 Google Inc. All rights reserved.
# http://ceres-solver.org/
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Google Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: arnaudgelas@gmail.com (Arnaud Gelas)
# alexs.mac@gmail.com (Alex Stewart)
if (COMMAND cmake_policy)
# Ignore empty elements in LIST() commands.
cmake_policy(SET CMP0007 OLD)
endif (COMMAND cmake_policy)
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: "
"\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" INSTALL_MANIFEST)
string(REGEX REPLACE "\n" ";" INSTALL_MANIFEST "${INSTALL_MANIFEST}")
list(REVERSE INSTALL_MANIFEST)
foreach (INSTALLED_FILE ${INSTALL_MANIFEST})
# Save the root ceres include install directory, e.g. /usr/local/include/ceres
# so that we can remove it at the end.
if (NOT CERES_INCLUDE_INSTALL_ROOT)
get_filename_component(FILE_NAME ${INSTALLED_FILE} NAME)
if (FILE_NAME STREQUAL ceres.h)
# Ensure that the directory is nested as we expect, as we are going to
# remove it, and we do not want to remove files pertaining to anyone else.
get_filename_component(PARENT_DIR ${INSTALLED_FILE} PATH)
get_filename_component(PARENT_DIR_NAME ${PARENT_DIR} NAME)
if (PARENT_DIR_NAME STREQUAL ceres AND IS_DIRECTORY ${PARENT_DIR})
set(CERES_INCLUDE_INSTALL_ROOT ${PARENT_DIR})
endif (PARENT_DIR_NAME STREQUAL ceres AND IS_DIRECTORY ${PARENT_DIR})
endif (FILE_NAME STREQUAL ceres.h)
endif (NOT CERES_INCLUDE_INSTALL_ROOT)
message(STATUS "Uninstalling \"$ENV{DESTDIR}${INSTALLED_FILE}\"")
if (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}")
execute_process(COMMAND @CMAKE_COMMAND@
-E remove "$ENV{DESTDIR}${INSTALLED_FILE}"
OUTPUT_VARIABLE RM_OUT
RESULT_VARIABLE RM_RETVAL)
if (NOT ${RM_RETVAL} EQUAL 0)
message(FATAL_ERROR
"Problem when removing \"$ENV{DESTDIR}${INSTALLED_FILE}\"")
endif (NOT ${RM_RETVAL} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}")
message(STATUS "File \"$ENV{DESTDIR}${INSTALLED_FILE}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${INSTALLED_FILE}")
endforeach(INSTALLED_FILE)
# Removing Ceres include install directory.
if (CERES_INCLUDE_INSTALL_ROOT AND
EXISTS ${CERES_INCLUDE_INSTALL_ROOT})
message(STATUS "Removing Ceres include install directory: "
"\"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT}\"")
execute_process(COMMAND @CMAKE_COMMAND@
-E remove_directory
"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT}"
OUTPUT_VARIABLE RM_OUT
RESULT_VARIABLE RM_RETVAL)
if (NOT ${RM_RETVAL} EQUAL 0)
message(FATAL_ERROR
"Failed to remove: \"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT\"")
endif (NOT ${RM_RETVAL} EQUAL 0)
else (CERES_INCLUDE_INSTALL_ROOT AND
EXISTS ${CERES_INCLUDE_INSTALL_ROOT})
message(FATAL_ERROR "Failed to find Ceres installed include directory "
"(e.g. /usr/local/include/ceres), candidate: "
"\"$ENV{DESTDIR}${CERES_INCLUDE_INSTALL_ROOT}\"")
endif (CERES_INCLUDE_INSTALL_ROOT AND
EXISTS ${CERES_INCLUDE_INSTALL_ROOT})