symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.44k stars 147 forks source link

Difficulty building w/ CMake choosing incompatible fmt library versions #324

Closed arbor-arthur closed 1 year ago

arbor-arthur commented 1 year ago

Describe the bug On my M1 MacBookPro I have a newer incompatible version of library fmt at version 9.1.0, installed with brew. When building, CMake finds this version and the build fails.

I get errors that look like:

      In file included from /Users/acshi/symforce_not_building/symforce/opt/factor.cc:6:
      In file included from /Users/acshi/symforce_not_building/symforce/opt/./factor.h:17:
      In file included from /Users/acshi/symforce_not_building/symforce/opt/./values.h:277:
      In file included from /Users/acshi/symforce_not_building/symforce/opt/./values.tcc:6:
      In file included from /opt/homebrew/include/fmt/format.h:48:
      /opt/homebrew/include/fmt/core.h:1735:47: error: cannot pass object of non-trivial type 'const std::vector<sym::Key>' through variadic method; call will abort at runtime [-Wnon-pod-varargs]
        const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
                                                    ^
      /opt/homebrew/include/fmt/core.h:204:26: note: expanded from macro 'FMT_FORWARD'
      #define FMT_FORWARD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__)
                               ^
      /opt/homebrew/include/fmt/core.h:1777:10: note: in instantiation of function template specialization 'fmt::detail::make_value<fmt::basic_format_context<fmt::appender, char>, const std::vector<sym::Key> &>' requested here
        return make_value<Context>(val);

I solved this by simply removing the call to find_package in symforce/opt/CMakeLists.txt and always running the CMake code to download and install this library locally.

To Reproduce On an M1 MBP, brew install (the latest version of) fmt. Clone the symforce repository, cd into it, and run python3 -m pip install ..

Expected behavior Should build without modifications.

Environment (please complete the following information):

Additional context cmake version 3.26.3

chao-qu-skydio commented 1 year ago

Thanks for reporting, this is a known issue to us. This issue is also coupled with spdlog as it also uses fmt.

chao-qu-skydio commented 1 year ago

I think this should be fixed in the master (by restricting fmt version to 8), again a new release is coming soon.

aaron-skydio commented 1 year ago

Yeah this should be fixed by f9c21ade57bb920048867d3441efb257e0c7894c