Added CeresConfig.cmake based on this example:
    https://projects.kde.org/projects/kde/kdeexamples/repository/revisions/master/show/buildsystem/HowToInstallALibrary

Change-Id: I130cac5d43d9fbbf359abc04d3691e25c4e2bb63
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e47ca52..43d4430 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -423,12 +423,12 @@
 ENDIF (NOT ${BUILD_ANDROID})
 
 # Eigen
-MESSAGE("-- Check for Eigen 3.0")
+MESSAGE("-- Check for Eigen 3.x")
 FIND_PATH(EIGEN_INCLUDE NAMES Eigen/Core PATHS ${EIGEN_SEARCH_HEADERS})
 IF (NOT EXISTS ${EIGEN_INCLUDE})
   MESSAGE(FATAL_ERROR "Can't find Eigen. Try passing -DEIGEN_INCLUDE=...")
 ENDIF (NOT EXISTS ${EIGEN_INCLUDE})
-MESSAGE("-- Found Eigen 3.0: ${EIGEN_INCLUDE}")
+MESSAGE("-- Found Eigen 3.x: ${EIGEN_INCLUDE}")
 
 # Template specializations for the Schur complement based solvers. If
 # compile time, binary size or compiler performance is an issue, you
@@ -680,3 +680,47 @@
 
 ADD_CUSTOM_TARGET(uninstall
                   COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/uninstall.cmake)
+
+# Set up install directories. INCLUDE_INSTALL_DIR and LIB_INSTALL_DIR
+# must not be absolute paths.
+SET(LIB_INSTALL_DIR_SUFFIX "" CACHE
+    STRING "The directories where to install libraries to")
+SET(LIB_INSTALL_DIR lib${LIB_INSTALL_DIR_SUFFIX} )
+SET(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/Ceres)
+SET(INCLUDE_INSTALL_DIR include)
+
+# This "exports" all targets which have been put into the export set
+# "CeresExport". This means that CMake generates a file with the given
+# filename, which can later on be loaded by projects using this package.
+# This file contains ADD_LIBRARY(bar IMPORTED) statements for each target
+# in the export set, so when loaded later on CMake will create "imported"
+# library targets from these, which can be used in many ways in the same way
+# as a normal library target created via a normal ADD_LIBRARY().
+INSTALL(EXPORT CeresExport
+        DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE CeresTargets.cmake)
+
+# Figure out the relative path from the installed Config.cmake file to the
+# install prefix (which may be at runtime different from the chosen
+# CMAKE_INSTALL_PREFIX if under Windows the package was installed anywhere)
+# This relative path will be configured into the CeresConfig.cmake.
+FILE(RELATIVE_PATH relInstallDir
+     ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX})
+
+# Create a CeresConfig.cmake file. <name>Config.cmake files are searched by
+# FIND_PACKAGE() automatically. We configure that file so that we can put any
+# information we want in it, e.g. version numbers, include directories, etc.
+CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfig.cmake.in"
+               "${CMAKE_CURRENT_BINARY_DIR}/CeresConfig.cmake" @ONLY)
+
+# Additionally, when CMake has found a CeresConfig.cmake, it can check for a
+# CeresConfigVersion.cmake in the same directory when figuring out the version
+# of the package when a version has been specified in the FIND_PACKAGE() call,
+# e.g. FIND_PACKAGE(Ceres [1.4.2] REQUIRED). The version argument is optional.
+CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/cmake/CeresConfigVersion.cmake.in"
+               "${CMAKE_CURRENT_BINARY_DIR}/CeresConfigVersion.cmake" @ONLY)
+
+# Install these two files into the same directory as the generated exports-file.
+INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/CeresConfig.cmake"
+              "${CMAKE_CURRENT_BINARY_DIR}/CeresConfigVersion.cmake"
+              "${CMAKE_SOURCE_DIR}/cmake/depend.cmake"
+        DESTINATION ${CMAKECONFIG_INSTALL_DIR})
diff --git a/cmake/CeresConfig.cmake.in b/cmake/CeresConfig.cmake.in
new file mode 100644
index 0000000..d000046
--- /dev/null
+++ b/cmake/CeresConfig.cmake.in
@@ -0,0 +1,49 @@
+# Ceres Solver - A fast non-linear least squares minimizer
+# Copyright 2013 Google Inc. All rights reserved.
+# http://code.google.com/p/ceres-solver/
+#
+# 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)
+#
+
+# Get the directory
+GET_FILENAME_COMPONENT(currentDir ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+# Get the chosen install prefix
+GET_FILENAME_COMPONENT(rootDir ${currentDir}/@relInstallDir@ ABSOLUTE)
+
+# Set the version
+SET(CERES_VERSION @CERES_VERSION@ )
+
+# What is my include directory
+SET(CERES_INCLUDES "${rootDir}/@INCLUDE_INSTALL_DIR@")
+
+# Import the exported targets
+INCLUDE(${currentDir}/CeresTargets.cmake)
+INCLUDE(${currentDir}/depend.cmake)
+
+# Set the expected library variable
+SET(CERES_LIBRARIES ceres)
diff --git a/cmake/CeresConfigVersion.cmake.in b/cmake/CeresConfigVersion.cmake.in
new file mode 100644
index 0000000..a51fa82
--- /dev/null
+++ b/cmake/CeresConfigVersion.cmake.in
@@ -0,0 +1,50 @@
+# Ceres Solver - A fast non-linear least squares minimizer
+# Copyright 2013 Google Inc. All rights reserved.
+# http://code.google.com/p/ceres-solver/
+#
+# 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}")
diff --git a/cmake/depend.cmake b/cmake/depend.cmake
new file mode 100644
index 0000000..8796339
--- /dev/null
+++ b/cmake/depend.cmake
@@ -0,0 +1,103 @@
+# Ceres Solver - A fast non-linear least squares minimizer
+# Copyright 2013 Google Inc. All rights reserved.
+# http://code.google.com/p/ceres-solver/
+#
+# 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)
+#
+
+# Default locations to search for on various platforms.
+LIST(APPEND SEARCH_LIBS /usr/lib)
+LIST(APPEND SEARCH_LIBS /usr/local/lib)
+LIST(APPEND SEARCH_LIBS /usr/local/homebrew/lib) # Mac OS X
+LIST(APPEND SEARCH_LIBS /opt/local/lib)
+
+LIST(APPEND SEARCH_HEADERS /usr/include)
+LIST(APPEND SEARCH_HEADERS /usr/local/include)
+LIST(APPEND SEARCH_HEADERS /usr/local/homebrew/include) # Mac OS X
+LIST(APPEND SEARCH_HEADERS /opt/local/include)
+
+# Locations to search for Eigen
+SET(EIGEN_SEARCH_HEADERS ${SEARCH_HEADERS})
+LIST(APPEND EIGEN_SEARCH_HEADERS /usr/include/eigen3) # Ubuntu 10.04's default location.
+LIST(APPEND EIGEN_SEARCH_HEADERS /usr/local/include/eigen3)
+LIST(APPEND EIGEN_SEARCH_HEADERS /usr/local/homebrew/include/eigen3)  # Mac OS X
+LIST(APPEND EIGEN_SEARCH_HEADERS /opt/local/var/macports/software/eigen3/opt/local/include/eigen3) # Mac OS X
+
+# Google Flags
+OPTION(GFLAGS
+       "Enable Google Flags."
+       ON)
+
+IF (${GFLAGS})
+  MESSAGE("-- Check for Google Flags")
+  FIND_LIBRARY(GFLAGS_LIB NAMES gflags PATHS ${SEARCH_LIBS})
+  IF (NOT EXISTS ${GFLAGS_LIB})
+    MESSAGE(FATAL_ERROR
+            "Can't find Google Flags. Please specify: "
+            "-DGFLAGS_LIB=...")
+  ENDIF (NOT EXISTS ${GFLAGS_LIB})
+  MESSAGE("-- Found Google Flags library: ${GFLAGS_LIB}")
+  FIND_PATH(GFLAGS_INCLUDE NAMES gflags/gflags.h PATHS ${SEARCH_HEADERS})
+  IF (NOT EXISTS ${GFLAGS_INCLUDE})
+    MESSAGE(FATAL_ERROR
+            "Can't find Google Flags. Please specify: "
+            "-DGFLAGS_INCLUDE=...")
+  ENDIF (NOT EXISTS ${GFLAGS_INCLUDE})
+  MESSAGE("-- Found Google Flags header in: ${GFLAGS_INCLUDE}")
+ENDIF (${GFLAGS})
+
+# Google Logging
+MESSAGE("-- Check for Google Log")
+FIND_LIBRARY(GLOG_LIB NAMES glog PATHS ${SEARCH_LIBS})
+IF (NOT EXISTS ${GLOG_LIB})
+  MESSAGE(FATAL_ERROR
+          "Can't find Google Log. Please specify: "
+          "-DGLOG_LIB=...")
+ENDIF (NOT EXISTS ${GLOG_LIB})
+MESSAGE("-- Found Google Log library: ${GLOG_LIB}")
+
+FIND_PATH(GLOG_INCLUDE NAMES glog/logging.h PATHS ${SEARCH_HEADERS})
+IF (NOT EXISTS ${GLOG_INCLUDE})
+  MESSAGE(FATAL_ERROR
+          "Can't find Google Log. Please specify: "
+          "-DGLOG_INCLUDE=...")
+ENDIF (NOT EXISTS ${GLOG_INCLUDE})
+MESSAGE("-- Found Google Log header in: ${GLOG_INCLUDE}")
+
+# Eigen
+MESSAGE("-- Check for Eigen 3.x")
+FIND_PATH(EIGEN_INCLUDE NAMES Eigen/Core PATHS ${EIGEN_SEARCH_HEADERS})
+IF (NOT EXISTS ${EIGEN_INCLUDE})
+  MESSAGE(FATAL_ERROR "Can't find Eigen. Try passing -DEIGEN_INCLUDE=...")
+ENDIF (NOT EXISTS ${EIGEN_INCLUDE})
+MESSAGE("-- Found Eigen 3.x: ${EIGEN_INCLUDE}")
+
+
+INCLUDE_DIRECTORIES(
+  ${GLOG_INCLUDE}
+  ${EIGEN_INCLUDE}
+  )
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index 66c258e..4694ec5 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -137,6 +137,7 @@
   TARGET_LINK_LIBRARIES(miniglog log)
 
   INSTALL(TARGETS miniglog
+          EXPORT  CeresExport
           RUNTIME DESTINATION bin
           LIBRARY DESTINATION lib${LIB_SUFFIX}
           ARCHIVE DESTINATION lib${LIB_SUFFIX})
@@ -194,6 +195,7 @@
 TARGET_LINK_LIBRARIES(ceres ${CERES_LIBRARY_DEPENDENCIES})
 
 INSTALL(TARGETS ceres
+        EXPORT  CeresExport
         RUNTIME DESTINATION bin
         LIBRARY DESTINATION lib${LIB_SUFFIX}
         ARCHIVE DESTINATION lib${LIB_SUFFIX})
@@ -208,6 +210,7 @@
                         SOVERSION ${CERES_ABI_VERSION})
 
   INSTALL(TARGETS ceres_shared
+          EXPORT  CeresExport
           RUNTIME DESTINATION bin
           LIBRARY DESTINATION lib${LIB_SUFFIX}
           ARCHIVE DESTINATION lib${LIB_SUFFIX})