Ceres and SuiteSparse features (#2800)

* [suitesparse] Implement optional feature: metis

* [ceres] Implement optional features: lapack, suitesparse, cxsparse, eigen. Closes #2798

* [ceres] Always require Eigen3
This commit is contained in:
Arkady Shapkin 2018-02-17 14:16:32 +03:00 committed by Robert Schumacher
parent 6142925568
commit 18be859328
6 changed files with 80 additions and 265 deletions

View File

@ -1,4 +1,24 @@
Source: ceres
Version: 1.13.0-2
Build-Depends:suitesparse, eigen3, clapack, gflags, glog
Version: 1.13.0-4
# eigen is always required by CMake, even if it isn't used.
Build-Depends: glog, eigen3
Description: non-linear optimization package
Feature: lapack
Build-Depends: clapack
Description: Use Lapack in Ceres
Feature: suitesparse
Build-Depends: ceres[lapack], suitesparse[core]
Description: SuiteSparse support for Ceres
Feature: cxsparse
Build-Depends: suitesparse[core]
Description: CXSparse support for Ceres
Feature: eigensparse
Description: Use of Eigen as a sparse linear algebra library in Ceres
Feature: tools
Build-Depends: gflags
Description: Ceres tools

View File

@ -1,247 +0,0 @@
--- a/cmake/FindSuiteSparse.cmake Mon Dec 05 18:42:48 2016
+++ b/cmake/FindSuiteSparse.cmake Fri Jul 07 01:50:54 2017
@@ -179,8 +179,6 @@
/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}
@@ -188,9 +186,10 @@
/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)
+# Additional suffixes to try appending to each search path.
+list(APPEND SUITESPARSE_CHECK_PATH_SUFFIXES
+ suitesparse) # Windows/Ubuntu
# Given the number of components of SuiteSparse, and to ensure that the
# automatic failure message generated by FindPackageHandleStandardArgs()
@@ -218,7 +217,8 @@
set(AMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS AMD_FOUND)
find_library(AMD_LIBRARY NAMES amd
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${AMD_LIBRARY})
message(STATUS "Found AMD library: ${AMD_LIBRARY}")
else (EXISTS ${AMD_LIBRARY})
@@ -229,7 +229,8 @@
mark_as_advanced(AMD_LIBRARY)
find_path(AMD_INCLUDE_DIR NAMES amd.h
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${AMD_INCLUDE_DIR})
message(STATUS "Found AMD header in: ${AMD_INCLUDE_DIR}")
else (EXISTS ${AMD_INCLUDE_DIR})
@@ -243,7 +244,8 @@
set(CAMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CAMD_FOUND)
find_library(CAMD_LIBRARY NAMES camd
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${CAMD_LIBRARY})
message(STATUS "Found CAMD library: ${CAMD_LIBRARY}")
else (EXISTS ${CAMD_LIBRARY})
@@ -254,7 +256,8 @@
mark_as_advanced(CAMD_LIBRARY)
find_path(CAMD_INCLUDE_DIR NAMES camd.h
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${CAMD_INCLUDE_DIR})
message(STATUS "Found CAMD header in: ${CAMD_INCLUDE_DIR}")
else (EXISTS ${CAMD_INCLUDE_DIR})
@@ -268,7 +271,8 @@
set(COLAMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS COLAMD_FOUND)
find_library(COLAMD_LIBRARY NAMES colamd
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${COLAMD_LIBRARY})
message(STATUS "Found COLAMD library: ${COLAMD_LIBRARY}")
else (EXISTS ${COLAMD_LIBRARY})
@@ -279,7 +283,8 @@
mark_as_advanced(COLAMD_LIBRARY)
find_path(COLAMD_INCLUDE_DIR NAMES colamd.h
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${COLAMD_INCLUDE_DIR})
message(STATUS "Found COLAMD header in: ${COLAMD_INCLUDE_DIR}")
else (EXISTS ${COLAMD_INCLUDE_DIR})
@@ -293,7 +298,8 @@
set(CCOLAMD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CCOLAMD_FOUND)
find_library(CCOLAMD_LIBRARY NAMES ccolamd
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${CCOLAMD_LIBRARY})
message(STATUS "Found CCOLAMD library: ${CCOLAMD_LIBRARY}")
else (EXISTS ${CCOLAMD_LIBRARY})
@@ -304,7 +310,8 @@
mark_as_advanced(CCOLAMD_LIBRARY)
find_path(CCOLAMD_INCLUDE_DIR NAMES ccolamd.h
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${CCOLAMD_INCLUDE_DIR})
message(STATUS "Found CCOLAMD header in: ${CCOLAMD_INCLUDE_DIR}")
else (EXISTS ${CCOLAMD_INCLUDE_DIR})
@@ -318,7 +325,8 @@
set(CHOLMOD_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS CHOLMOD_FOUND)
find_library(CHOLMOD_LIBRARY NAMES cholmod
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${CHOLMOD_LIBRARY})
message(STATUS "Found CHOLMOD library: ${CHOLMOD_LIBRARY}")
else (EXISTS ${CHOLMOD_LIBRARY})
@@ -329,7 +337,8 @@
mark_as_advanced(CHOLMOD_LIBRARY)
find_path(CHOLMOD_INCLUDE_DIR NAMES cholmod.h
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${CHOLMOD_INCLUDE_DIR})
message(STATUS "Found CHOLMOD header in: ${CHOLMOD_INCLUDE_DIR}")
else (EXISTS ${CHOLMOD_INCLUDE_DIR})
@@ -343,7 +352,8 @@
set(SUITESPARSEQR_FOUND TRUE)
list(APPEND SUITESPARSE_FOUND_REQUIRED_VARS SUITESPARSEQR_FOUND)
find_library(SUITESPARSEQR_LIBRARY NAMES spqr
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${SUITESPARSEQR_LIBRARY})
message(STATUS "Found SuiteSparseQR library: ${SUITESPARSEQR_LIBRARY}")
else (EXISTS ${SUITESPARSEQR_LIBRARY})
@@ -354,7 +364,8 @@
mark_as_advanced(SUITESPARSEQR_LIBRARY)
find_path(SUITESPARSEQR_INCLUDE_DIR NAMES SuiteSparseQR.hpp
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${SUITESPARSEQR_INCLUDE_DIR})
message(STATUS "Found SuiteSparseQR header in: ${SUITESPARSEQR_INCLUDE_DIR}")
else (EXISTS ${SUITESPARSEQR_INCLUDE_DIR})
@@ -370,7 +381,8 @@
# 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})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${TBB_LIBRARIES})
message(STATUS "Found Intel Thread Building Blocks (TBB) library: "
"${TBB_LIBRARIES}, assuming SuiteSparseQR was compiled with TBB.")
@@ -383,7 +395,8 @@
if (TBB_FOUND)
find_library(TBB_MALLOC_LIB NAMES tbbmalloc
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${TBB_MALLOC_LIB})
message(STATUS "Found Intel Thread Building Blocks (TBB) Malloc library: "
"${TBB_MALLOC_LIB}")
@@ -413,7 +426,8 @@
# 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})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${SUITESPARSE_CONFIG_LIBRARY})
message(STATUS "Found SuiteSparse_config library: "
"${SUITESPARSE_CONFIG_LIBRARY}")
@@ -421,7 +435,8 @@
mark_as_advanced(SUITESPARSE_CONFIG_LIBRARY)
find_path(SUITESPARSE_CONFIG_INCLUDE_DIR NAMES SuiteSparse_config.h
- PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${SUITESPARSE_CONFIG_INCLUDE_DIR})
message(STATUS "Found SuiteSparse_config header in: "
"${SUITESPARSE_CONFIG_INCLUDE_DIR}")
@@ -439,7 +454,8 @@
# 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})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (LIBRT_LIBRARY)
message(STATUS "Adding librt: ${LIBRT_LIBRARY} to "
"SuiteSparse_config libraries (required on Linux & Unix [not OSX] if "
@@ -458,7 +474,8 @@
# 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})
+ PATHS ${SUITESPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${UFCONFIG_INCLUDE_DIR})
message(STATUS "Found UFconfig header in: ${UFCONFIG_INCLUDE_DIR}")
set(UFCONFIG_FOUND TRUE)
@@ -549,7 +566,8 @@
# METIS (Optional dependency).
find_library(METIS_LIBRARY NAMES metis
- PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS})
+ PATHS ${SUITESPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${SUITESPARSE_CHECK_PATH_SUFFIXES})
if (EXISTS ${METIS_LIBRARY})
message(STATUS "Found METIS library: ${METIS_LIBRARY}.")
set(METIS_FOUND TRUE)
--- a/cmake/FindCXSparse.cmake Mon Dec 05 18:42:48 2016
+++ b/cmake/FindCXSparse.cmake Fri Jul 07 01:50:04 2017
@@ -135,12 +135,16 @@
/usr/local/homebrew/lib # Mac OS X.
/opt/local/lib
/usr/lib)
+# Additional suffixes to try appending to each search path.
+list(APPEND CXSPARSE_CHECK_PATH_SUFFIXES
+ suitesparse) # Linux/Windows
# Search supplied hint directories first if supplied.
find_path(CXSPARSE_INCLUDE_DIR
NAMES cs.h
- PATHS ${CXSPARSE_INCLUDE_DIR_HINTS}
- ${CXSPARSE_CHECK_INCLUDE_DIRS})
+ HINTS ${CXSPARSE_INCLUDE_DIR_HINTS}
+ PATHS ${CXSPARSE_CHECK_INCLUDE_DIRS}
+ PATH_SUFFIXES ${CXSPARSE_CHECK_PATH_SUFFIXES})
if (NOT CXSPARSE_INCLUDE_DIR OR
NOT EXISTS ${CXSPARSE_INCLUDE_DIR})
cxsparse_report_not_found(
@@ -150,8 +154,9 @@
NOT EXISTS ${CXSPARSE_INCLUDE_DIR})
find_library(CXSPARSE_LIBRARY NAMES cxsparse
- PATHS ${CXSPARSE_LIBRARY_DIR_HINTS}
- ${CXSPARSE_CHECK_LIBRARY_DIRS})
+ HINTS ${CXSPARSE_LIBRARY_DIR_HINTS}
+ PATHS ${CXSPARSE_CHECK_LIBRARY_DIRS}
+ PATH_SUFFIXES ${CXSPARSE_CHECK_PATH_SUFFIXES})
if (NOT CXSPARSE_LIBRARY OR
NOT EXISTS ${CXSPARSE_LIBRARY})
cxsparse_report_not_found(

View File

@ -16,24 +16,45 @@ vcpkg_from_github(
HEAD_REF master
)
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/fix-find-packages.patch
)
# Ninja crash compiler with error:
# "fatal error C1001: An internal error has occurred in the compiler. (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 255)"
set(SUITESPARSE OFF)
if("suitesparse" IN_LIST FEATURES)
set(SUITESPARSE ON)
endif()
set(CXSPARSE OFF)
if("cxsparse" IN_LIST FEATURES)
set(CXSPARSE ON)
endif()
set(LAPACK OFF)
if("lapack" IN_LIST FEATURES)
set(LAPACK ON)
endif()
set(EIGENSPARSE OFF)
if("eigensparse" IN_LIST FEATURES)
set(EIGENSPARSE ON)
endif()
set(GFLAGS OFF)
if("tools" IN_LIST FEATURES)
set(GFLAGS ON)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DEXPORT_BUILD_DIR=ON
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
-DCXSPARSE=ON
-DEIGENSPARSE=ON
-DSUITESPARSE=ON
-DGFLAGS=${GFLAGS}
-DCXSPARSE=${CXSPARSE}
-DEIGENSPARSE=${EIGENSPARSE}
-DLAPACK=${LAPACK}
-DSUITESPARSE=${SUITESPARSE}
-DGFLAGS_PREFER_EXPORTED_GFLAGS_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}
@ -41,7 +62,6 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH "CMake")
vcpkg_copy_pdbs()
# Changes target search path

View File

@ -1,4 +1,8 @@
Source: suitesparse
Version: 4.5.5-3
Build-Depends: metis, clapack
Version: 4.5.5-4
Build-Depends: clapack
Description: algebra library
Feature: metis
Build-Depends: metis
Description: Use metis in SuiteSparse

View File

@ -1,7 +1,20 @@
diff --git "a/SuiteSparse/CMakeLists.txt" "b/SuiteSparse/CMakeLists.txt"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8227298..c0eb354 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -222,7 +222,7 @@ ELSE()
ENDIF()
ENDIF()
-IF(BUILD_METIS)
+IF(BUILD_METIS OR USE_VCPKG_METIS)
set(SuiteSparse_LINKER_METIS_LIBS "metis")
else()
set(SuiteSparse_LINKER_METIS_LIBS "")
diff --git a/SuiteSparse/CMakeLists.txt b/SuiteSparse/CMakeLists.txt
index 7361363..8a48cf3 100644
--- "a/SuiteSparse/CMakeLists.txt"
+++ "b/SuiteSparse/CMakeLists.txt"
--- a/SuiteSparse/CMakeLists.txt
+++ b/SuiteSparse/CMakeLists.txt
@@ -10,7 +10,11 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
IF (BUILD_METIS)
INCLUDE_DIRECTORIES("${METIS_SOURCE_DIR}/include")

View File

@ -45,12 +45,17 @@ vcpkg_apply_patches(
PATCHES "${CMAKE_CURRENT_LIST_DIR}/remove-debug-postfix.patch"
)
set(USE_VCPKG_METIS OFF)
if("metis" IN_LIST FEATURES)
set(USE_VCPKG_METIS ON)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SUITESPARSEWIN_PATH}
PREFER_NINJA
OPTIONS
-DBUILD_METIS=OFF #Disable the option to build metis from source
-DUSE_VCPKG_METIS=ON #Force using vcpckg metis library
-DUSE_VCPKG_METIS=${USE_VCPKG_METIS} #Force using vcpckg metis library
-DMETIS_SOURCE_DIR=${CURRENT_INSTALLED_DIR}
-DLIB_POSTFIX=
-DSUITESPARSE_USE_CUSTOM_BLAS_LAPACK_LIBS=ON