Skip to content

Commit

Permalink
Support Flann and Cereal from external dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
KindDragon committed Jul 4, 2017
1 parent 39f0081 commit 09be14d
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 48 deletions.
79 changes: 62 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,69 @@ include_directories(
# as system headers.
include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS})


set(THEIA_USE_SYSTEM_CEREAL OFF CACHE BOOL "Use a system Cereal library")
set(THEIA_USE_SYSTEM_FLANN OFF CACHE BOOL "Use a system Flann library")

include_directories(libraries)

# build Third party libraries included in distro.
add_subdirectory(libraries)
include_directories(
libraries
libraries/spectra
${akaze_SOURCE_DIR}
${akaze_INCLUDE_DIR}
${cereal_SOURCE_DIR}
${cereal_SOURCE_DIR}/include
${flann_SOURCE_DIR}
${flann_SOURCE_DIR}/src/cpp
${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR}
${optimo_SOURCE_DIR}
${statx_SOURCE_DIR}
${stlplus3_SOURCE_DIR}
${vlfeat_SOURCE_DIR}
${visual_sfm_SOURCE_DIR})
if (${BUILD_TESTING})
add_subdirectory(libraries/gtest)
endif (${BUILD_TESTING})

# AKAZE feature extractor.
add_subdirectory(libraries/akaze)

include_directories(${akaze_SOURCE_DIR} ${akaze_INCLUDE_DIR})

# Cereal for portable IO.
if(NOT THEIA_USE_SYSTEM_CEREAL)
add_subdirectory(libraries/cereal)

include_directories(${cereal_SOURCE_DIR} ${cereal_SOURCE_DIR}/include)
else()
find_package(cereal REQUIRED)

set(_THEIA_CEREAL_LIBRARIES cereal)
endif()

# Flann for fast approximate nearest neighbor searches.
if(NOT THEIA_USE_SYSTEM_FLANN)
add_subdirectory(libraries/flann)

include_directories(${flann_SOURCE_DIR} ${flann_SOURCE_DIR}/src/cpp)
set(_THEIA_FLANN_LIBRARIES flann_cpp)
else()
find_package(Flann REQUIRED)

include_directories(${FLANN_INCLUDE_DIR})
set(_THEIA_FLANN_LIBRARIES ${FLANN_LIBRARY})
endif()

# Add Optimo.
add_subdirectory(libraries/optimo)
include_directories(${optimo_SOURCE_DIR})

# Add Spectra.
include_directories(libraries/spectra)

# Add Statx.
add_subdirectory(libraries/statx)
include_directories(${statx_SOURCE_DIR})

# STLPlus for filepath tools.
add_subdirectory(libraries/stlplus3)
include_directories(${stlplus3_SOURCE_DIR})

# Add VLFeat.
add_subdirectory(libraries/vlfeat)
include_directories(${vlfeat_SOURCE_DIR})

# Add VisualSfM files.
add_subdirectory(libraries/visual_sfm)
include_directories(${visual_sfm_SOURCE_DIR})


list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(OptimizeTheiaCompilerFlags)
Expand Down
63 changes: 63 additions & 0 deletions cmake/FindFlann.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Find FLANN
#
# This sets the following variables:
# FLANN_FOUND - True if FLANN was found.
# FLANN_INCLUDE_DIRS - Directories containing the FLANN include files.
# FLANN_LIBRARIES - Libraries needed to use FLANN.
# FLANN_DEFINITIONS - Compiler flags for FLANN.
# If FLANN_USE_STATIC is specified and then look for static libraries ONLY else
# look for shared ones

if(FLANN_USE_STATIC)
set(FLANN_RELEASE_NAME flann_cpp_s flann_cpp)
set(FLANN_DEBUG_NAME flann_cpp_s-gd flann_cpp-gd)
else(FLANN_USE_STATIC)
set(FLANN_RELEASE_NAME flann_cpp)
set(FLANN_DEBUG_NAME flann_cpp-gd)
endif(FLANN_USE_STATIC)

find_package(PkgConfig QUIET)
if (FLANN_FIND_VERSION)
pkg_check_modules(PC_FLANN flann>=${FLANN_FIND_VERSION})
else(FLANN_FIND_VERSION)
pkg_check_modules(PC_FLANN flann)
endif(FLANN_FIND_VERSION)

set(FLANN_DEFINITIONS ${PC_FLANN_CFLAGS_OTHER})

find_path(FLANN_INCLUDE_DIR flann/flann.hpp
HINTS ${PC_FLANN_INCLUDEDIR} ${PC_FLANN_INCLUDE_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}"
PATHS "$ENV{PROGRAMFILES}/Flann" "$ENV{PROGRAMW6432}/Flann"
PATH_SUFFIXES include)

find_library(FLANN_LIBRARY
NAMES ${FLANN_RELEASE_NAME}
HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}"
PATHS "$ENV{PROGRAMFILES}/Flann" "$ENV{PROGRAMW6432}/Flann"
PATH_SUFFIXES lib)

find_library(FLANN_LIBRARY_DEBUG
NAMES ${FLANN_DEBUG_NAME} ${FLANN_RELEASE_NAME}
HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS} "${FLANN_ROOT}" "$ENV{FLANN_ROOT}"
PATHS "$ENV{PROGRAMFILES}/Flann" "$ENV{PROGRAMW6432}/Flann"
PATH_SUFFIXES lib)

if(NOT FLANN_LIBRARY_DEBUG)
set(FLANN_LIBRARY_DEBUG ${FLANN_LIBRARY})
endif(NOT FLANN_LIBRARY_DEBUG)

set(FLANN_INCLUDE_DIRS ${FLANN_INCLUDE_DIR})
set(FLANN_LIBRARIES optimized ${FLANN_LIBRARY} debug ${FLANN_LIBRARY_DEBUG})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FLANN DEFAULT_MSG FLANN_LIBRARY FLANN_INCLUDE_DIR)

mark_as_advanced(FLANN_LIBRARY FLANN_LIBRARY_DEBUG FLANN_INCLUDE_DIR)

if(FLANN_FOUND)
message(STATUS "Flann found (include: ${FLANN_INCLUDE_DIRS}, lib: ${FLANN_LIBRARIES})")
if(FLANN_USE_STATIC)
add_definitions(-DFLANN_STATIC)
endif(FLANN_USE_STATIC)
endif(FLANN_FOUND)
27 changes: 0 additions & 27 deletions libraries/CMakeLists.txt

This file was deleted.

9 changes: 5 additions & 4 deletions src/theia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,15 @@ set(THEIA_LIBRARY_DEPENDENCIES
${CERES_LIBRARIES}
${GFLAGS_LIBRARIES}
${GLOG_LIBRARIES}
${SUITESPARSE_LIBRARIES}
${OPENIMAGEIO_LIBRARIES}
${SUITESPARSE_LIBRARIES}
${_THEIA_CEREAL_LIBRARIES}
${_THEIA_FLANN_LIBRARIES}
akaze
flann_cpp
statx
stlplus3
vlfeat
visual_sfm)
visual_sfm
vlfeat)

set(THEIA_LIBRARY_SOURCE
${THEIA_SRC}
Expand Down

0 comments on commit 09be14d

Please sign in to comment.