From 2e1c2d6b4357a210b246f8bbf96a392e4755bef3 Mon Sep 17 00:00:00 2001 From: Xiaohan Fei Date: Sun, 20 Feb 2022 14:28:24 -0800 Subject: [PATCH] clean up -- remove more hard-coded paths --- CMakeLists.txt | 95 +++++++++++++++++++------------------------ build.sh | 3 +- common/CMakeLists.txt | 4 -- src/CMakeLists.txt | 4 -- 4 files changed, 43 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8c2a10..9210a89e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.5) -project(feh) + +# vision lab visual-inertial navigation system +project(vl_vins) # Set operating system variables if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") @@ -43,38 +45,44 @@ add_definitions(-DGOOGLE_STRIP_LOG=1) # add_definitions(-DEIGEN_DEFAULT_TO_ROW_MAJOR) add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_ZERO) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/thirdparty) +set(THIRD_PARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty") +list(APPEND CMAKE_PREFIX_PATH ${THIRD_PARTY_DIR}) -# Find and add OpenCV to libraries -find_package(OpenCV REQUIRED) +find_package(OpenCV REQUIRED PATHS ${THIRD_PARTY_DIR}/opencv/install) find_package(Python3 REQUIRED Interpreter Development) find_package(Pangolin REQUIRED) find_package(jsoncpp REQUIRED) + # Google stuff find_package(gflags REQUIRED) find_package(GTest REQUIRED NAMES GTest gtest googletest GoogleTest) find_package(glog REQUIRED) find_package(Ceres REQUIRED) -# Find and add DBoW2 + +# DBoW2 find_package(DBoW2 REQUIRED) -# Create an interface target for DBoW2 (since DBoW2 does not export headers & libraries as a target) +# Create an interface target for DBoW2 (since DBoW2 does not export headers & libraries as a target). +# We will add the DBoW2 target to our dependency list in a bit. add_library(DBoW2 INTERFACE) target_include_directories(DBoW2 INTERFACE ${DBoW2_INCLUDE_DIR}) target_link_libraries(DBoW2 INTERFACE ${DBoW2_LIBS}) +# The dependency PNP does not properly export a target for easy integration, +# so we create an interface target here, and will add the interface target to +# the dependency list in a bit. +add_library(pnp INTERFACE) +target_include_directories(pnp INTERFACE ${THIRD_PARTY_DIR}/pnp) +target_link_libraries(pnp INTERFACE ${THIRD_PARTY_DIR}/pnp/build/liblibpnp.a) + # TODO (xiaohfei): this is not working since gperftools does not properly generate cmake config files. # Need to manually add gperftools if needed. if (USE_GPERFTOOLS) find_package(gperftools REQUIRED) endif() -# The dependency PNP does have proper installation target, need to manually specify paths. -add_library(pnp INTERFACE) -target_include_directories(pnp INTERFACE ${CMAKE_SOURCE_DIR}/thirdparty/pnp) -target_link_libraries(pnp INTERFACE ${CMAKE_SOURCE_DIR}/thirdparty/pnp/build/liblibpnp.a) list(APPEND DEPS - # opencv + # OpenCV opencv_highgui opencv_features2d opencv_core @@ -82,62 +90,46 @@ list(APPEND DEPS opencv_imgproc opencv_imgcodecs opencv_xfeatures2d - # google stuff + + # Google stuff glog::glog GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main gflags_static - # graphics - GLEW - pangolin - # solver + + # Ceres::ceres should carry over all its own dependencies, so we don't need + # to add the following dependencies: cxsparse, cholmod, lapack, and blas. + # But if needed, you can add them back. Ceres::ceres - pnp - cxsparse - cholmod - lapack - blas - # utils - jsoncpp_lib + # Use jsoncpp_static if you are building modules of xivo as static libraryies # jsoncpp_static + jsoncpp_lib + + # Target "pangolin" exported by Pangolin should carry over its own dependencies, i.e., + # GLEW and GL (in Linux). If needed, you can manually add them. + pangolin + + # Loop closure dependencies. + pnp DBoW2 - # system - pthread ) -if (IS_LINUX) - list(APPEND DEPS GL) -endif (IS_LINUX) link_libraries(${DEPS}) -# Manually add link directories (ideally we dont have to use this) -link_directories( - /usr/local/lib - /usr/lib/x86_64-linux-gnu -) include_directories( ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/src - # Manually add include dirs, ideally we don't need this - # ${JSONCPP_INCLUDE_DIRS} - # ${OpenCV_INCLUDE_DIRS} - # ${Python3_INCLUDE_DIRS} - /usr/include/suitesparse - /usr/include ) - - enable_testing() -# add_subdirectory(thirdparty/abseil-cpp) if (BUILD_G2O) - link_directories(${CMAKE_SOURCE_DIR}/thirdparty/g2o/release/lib) - include_directories(${CMAKE_SOURCE_DIR}/thirdparty/g2o/release/include) - list(APPEND deps + link_directories(${THIRD_PARTY_DIR}/g2o/release/lib) + include_directories(${THIRD_PARTY_DIR}/g2o/release/include) + link_libraries( g2o_core g2o_solver_dense g2o_solver_cholmod @@ -146,12 +138,9 @@ if (BUILD_G2O) g2o_types_slam3d g2o_types_sba g2o_stuff - cholmod - cxsparse - ) +) endif(BUILD_G2O) -# feh add_subdirectory(common) add_subdirectory(src) @@ -166,10 +155,10 @@ add_subdirectory(src) # If you see an error saying "Python.h: No such file or directory", you probably # need to "sudo apt-get install python3-dev" assuming you are binding to python3. set(PYBIND11_CPP_STANDARD -std=c++17) -add_subdirectory(thirdparty/pybind11) +add_subdirectory(${THIRD_PARTY_DIR}/pybind11) pybind11_add_module(pyxivo MODULE pybind11/pyxivo.cpp) -set(libxivo common xest xapp) +set(pybind_deps common xest xapp) if (BUILD_G2O) - list(APPEND libxivo xopt) + list(APPEND pybind_deps xopt) endif(BUILD_G2O) -target_link_libraries(pyxivo PRIVATE ${libxivo}) +target_link_libraries(pyxivo PRIVATE ${pybind_deps}) diff --git a/build.sh b/build.sh index d69a4837..464b968c 100755 --- a/build.sh +++ b/build.sh @@ -34,8 +34,7 @@ if [ $USE_GPERFTOOLS = true ]; then fi CPU_COUNT=4 -# OPENCV_INSTALL_DIR=/media/data3/stsuei/DevelopmentEnvironments/xivo_gcc9/share/OpenCV -OPENCV_INSTALL_DIR=$PWD/thirdparty/opencv/install/share/OpenCV +OPENCV_INSTALL_DIR=/media/data3/stsuei/DevelopmentEnvironments/xivo_gcc9/share/OpenCV # build dependencies PROJECT_DIR=$(pwd) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 7251d411..eaed3c8e 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,10 +1,6 @@ cmake_minimum_required(VERSION 3.5) project(common) -# # uncomment to overwrite target destinations -# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) -# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib) - add_library(common STATIC utils.cpp) # option(BUILD_COMMON_TESTS True) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5366ee5c..a50e9364 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 3.5) project(estimator) -# # overwrite binary output directory -# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) -# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) - # if set, use inverse-depth parametrization # add_definitions(-DUSE_INVDEPTH)