jll63 / yomm2

Fast, orthogonal, open multi-methods. Solve the Expression Problem in C++17.
Boost Software License 1.0
343 stars 18 forks source link

Update CMakeLists #24

Closed FabienPean closed 3 years ago

FabienPean commented 3 years ago

Add C++17 as a required feature of the library in a generic way. This should probably be sufficient to allow the library to be packaged for OSX in vcpkg.

jll63 commented 3 years ago

Thanks. I asked colleagues to try it on a Mac. In the meantime...With g++ 7 and g++ 9, I get a warning:

In file included from /tmp/yomm2/examples/dl_shared.cpp:9:0:
/tmp/yomm2/include/yorel/yomm2.hpp:264:45: warning: inline variables are only available with -std=c++1z or -std=gnu++1z
 inline typename next_ptr_t<Signature>::type next;

And with clang++ 9 and 11, lots of:

/tmp/yomm2/include/yorel/yomm2.hpp:495:64: warning: static_assert with no message is a C++17
      extension [-Wc++17-extensions]
        static_assert(shared_ptr_traits<DERIVED>::is_shared_ptr);

Which compiler did you test with?

FabienPean commented 3 years ago

Hi, I just reworked the CMakeLists upfront and was going to rely on the CI for checking validity.

The warnings seem all related to the example dl_shared. This happens because dl_shared is not "linked" to target yomm2 but instead it just extracts the include directory from the target yomm2. Solutions are either

  1. use target_link_libraries(dl_shared YOMM2::yomm2) but I assume it is using only the include directory for some reason.
  2. use target_compile_features(dl_shared PUBLIC cxx_std_17) to explicitly enforce correct standard use (minimal effort)
  3. create a new yomm2 target containing only the headers so that dl_shared problem can be solved with target_link_libraries(dl_shared YOMM2::yomm2_headers). This requires more work, but might make more sense if it is a common scenario.

For OSX no need really to go over it, the CI of microsoft/vcpkg would let me know if there is still an issue. The problem seemed that that the compiler id has changed and is now AppleClang instead of just Clang, so the C++17 flag was not set.

jll63 commented 3 years ago

@FabienPean Can you tell me a bit more about what you use (or plan to use) YOMM2 for? Is that work available as open source? I would like to make a list of projects in which the library is used. But if you are not allowed to talk about it it's all right too.

FabienPean commented 3 years ago

Nothing really targeted I'm afraid. I heard about the library from your talk at cppcon some years ago and wanted to refresh my memory because I think it is a really interesting solution. Since I like using vcpkg quite much for using/testing libraries and saw that yomm2 had a CMakeLists, I decided to bring it up there for easier consumption and access. It should be soon merged: microsoft/vcpkg#17886 If I were to use it into some relevant piece of work, I will announce it here then :)

ras0219-msft commented 3 years ago

It has been merged into vcpkg :)

jll63 commented 3 years ago

It has been merged into vcpkg :)

Cool :)