diff --git a/ports/ceres/0001_add_missing_include_path.patch b/ports/ceres/0001_add_missing_include_path.patch new file mode 100644 index 000000000..8bb8dfb50 --- /dev/null +++ b/ports/ceres/0001_add_missing_include_path.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 02c72b5..15a947e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -582,7 +582,7 @@ include_directories( + # Note that this is *not* propagated to clients, ie CERES_INCLUDE_DIRS + # used by clients after find_package(Ceres) does not identify Eigen as + # as system headers. +-include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS}) ++include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}/Eigen) + + if (SUITESPARSE) + include_directories(${SUITESPARSE_INCLUDE_DIRS}) diff --git a/ports/ceres/0002_cmakelists_fixes.patch b/ports/ceres/0002_cmakelists_fixes.patch new file mode 100644 index 000000000..f806794a8 --- /dev/null +++ b/ports/ceres/0002_cmakelists_fixes.patch @@ -0,0 +1,42 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 15a947e..62d8c59 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -374,27 +374,7 @@ if (MINIGLOG) + GLOG_LIBRARY) + else (MINIGLOG) + unset(MINIGLOG_MAX_LOG_LEVEL CACHE) +- # Don't search with REQUIRED so that configuration continues if not found and +- # we can output an error messages explaining MINIGLOG option. +- find_package(Glog) +- if (NOT GLOG_FOUND) +- message(FATAL_ERROR "Can't find Google Log (glog). Please set either: " +- "glog_DIR (newer CMake built versions of glog) or GLOG_INCLUDE_DIR & " +- "GLOG_LIBRARY or enable MINIGLOG option to use minimal glog " +- "implementation.") +- endif(NOT GLOG_FOUND) +- # By default, assume gflags was found, updating the message if it was not. +- set(GLOG_GFLAGS_DEPENDENCY_MESSAGE +- " Assuming glog was built with gflags support as gflags was found. " +- "This will make gflags a public dependency of Ceres.") +- if (NOT GFLAGS_FOUND) +- set(GLOG_GFLAGS_DEPENDENCY_MESSAGE +- " Assuming glog was NOT built with gflags support as gflags was " +- "not found. If glog was built with gflags, please set the " +- "gflags search locations such that it can be found by Ceres. " +- "Otherwise, Ceres may fail to link due to missing gflags symbols.") +- endif(NOT GFLAGS_FOUND) +- message("-- Found Google Log (glog)." ${GLOG_GFLAGS_DEPENDENCY_MESSAGE}) ++ find_package(Glog REQUIRED) + endif (MINIGLOG) + + if (NOT SCHUR_SPECIALIZATIONS) +@@ -917,8 +897,6 @@ install(FILES "${Ceres_BINARY_DIR}/CeresConfig-install.cmake" + DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR}) + install(FILES "${Ceres_BINARY_DIR}/CeresConfigVersion.cmake" + "${Ceres_SOURCE_DIR}/cmake/FindEigen.cmake" +- "${Ceres_SOURCE_DIR}/cmake/FindGlog.cmake" +- "${Ceres_SOURCE_DIR}/cmake/FindGflags.cmake" + DESTINATION ${RELATIVE_CMAKECONFIG_INSTALL_DIR}) + + # Create an uninstall target to remove all installed files. diff --git a/ports/ceres/0003_remove_unnecessary_cmake_modules.patch b/ports/ceres/0003_remove_unnecessary_cmake_modules.patch new file mode 100644 index 000000000..698d410b9 --- /dev/null +++ b/ports/ceres/0003_remove_unnecessary_cmake_modules.patch @@ -0,0 +1,949 @@ +diff --git a/cmake/FindGflags.cmake b/cmake/FindGflags.cmake +deleted file mode 100644 +index 32c04ea..0000000 +--- a/cmake/FindGflags.cmake ++++ /dev/null +@@ -1,591 +0,0 @@ +-# 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). +-# FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION: True iff the version of gflags +-# found was built & installed / +-# exported as a CMake package. +-# +-# 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 AND CALLERS_CMAKE_FIND_LIBRARY_PREFIXES) +- set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") +- endif() +-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/] 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 _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 () +- return() +-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 +- 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 +- 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) +- +-# Protect against any alternative find_package scripts for this library having +-# been called previously (in a client project) which set GFLAGS_FOUND, but not +-# the other variables we require / set here which could cause the search logic +-# here to fail. +-unset(GFLAGS_FOUND) +- +-# ----------------------------------------------------------------- +-# 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 +- HINTS ${GFLAGS_INCLUDE_DIR_HINTS} +- PATHS ${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 +- HINTS ${GFLAGS_LIBRARY_DIR_HINTS} +- PATHS ${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) +diff --git a/cmake/FindGlog.cmake b/cmake/FindGlog.cmake +deleted file mode 100644 +index 979dced..0000000 +--- a/cmake/FindGlog.cmake ++++ /dev/null +@@ -1,346 +0,0 @@ +-# 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. +-# FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION: True iff the version of glog found +-# was built & installed / exported +-# as a CMake package. +-# +-# The following variables control the behaviour of this module: +-# +-# GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION: TRUE/FALSE, iff TRUE then +-# then prefer using an exported CMake configuration +-# generated by glog > 0.3.4 over searching for the +-# glog components manually. Otherwise (FALSE) +-# ignore any exported glog 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 +-# GLOG_INCLUDE_DIR_HINTS or GLOG_LIBRARY_DIR_HINTS +-# otherwise FALSE. +-# 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 AND CALLERS_CMAKE_FIND_LIBRARY_PREFIXES) +- set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}") +- endif() +-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/] 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 _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 () +- return() +-endmacro(GLOG_REPORT_NOT_FOUND) +- +-# Protect against any alternative find_package scripts for this library having +-# been called previously (in a client project) which set GLOG_FOUND, but not +-# the other variables we require / set here which could cause the search logic +-# here to fail. +-unset(GLOG_FOUND) +- +-# ----------------------------------------------------------------- +-# By default, if the user has expressed no preference for using an exported +-# glog CMake configuration over performing a search for the installed +-# components, and has not specified any hints for the search locations, then +-# prefer a glog exported configuration if available. +-if (NOT DEFINED GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION +- AND NOT GLOG_INCLUDE_DIR_HINTS +- AND NOT GLOG_LIBRARY_DIR_HINTS) +- message(STATUS "No preference for use of exported glog CMake configuration " +- "set, and no hints for include/library directories provided. " +- "Defaulting to preferring an installed/exported glog CMake configuration " +- "if available.") +- set(GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION TRUE) +-endif() +- +-if (GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION) +- # Try to find an exported CMake configuration for glog, as generated by +- # glog versions > 0.3.4 +- # +- # 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. +- # +- # NOTE: We use the NAMES option as glog erroneously uses 'google-glog' as its +- # project name when built with CMake, but exports itself as just 'glog'. +- # On Linux/OS X this does not break detection as the project name is +- # not used as part of the install path for the CMake package files, +- # e.g. /usr/local/lib/cmake/glog, where the suffix is hardcoded +- # in glog's CMakeLists. However, on Windows the project name *is* +- # part of the install prefix: C:/Program Files/google-glog/[include,lib]. +- # However, by default CMake checks: +- # C:/Program Files/ which does not +- # exist and thus detection fails. Thus we use the NAMES to force the +- # search to use both google-glog & glog. +- # +- # [1] http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_package +- find_package(glog QUIET +- NAMES google-glog glog +- NO_MODULE +- NO_CMAKE_PACKAGE_REGISTRY +- NO_CMAKE_BUILDS_PATH) +- if (glog_FOUND) +- message(STATUS "Found installed version of glog: ${glog_DIR}") +- else() +- # Failed to find an installed version of glog, repeat search allowing +- # exported build directories. +- message(STATUS "Failed to find installed glog CMake configuration, " +- "searching for glog build directories exported with CMake.") +- # Again pass NO_CMAKE_BUILDS_PATH, as we know that glog is exported and +- # do not want to treat projects built with the CMake GUI preferentially. +- find_package(glog QUIET +- NAMES google-glog glog +- NO_MODULE +- NO_CMAKE_BUILDS_PATH) +- if (glog_FOUND) +- message(STATUS "Found exported glog build directory: ${glog_DIR}") +- endif(glog_FOUND) +- endif(glog_FOUND) +- +- set(FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION ${glog_FOUND}) +- +- if (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION) +- message(STATUS "Detected glog version: ${glog_VERSION}") +- set(GLOG_FOUND ${glog_FOUND}) +- # glog wraps the include directories into the exported glog::glog target. +- set(GLOG_INCLUDE_DIR "") +- set(GLOG_LIBRARY glog::glog) +- else (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION) +- message(STATUS "Failed to find an installed/exported CMake configuration " +- "for glog, will perform search for installed glog components.") +- endif (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION) +-endif(GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION) +- +-if (NOT GLOG_FOUND) +- # Either failed to find an exported glog CMake configuration, or user +- # told us not to use one. Perform a manual search for all glog components. +- +- # 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 +- google-glog/include # CMake installs with project name prefix. +- google-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 +- google-glog/lib # CMake installs with project name prefix. +- google-glog/Lib) +- +- # Search supplied hint directories first if supplied. +- find_path(GLOG_INCLUDE_DIR +- NAMES glog/logging.h +- HINTS ${GLOG_INCLUDE_DIR_HINTS} +- PATHS ${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 +- HINTS ${GLOG_LIBRARY_DIR_HINTS} +- PATHS ${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[^/]*") +- +- glog_reset_find_library_prefix() +- +-endif(NOT GLOG_FOUND) +- +-# 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) +- +-# If we are using an exported CMake glog target, the include directories are +-# wrapped into the target itself, and do not have to be (and are not) +-# separately specified. In which case, we should not add GLOG_INCLUDE_DIRS +-# to the list of required variables in order that glog be reported as found. +-if (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION) +- set(GLOG_REQUIRED_VARIABLES GLOG_LIBRARIES) +-else() +- set(GLOG_REQUIRED_VARIABLES GLOG_INCLUDE_DIRS GLOG_LIBRARIES) +-endif() +- +-# Handle REQUIRED / QUIET optional arguments. +-include(FindPackageHandleStandardArgs) +-find_package_handle_standard_args(Glog DEFAULT_MSG +- ${GLOG_REQUIRED_VARIABLES}) +- +-# 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 +- glog_DIR) # Autogenerated by find_package(glog) +-endif (GLOG_FOUND) diff --git a/ports/ceres/0004_use_glog_target.patch b/ports/ceres/0004_use_glog_target.patch new file mode 100644 index 000000000..6ca328a8e --- /dev/null +++ b/ports/ceres/0004_use_glog_target.patch @@ -0,0 +1,25 @@ +diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt +index cc43fec..18b415b 100644 +--- a/internal/ceres/CMakeLists.txt ++++ b/internal/ceres/CMakeLists.txt +@@ -152,17 +152,9 @@ else (SCHUR_SPECIALIZATIONS) + endif (SCHUR_SPECIALIZATIONS) + + # Build the list of dependencies for Ceres based on the current configuration. +-if (NOT MINIGLOG AND GLOG_FOUND) +- list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES ${GLOG_LIBRARIES}) +- if (GFLAGS_FOUND) +- # If glog & gflags are both found, we assume that glog was built with +- # gflags, as it is awkward to perform a try_compile() to verify this +- # when gflags is an imported target (as it is in newer versions). +- # As glog #includes gflags/gflags.h in glog/logging.h if compiled with +- # gflags, it is thus a public dependency for Ceres in this case. +- list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES ${GFLAGS_LIBRARIES}) +- endif() +-endif (NOT MINIGLOG AND GLOG_FOUND) ++if (NOT MINIGLOG) ++ list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES glog::glog) ++endif (NOT MINIGLOG) + + if (SUITESPARSE AND SUITESPARSE_FOUND) + # Define version information for use in Solver::FullReport. diff --git a/ports/ceres/0005_fix_exported_ceres_config.patch b/ports/ceres/0005_fix_exported_ceres_config.patch new file mode 100644 index 000000000..5cc41013e --- /dev/null +++ b/ports/ceres/0005_fix_exported_ceres_config.patch @@ -0,0 +1,92 @@ +diff --git a/cmake/CeresConfig.cmake.in b/cmake/CeresConfig.cmake.in +index d0380de..bf4c2eb 100644 +--- a/cmake/CeresConfig.cmake.in ++++ b/cmake/CeresConfig.cmake.in +@@ -237,85 +237,8 @@ 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@) +-set(CERES_USES_GFLAGS @GFLAGS@) +-if (CERES_USES_MINIGLOG) +- set(MINIGLOG_INCLUDE_DIR ${CERES_INCLUDE_DIR}/ceres/internal/miniglog) +- if (NOT CERES_WAS_INSTALLED) +- # When Ceres was exported from the build tree, the miniglog headers +- # will be in Ceres internal source directory, not in the public headers +- # directory (they are copied with the public headers when installed). +- set(MINIGLOG_INCLUDE_DIR +- ${CERES_EXPORTED_SOURCE_DIR}/internal/ceres/miniglog) +- endif() +- if (NOT EXISTS ${MINIGLOG_INCLUDE_DIR}) +- ceres_report_not_found( +- "Failed to find miniglog headers in expected include directory: " +- "${MINIGLOG_INCLUDE_DIR}, 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. +- set(GLOG_WAS_BUILT_WITH_CMAKE @FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION@) +- if (GLOG_WAS_BUILT_WITH_CMAKE) +- set(glog_DIR @glog_DIR@) +- set(GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION TRUE) +- else() +- 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}) +- endif() +- +- # 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") +- else (GLOG_FOUND) +- ceres_report_not_found("Missing required Ceres " +- "dependency: glog. Searched using GLOG_INCLUDE_DIR_HINTS: " +- "${GLOG_INCLUDE_DIR_HINTS} and glog_DIR: ${glog_DIR}.") +- endif (GLOG_FOUND) +- list(APPEND CERES_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS}) +- +- # gflags is only a public dependency of Ceres via glog, thus is not required +- # if Ceres was built with MINIGLOG. +- if (CERES_USES_GFLAGS) +- # If gflags was found as an imported CMake target, we need to call +- # find_packge(Gflags) again here, as imported CMake targets are not +- # re-exported. Without this, the 'gflags-shared' target name which is +- # present in CERES_LIBRARIES in this case would not be defined, and so +- # CMake will assume it is a library name (which it is not) and fail to link. +- # +- # Append the locations of gflags when Ceres was built to the search path +- # hints. +- set(GFLAGS_WAS_BUILT_WITH_CMAKE @FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION@) +- if (GFLAGS_WAS_BUILT_WITH_CMAKE) +- set(gflags_DIR @gflags_DIR@) +- set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE) +- else() +- list(APPEND GFLAGS_INCLUDE_DIR_HINTS @GFLAGS_INCLUDE_DIR@) +- get_filename_component(CERES_BUILD_GFLAGS_LIBRARY_DIR @GFLAGS_LIBRARY@ PATH) +- list(APPEND GFLAGS_LIBRARY_DIR_HINTS ${CERES_BUILD_GFLAGS_LIBRARY_DIR}) +- endif() +- +- # Search quietly s/t we control the timing of the error message if not found. +- find_package(Gflags QUIET) +- if (GFLAGS_FOUND) +- message(STATUS "Found required Ceres dependency: gflags") +- else() +- ceres_report_not_found("Missing required Ceres " +- "dependency: gflags. Searched using GFLAGS_INCLUDE_DIR_HINTS: " +- "${GFLAGS_INCLUDE_DIR_HINTS} and gflags_DIR: ${gflags_DIR}.") +- endif() +- list(APPEND CERES_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR_HINTS}) +- endif() +-endif (CERES_USES_MINIGLOG) ++include (CMakeFindDependencyMacro) ++find_dependency (glog NO_MODULE) + + # Import exported Ceres targets, if they have not already been imported. + if (NOT TARGET ceres AND NOT Ceres_BINARY_DIR) diff --git a/ports/ceres/CONTROL b/ports/ceres/CONTROL index 208082de7..3c890ff53 100644 --- a/ports/ceres/CONTROL +++ b/ports/ceres/CONTROL @@ -1,5 +1,5 @@ Source: ceres -Version: 1.14.0-1 +Version: 1.14.0-3 # eigen is always required by CMake, even if it isn't used. Build-Depends: glog, eigen3 Description: non-linear optimization package diff --git a/ports/ceres/portfile.cmake b/ports/ceres/portfile.cmake index 98621116b..1c52b2d93 100644 --- a/ports/ceres/portfile.cmake +++ b/ports/ceres/portfile.cmake @@ -14,6 +14,12 @@ vcpkg_from_github( REF 1.14.0 SHA512 6dddddf5bd5834332a69add468578ad527e4d94fe85c9751ddf5fe9ad11a34918bdd9c994c49dd6ffc398333d0ac9752ac89aaef1293e2fe0a55524e303d415d HEAD_REF master + PATCHES + 0001_add_missing_include_path.patch + 0002_cmakelists_fixes.patch + 0003_remove_unnecessary_cmake_modules.patch + 0004_use_glog_target.patch + 0005_fix_exported_ceres_config.patch ) set(SUITESPARSE OFF) @@ -54,7 +60,7 @@ vcpkg_configure_cmake( -DLAPACK=${LAPACK} -DSUITESPARSE=${SUITESPARSE} -DGFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION=ON - -DGLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION=OFF # TheiaSfm doesn't work well with this + -DGLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION=OFF # TheiaSfm doesn't work well with this. -DMSVC_USE_STATIC_CRT=${MSVC_USE_STATIC_CRT_VALUE} ) @@ -69,10 +75,17 @@ endif() vcpkg_copy_pdbs() # Changes target search path -file(READ ${CURRENT_PACKAGES_DIR}/share/ceres/CeresConfig.cmake CERES_TARGETS) -string(REPLACE "get_filename_component(CURRENT_ROOT_INSTALL_DIR\n \${CERES_CURRENT_CONFIG_DIR}/../" - "get_filename_component(CURRENT_ROOT_INSTALL_DIR\n \${CERES_CURRENT_CONFIG_DIR}/../../" CERES_TARGETS "${CERES_TARGETS}") -file(WRITE ${CURRENT_PACKAGES_DIR}/share/ceres/CeresConfig.cmake "${CERES_TARGETS}") +if(WIN32) + file(READ ${CURRENT_PACKAGES_DIR}/share/ceres/CeresConfig.cmake CERES_TARGETS) + string(REPLACE "get_filename_component(CURRENT_ROOT_INSTALL_DIR\n \${CERES_CURRENT_CONFIG_DIR}/../" + "get_filename_component(CURRENT_ROOT_INSTALL_DIR\n \${CERES_CURRENT_CONFIG_DIR}/../../" CERES_TARGETS "${CERES_TARGETS}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/ceres/CeresConfig.cmake "${CERES_TARGETS}") +else() + file(READ ${CURRENT_PACKAGES_DIR}/share/ceres/CeresConfig.cmake CERES_TARGETS) + string(REPLACE "get_filename_component(CURRENT_ROOT_INSTALL_DIR\n \${CERES_CURRENT_CONFIG_DIR}/../../../" + "get_filename_component(CURRENT_ROOT_INSTALL_DIR\n \${CERES_CURRENT_CONFIG_DIR}/../../" CERES_TARGETS "${CERES_TARGETS}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/ceres/CeresConfig.cmake "${CERES_TARGETS}") +endif() # Clean file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) diff --git a/ports/jxrlib/CMakeLists.txt b/ports/jxrlib/CMakeLists.txt index 17f16bea4..727b96906 100644 --- a/ports/jxrlib/CMakeLists.txt +++ b/ports/jxrlib/CMakeLists.txt @@ -1,6 +1,6 @@ # Copyright Mathieu Malaterre # BSD (Same as jxrlib) -# Based on https://jxrlib.codeplex.com/discussions/440294 +# Based on https://jxrlib.codeplex.com/discussions/440294 # and modified for vcpkg packaging cmake_minimum_required(VERSION 2.8) project(jxrlib C) @@ -18,6 +18,10 @@ macro(JXR_MAKE_OBJ SET_NAME) endforeach() endmacro() +if(NOT MSVC) + add_definitions(-D__ANSI__) +endif() + include(TestBigEndian) test_big_endian(ISBIGENDIAN) if(ISBIGENDIAN) @@ -99,4 +103,4 @@ install(FILES jxrgluelib/JXRGlue.h jxrgluelib/JXRMeta.h jxrtestlib/JXRTest.h ) install(DIRECTORY common/include/ DESTINATION ${JXRLIB_INSTALL_INCLUDE_DIR} FILES_MATCHING PATTERN "*.h" -) \ No newline at end of file +) diff --git a/ports/jxrlib/portfile.cmake b/ports/jxrlib/portfile.cmake index 9b7cca5fb..01780c78e 100644 --- a/ports/jxrlib/portfile.cmake +++ b/ports/jxrlib/portfile.cmake @@ -11,9 +11,11 @@ vcpkg_from_github( file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) -# The file guiddef.h is part of the Windows SDK, -# we then remove the local copy shipped with jxrlib -file(REMOVE ${SOURCE_PATH}/common/include/guiddef.h) +if(NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES Darwin AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES Linux) + # The file guiddef.h is part of the Windows SDK, + # we then remove the local copy shipped with jxrlib + file(REMOVE ${SOURCE_PATH}/common/include/guiddef.h) +endif() vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} diff --git a/ports/zziplib/CMakeLists.txt b/ports/zziplib/CMakeLists.txt index e56df5da9..5873b1b23 100644 --- a/ports/zziplib/CMakeLists.txt +++ b/ports/zziplib/CMakeLists.txt @@ -10,9 +10,23 @@ include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) +endif() + +if(UNIX) + message(STATUS "Running ${SHELL_EXECUTABLE} ./configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/") + add_custom_target( + zziplib_autotools + ${SHELL_EXECUTABLE} ./configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + message(STATUS "Autotools should have finished their job") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/x86_64-pc-linux-gnu/zzip) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/x86_64-pc-linux-gnu) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/x86_64-apple-darwin18.2.0/zzip) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/x86_64-apple-darwin18.2.0) endif() option(BUILD_SHARED_LIBS "Build shared libraries" ON) @@ -40,6 +54,14 @@ set(HEADERS zzip/__debug.h zzip/write.h zzip/zzip.h ) +if(UNIX) + file(GLOB OTHER_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/x86_64-pc-linux-gnu/zzip/*.h) + list(APPEND HEADERS ${OTHER_HEADERS}) + file(GLOB OTHER_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/x86_64-apple-darwin18.2.0/zzip/*.h) + list(APPEND HEADERS ${OTHER_HEADERS}) +else() + list(APPEND HEADERS zzip/_msvc.h) +endif() # List the source files set(SRCS zzip/dir.c @@ -53,9 +75,12 @@ set(SRCS zzip/dir.c ) add_library(zziplib ${SRCS} ${HEADERS}) +if(UNIX) + add_dependencies(zziplib zziplib_autotools) +endif() if(BUILD_SHARED_LIBS) - target_compile_definitions(zziplib PRIVATE -DZZIPLIB_EXPORTS) + target_compile_definitions(zziplib PRIVATE -DZZIPLIB_EXPORTS) endif() target_link_libraries(zziplib ${ZLIB_LIBRARIES}) @@ -66,4 +91,4 @@ install(TARGETS zziplib LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib) -install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/zzip) \ No newline at end of file +install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/zzip) diff --git a/ports/zziplib/CONTROL b/ports/zziplib/CONTROL index 4d4f7ea58..8d28f08ac 100644 --- a/ports/zziplib/CONTROL +++ b/ports/zziplib/CONTROL @@ -1,4 +1,4 @@ Source: zziplib -Version: 0.13.69 +Version: 0.13.69-1 Build-Depends: zlib Description: library providing read access on ZIP-archives diff --git a/ports/zziplib/portfile.cmake b/ports/zziplib/portfile.cmake index 2ff90af94..554fdc540 100644 --- a/ports/zziplib/portfile.cmake +++ b/ports/zziplib/portfile.cmake @@ -10,6 +10,7 @@ file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA ) vcpkg_install_cmake()