cmake_minimum_required(VERSION 2.8) project(DBoW2) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native") set(HDRS_DBOW2 DBoW2/BowVector.h DBoW2/FORB.h DBoW2/FClass.h DBoW2/FeatureVector.h DBoW2/ScoringObject.h DBoW2/TemplatedVocabulary.h) set(SRCS_DBOW2 DBoW2/BowVector.cpp DBoW2/FORB.cpp DBoW2/FeatureVector.cpp DBoW2/ScoringObject.cpp) set(HDRS_DUTILS DUtils/Random.h DUtils/Timestamp.h) set(SRCS_DUTILS DUtils/Random.cpp DUtils/Timestamp.cpp) # 要保证整个工程的opencv版本一致,包括dbow,源码以及ros相关的 # 3 4 都可以正常运行 find_package(OpenCV 3.2 QUIET) if(NOT OpenCV_FOUND) find_package(OpenCV 3.0 QUIET) if(NOT OpenCV_FOUND) message(FATAL_ERROR "OpenCV > 3.0 not found.") endif() endif() set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) include_directories(${OpenCV_INCLUDE_DIRS}) add_library(DBoW2 SHARED ${SRCS_DBOW2} ${SRCS_DUTILS}) target_link_libraries(DBoW2 ${OpenCV_LIBS})