irods / irods_rule_engine_plugin_metadata_guard

BSD 3-Clause "New" or "Revised" License
0 stars 7 forks source link

Missing fmt dependency #8

Closed SwooshyCueb closed 3 years ago

SwooshyCueb commented 4 years ago

Build fails because fmt/core.h was not found:

In file included from /re_metadata_guard_source/src/main.cpp:4:
In file included from /usr/include/irods/irods_re_plugin.hpp:25:
In file included from /usr/include/irods/irods_logger.hpp:21:
In file included from /opt/irods-externals/spdlog1.5.0-1/include/spdlog/spdlog.h:12:
In file included from /opt/irods-externals/spdlog1.5.0-1/include/spdlog/common.h:38:
/opt/irods-externals/spdlog1.5.0-1/include/spdlog/fmt/fmt.h:25:10: fatal error: 'fmt/core.h' file not found
#include <fmt/core.h>
         ^~~~~~~~~~~~

If clang does manage to find fmt/core.h, build fails during linking, as libfmt is not linked:

ld.lld: error: undefined symbol: fmt::v7::detail::assert_fail(char const*, int, char const*)
>>> referenced by format.h:673 (/usr/include/fmt/format.h:673)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::basic_memory_buffer<char, 250ul, std::__1::allocator<char> >::operator=(fmt::v7::basic_memory_buffer<char, 250ul, std::__1::allocator<char> >&&))
>>> referenced by core.h:317 (/usr/include/fmt/core.h:317)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(std::__1::make_unsigned<long>::type fmt::v7::detail::to_unsigned<long>(long))
>>> referenced by format.h:909 (/usr/include/fmt/format.h:909)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::format_decimal_result<char*> fmt::v7::detail::format_decimal<char, unsigned int>(char*, unsigned int, int))
>>> referenced by format.h:909 (/usr/include/fmt/format.h:909)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::format_decimal_result<char*> fmt::v7::detail::format_decimal<char, unsigned long>(char*, unsigned long, int))

ld.lld: error: undefined symbol: fmt::v7::detail::basic_data<void>::digits
>>> referenced by format.h:0 (/usr/include/fmt/format.h:0)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::format_decimal_result<char*> fmt::v7::detail::format_decimal<char, unsigned int>(char*, unsigned int, int))
>>> referenced by format.h:0 (/usr/include/fmt/format.h:0)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::format_decimal_result<char*> fmt::v7::detail::format_decimal<char, unsigned int>(char*, unsigned int, int))
>>> referenced by format.h:0 (/usr/include/fmt/format.h:0)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::format_decimal_result<char*> fmt::v7::detail::format_decimal<char, unsigned long>(char*, unsigned long, int))
>>> referenced by format.h:0 (/usr/include/fmt/format.h:0)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::format_decimal_result<char*> fmt::v7::detail::format_decimal<char, unsigned long>(char*, unsigned long, int))

ld.lld: error: undefined symbol: fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_32
>>> referenced by format.h:847 (/usr/include/fmt/format.h:847)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::count_digits(unsigned int))

ld.lld: error: undefined symbol: fmt::v7::basic_format_context<std::__1::back_insert_iterator<fmt::v7::detail::buffer<char> >, char>::iterator fmt::v7::detail::vformat_to<char>(fmt::v7::detail::buffer<char>&, fmt::v7::basic_string_view<char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<std::__1::back_insert_iterator<fmt::v7::detail::buffer<fmt::v7::type_identity<char>::type> >, fmt::v7::type_identity<char>::type> >)
>>> referenced by format.h:3509 (/usr/include/fmt/format.h:3509)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::basic_format_context<std::__1::back_insert_iterator<fmt::v7::detail::buffer<char> >, char>::iterator fmt::v7::format_to<char [6], int&, 250ul, char>(fmt::v7::basic_memory_buffer<char, 250ul, std::__1::allocator<char> >&, char const (&) [6], int&))

ld.lld: error: undefined symbol: fmt::v7::detail::basic_data<void>::zero_or_powers_of_10_64
>>> referenced by format.h:787 (/usr/include/fmt/format.h:787)
>>>               CMakeFiles/irods_rule_engine_plugin-metadata_guard.dir/src/main.cpp.o:(fmt::v7::detail::count_digits(unsigned long))
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)

(Note: Output here is from the lld linker. This isn't used by default when building irods, but I often use it because I find the error messages easier to understand.)

The easy solution is to add ${IRODS_EXTERNALS_FULLPATH_FMT}/include and ${IRODS_EXTERNALS_FULLPATH_FMT}/lib/libfmt.so to the list of arguments provided to target_include_directories and target_link_libraries, respectively, in CMakeLists.txt.

HOWEVER, since the fmt dependency comes from irods proper, and not from the rule engine plugin itself, it needs to be passed down by the cmake targets file provided by irods-dev.

From the CMake documentation on INTERFACE_INCLUDE_DIRECTORIES:

Targets may populate this property to publish the include directories required to compile against the headers for the target. The target_include_directories() command populates this property with values given to the PUBLIC and INTERFACE keywords. Projects may also get and set the property directly.

When target dependencies are specified using target_include_directories(), CMake will read this property from all target dependencies to determine the build properties of the consumer.

Related issue: irods/irods#5250

trel commented 3 years ago

are we good here? if so, please checkbox and close.

SwooshyCueb commented 3 years ago

The temporary solution is in place. Initially, I was planning on keeping this open until irods-dev passed down the proper dependencies, but since that's covered in irods/irods#5250, I'll go ahead and close this.