Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place all relevant headers in /include during installation #489

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adamant-pwn
Copy link
Contributor

Should partially help with #485.

"src/*/*.hpp"
"src/*/*/*.hpp"
)
get_property(INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that this collects everything specified in include_directories. I suppose on Mac it can as well collect include_directories(SYSTEM /usr/local/include), which we probably do not want? I'm not sure what's the best course of action to avoid this situation here.

@adamant-pwn
Copy link
Contributor Author

@hmusta I tried using Metagraph as an external project, and besides problems with includes (that are at least resolved by this commit), I also get a bunch of linking errors:

[100%] Linking CXX executable MyExecutable
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::sink_it_(spdlog::details::log_msg const&)':
main.cpp:(.text._ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE[_ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE]+0x253): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::flush_()':
main.cpp:(.text._ZN6spdlog6logger6flush_Ev[_ZN6spdlog6logger6flush_Ev]+0x24a): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::make_unsigned<long>::type fmt::v10::detail::to_unsigned<long>(long)':
main.cpp:(.text._ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_]+0x21): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned int>(char*, unsigned int, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x3f): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned long>(char*, unsigned long, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x42): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > > fmt::v10::vformat_to<std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, 0>(std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)':
main.cpp:(.text._ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE[_ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE]+0x3e): undefined reference to `void fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)'
collect2: error: ld returned 1 exit status

These are resolved by adding

find_package(spdlog REQUIRED)
target_link_libraries(MyExecutable PRIVATE spdlog::spdlog)

But I assume it uses system-wide spdlog, rather than the one shipped with Metagraph. What would be the proper way to fix this, so that Metagraph installs all of its dependencies when used via ExternalProject_Add?

@hmusta
Copy link
Collaborator

hmusta commented Jun 21, 2024

@hmusta I tried using Metagraph as an external project, and besides problems with includes (that are at least resolved by this commit), I also get a bunch of linking errors:

[100%] Linking CXX executable MyExecutable
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::sink_it_(spdlog::details::log_msg const&)':
main.cpp:(.text._ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE[_ZN6spdlog6logger8sink_it_ERKNS_7details7log_msgE]+0x253): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `spdlog::logger::flush_()':
main.cpp:(.text._ZN6spdlog6logger6flush_Ev[_ZN6spdlog6logger6flush_Ev]+0x24a): undefined reference to `fmt::v10::vformat[abi:cxx11](fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::make_unsigned<long>::type fmt::v10::detail::to_unsigned<long>(long)':
main.cpp:(.text._ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_]+0x21): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned int>(char*, unsigned int, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcjEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x3f): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `fmt::v10::detail::format_decimal_result<char*> fmt::v10::detail::format_decimal<char, unsigned long>(char*, unsigned long, int)':
main.cpp:(.text._ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i[_ZN3fmt3v106detail14format_decimalIcmEENS1_21format_decimal_resultIPT_EES5_T0_i]+0x42): undefined reference to `fmt::v10::detail::assert_fail(char const*, int, char const*)'
/usr/bin/ld: CMakeFiles/MyExecutable.dir/src/main.cpp.o: in function `std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > > fmt::v10::vformat_to<std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, 0>(std::back_insert_iterator<fmt::v10::basic_memory_buffer<char, 250ul, std::allocator<char> > >, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::basic_format_context<fmt::v10::appender, char> >)':
main.cpp:(.text._ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE[_ZN3fmt3v1010vformat_toISt20back_insert_iteratorINS0_19basic_memory_bufferIcLm250ESaIcEEEELi0EEET_S7_NS0_17basic_string_viewIcEENS0_17basic_format_argsINS0_20basic_format_contextINS0_8appenderEcEEEE]+0x3e): undefined reference to `void fmt::v10::detail::vformat_to<char>(fmt::v10::detail::buffer<char>&, fmt::v10::basic_string_view<char>, fmt::v10::detail::vformat_args<char>::type, fmt::v10::detail::locale_ref)'
collect2: error: ld returned 1 exit status

These are resolved by adding

find_package(spdlog REQUIRED)
target_link_libraries(MyExecutable PRIVATE spdlog::spdlog)

But I assume it uses system-wide spdlog, rather than the one shipped with Metagraph. What would be the proper way to fix this, so that Metagraph installs all of its dependencies when used via ExternalProject_Add?

AFAIK you can set the path in find_package:
https://stackoverflow.com/questions/49816206/cmake-find-package-specify-path

@adamant-pwn
Copy link
Contributor Author

This is true, but currently Metagraph doesn't even install it in the install dir:

$ ls install/lib/
cmake  libjsoncpp.a  libmetagraph-core.a  libz.a  pkgconfig

Do we want to also put libspdlog.a there and tell third-party users to manually link with it? I'd prefer this to be handled automatically, but I'm not sure what's the proper way to do this...

@hmusta
Copy link
Collaborator

hmusta commented Jun 21, 2024

This is true, but currently Metagraph doesn't even install it in the install dir:

$ ls install/lib/
cmake  libjsoncpp.a  libmetagraph-core.a  libz.a  pkgconfig

Do we want to also put libspdlog.a there and tell third-party users to manually link with it? I'd prefer this to be handled automatically, but I'm not sure what's the proper way to do this...

I'd prefer to have it be linked statically in libmetagraph-core.a, though the downside of this is that if another library happens to use it, they'd have to use our version. Though we could have a cmake variable called SPDLOG_LINKED or something to control this.

@adamant-pwn
Copy link
Contributor Author

Isn't it already linked statically the way it is written now? I'm not sure what needs to be updated to ensure it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants