← All tasks
cppceres-solver/ceres-solver #451Not checked yet

Include ceres-solver as fetchcontent directory

envgap__ceres-solver__ceres-solver-451

Original GitHub issue ↗Opened 2019-01-14

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not checked yet.
  • No curated issue-specific recipe or verified environment fix is available.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

ceres-solver/ceres-solver #451 · read the original issue
Hi,



 I am trying to use ceres-solver (the master branch)with the development HEAD of Eigen, both are included as FetchContent projects:



```

include(FetchContent)

function(FetchContentHelper name vc url tag)

    set(options ADD_SUBDIR)

    set(mvargs CONFIG_SUBDIR)

    cmake_parse_arguments(PARSE_ARGV 4 FCH "${options}" "" "${mvargs}")



    FetchContent_Declare(

        ${name}

        ${vc}_REPOSITORY ${url}

        ${vc}_TAG        ${tag}

        GIT_PROGRESS     ON

    )

    FetchContent_GetProperties(${name})

    if(NOT ${name}_POPULATED)

        message("Setting up ${name} from ${url}")

        FetchContent_Populate(${name})

        if(FCH_ADD_SUBDIR)

            foreach(config ${FCH_CONFIG_SUBDIR})

                string(REPLACE "=" ";" configkeyval ${config})

                list(LENGTH configkeyval len)

                if (len GREATER_EQUAL 2)

                    list(GET configkeyval 0 configkey)

                    list(SUBLIST configkeyval 1 -1 configvals)

                    string(REPLACE ";" "=" configval "${configvals}")

                else()

                    message(FATAL_ERROR "Invalid config: ${configkeyval}")

                endif()

                message("Set ${configkey} = ${configval}")

                set(${configkey} ${configval} CACHE INTERNAL "" FORCE)

            endforeach()

            set(${name}_SOURCE_DIR ${${name}_SOURCE_DIR} PARENT_SCOPE)

            set(${name}_BINARY_DIR ${${name}_BINARY_DIR} PARENT_SCOPE)

            add_subdirectory(${${name}_SOURCE_DIR} ${${name}_BINARY_DIR} EXCLUDE_FROM_ALL)

        endif()

    endif()

endfunction(FetchContentHelper)

FetchContentHelper(spdlog GIT "https://github.com/gabime/spdlog.git" v1.x ADD_SUBDIR)

FetchContentHelper(fmt GIT "https://github.com/fmtlib/fmt.git" 5.2.1 ADD_SUBDIR)

FetchContentHelper(eigen HG "https://bitbucket.org/eigen/eigen" default

    ADD_SUBDIR CONFIG_SUBDIR

        BUILD_TESTING=OFF

        )

# !1

set(Eigen3_DIR ${eigen_BINARY_DIR})

find_package(Eigen3 REQUIRED NO_MODULE NO_DEFAULT_PATH)

# get_target_property(eigen_include_dir Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)  # !2

FetchContentHelper(ceres GIT "https://github.com/ceres-solver/ceres-solver.git" master

    ADD_SUBDIR CONFIG_SUBDIR

      EIGEN_INCLUDE_DIR=${eigen_SOURCE_DIR}  # !3

      EIGENSPARSE=ON

      SUITESPARSE=ON

      CXSPARSE=OFF

      GFLAGS=OFF

      MINIGLOG=ON

      CXX11=ON

      OPENMP=ON

      EXPORT_BUILD_DIR=ON

    )

set(Ceres_DIR ${ceres_BINARY_DIR})

find_package(Ceres REQUIRED NO_DEFAULT_PATH)  # !4

```



In general, this works, but there are places that do not work and/or confusing to me.



* !1: This is to import Eigen3::Eigen target.

* !2: This attempts to read the include dir property of Eigen3::Eigen, which I though I could use as EIGEN_INCLUDE_DIR in configuring ceres, but it turn out that the property from get_property is a generator expression, so it causes an error in the ceres cmake file.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

Issue-specific recipe and runtime smoke command require review against the complete issue and repository.

Legacy reproduction is generic install-only; match the actual issue failure before admission.