首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“普通”构建和ExternalProject_Add之间的行为差异

“普通”构建和ExternalProject_Add之间的行为差异
EN

Stack Overflow用户
提问于 2019-05-24 21:21:13
回答 1查看 561关注 0票数 0

我正在尝试使用CMake的外部项目功能在linux上构建ceres-solver。

我构建了一个特定版本的Eigen,其他依赖项是通过我的包管理器(BLAS、LAPACK和Suitesparse)安装的。

如果我直接从源代码构建Ceres-solver:

代码语言:javascript
复制
cmake -G Ninja -DEIGEN_INCLUDE_DIR='<path-to-eigen>' -DEIGEN_BUILD_DIR='<path-to-eigen-build>' ..

它自动查找suitesparse及其所有依赖项(BLAS、LAPACK、AMD、COLAMD等)而且它的构建没有任何问题。

下面是CMake的输出:

代码语言:javascript
复制
-- Detected Ceres version: 2.0.0 from <path>/ceres-solver/include/ceres/version.h
-- Detected available Ceres threading models: [CXX11_THREADS, OPENMP, NO_THREADS]
-- Building with C++17
-- No preference for use of exported Eigen CMake configuration set, and no hints for include directory provided. Defaulting to preferring an installed/exported Eigen CMake configuration if available.
-- Found installed version of Eigen: <path>/eigen-3.3.5/share/eigen3/cmake
-- Found Eigen version 3.3.5: <path>/eigen-3.3.5/include/eigen3
-- Disabling use of Eigen as a sparse linear algebra library.
   This does not affect the covariance estimation algorithm 
   which can still use the EIGEN_SPARSE_QR algorithm.
-- Found LAPACK library: /usr/lib/liblapack.so;/usr/lib/libblas.so
-- Found AMD headers in: /usr/include
-- Found AMD library: /usr/lib/libamd.so
-- Found CAMD headers in: /usr/include
-- Found CAMD library: /usr/lib/libcamd.so
-- Found COLAMD headers in: /usr/include
-- Found COLAMD library: /usr/lib/libcolamd.so
-- Found CCOLAMD headers in: /usr/include
-- Found CCOLAMD library: /usr/lib/libccolamd.so
-- Found CHOLMOD headers in: /usr/include
-- Found CHOLMOD library: /usr/lib/libcholmod.so
-- Found SUITESPARSEQR headers in: /usr/include
-- Found SUITESPARSEQR library: /usr/lib/libspqr.so
-- Found Intel Thread Building Blocks (TBB) library (2019.0) assuming SuiteSparseQR was compiled with TBB.
-- Found SUITESPARSE_CONFIG headers in: /usr/include
-- Found SUITESPARSE_CONFIG library: /usr/lib/libsuitesparseconfig.so
-- Found LIBRT library: /usr/lib/librt.so
-- Adding librt: /usr/lib/librt.so to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found METIS library: /usr/lib/libmetis.so
-- Found SuiteSparse 5.4.0, building with SuiteSparse.
-- Building without CXSparse.
-- Building without Apple's Accelerate sparse support.
-- 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.
-- Found installed version of gflags: <path>
-- Detected gflags version: 2.2.2
-- Found Google Flags header in: <path>/include, in namespace: google
-- 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.
-- Found installed version of glog: <path>/glog
-- Detected glog version: 0.3.5
-- Found Google Log (glog). Assuming glog was built with gflags support as gflags was found. This will make gflags a public dependency of Ceres.
-- Using Ceres threading model: OPENMP
-- Building Ceres as a static library.
-- Enabling CERES_NO_CXSPARSE in Ceres config.h
-- Enabling CERES_NO_ACCELERATE_SPARSE in Ceres config.h
-- Enabling CERES_USE_OPENMP in Ceres config.h
-- Do not build any example.
-- Configuring done
-- Generating done

但是,如果我将Ceres-solver构建为外部项目,它不会找到BLAS (与我直接从源代码构建时自动找到的BLAS相同)。

通过ExternalProject_Add构建库与单独手动构建库在行为上有区别吗?我的“主”项目(调用ExternalProject_Add的项目)中定义的选项和变量是否会泄漏给外部项目(如果可以,我如何防止它?)

我对ExternalProject_Add的调用:

代码语言:javascript
复制
        ExternalProject_Add(ceres-solver
            PREFIX CeresSolver
            BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ceres-solver
            SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ceres-solver
            INSTALL_DIR ${DEFAULT_INSTALL_ROOT}/ceres-solver
            LOG_DIR ${DEFAULT_INSTALL_ROOT}/ceres-solver/log
            LOG_CONFIGURE ON
            CMAKE_ARGS
                -DCERES_THREADING_MODEL=OPENMP
                -DCMAKE_CXX_STANDARD=17
                -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                -DCMAKE_INSTALL_PREFIX=${DEFAULT_INSTALL_ROOT}/ceres-solver

                -DBUILD_BENCHMARKS=OFF
                -DBUILD_DOCUMENTATION=OFF
                -DBUILD_EXAMPLES=OFF
                -DBUILD_SHARED_LIBS=ON
                -DBUILD_TESTING=OFF

                -DCXSPARSE=OFF
                -DEIGENSPARSE=OFF

                -DEIGEN_INCLUDE_DIR=${EIGEN3_INCLUDE_DIR}
                -DEigen3_DIR=${Eigen3_DIR}
                -DSUITESPARSE=ON
                -DLAPACK=ON)

以及configure for ceres-solver的输出:

代码语言:javascript
复制
- Detected available Ceres threading models: [CXX11_THREADS, OPENMP, NO_THREADS]
-- Building with C++17
-- Found Eigen version 3.3.5: <path>
-- Disabling use of Eigen as a sparse linear algebra library.
   This does not affect the covariance estimation algorithm 
   which can still use the EIGEN_SPARSE_QR algorithm.
-- Did not find LAPACK library, disabling LAPACK support.
-- Failed to find SuiteSparse - Did not find BLAS library (required for SuiteSparse).
-- Failed to find SuiteSparse - Did not find LAPACK library (required for SuiteSparse).
-- Failed to find SuiteSparse - Did not find AMD header (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find AMD library (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find CAMD header (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find CAMD library (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find COLAMD header (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find COLAMD library (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find CCOLAMD header (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find CCOLAMD library (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find CHOLMOD header (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find CHOLMOD library (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find SUITESPARSEQR header (required SuiteSparse component).
-- Failed to find SuiteSparse - Did not find SUITESPARSEQR library (required SuiteSparse component).
-- Failed to find SuiteSparse - Failed to find either: SuiteSparse_config header & library (should be present in all SuiteSparse >= v4 installs), or UFconfig header (should be present in all SuiteSparse < v4 installs).
-- Did not find all SuiteSparse dependencies, disabling SuiteSparse support.
-- Building without CXSparse.
-- Building without Apple's Accelerate sparse support.
   ===============================================================
   Compiling without any sparse library: SuiteSparse, CXSparse 
   EigenSparse & Apple's Accelerate are all disabled or unavailable.  
   No sparse linear solvers (SPARSE_NORMAL_CHOLESKY & SPARSE_SCHUR)
   will be available when Ceres is used.
   ===============================================================
-- Found Google Flags header in: <path>, in namespace: google
-- Found Google Log (glog). Assuming glog was built with gflags support as gflags was found. This will make gflags a public dependency of Ceres.
-- Using Ceres threading model: OPENMP
-- Building Ceres as a shared library.
-- Do not build any example.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-04 18:09:39

我的build文件夹似乎已经损坏了。我刚刚删除了build文件夹和install文件夹。当我重新运行安装时,一切都运行得很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56293558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档