AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.62k stars 647 forks source link

[BUG] include/openvdb/TypeList.h uses std::tuple_size_v that isn't defined in C++ standards #1814

Closed yurivict closed 4 months ago

yurivict commented 4 months ago

Environment

Operating System: FreeBSD 14.0 Version / Commit SHA: 11.0.0 Other: clang-18.1.5

Describe the bug

The py39-openimageio using OpenVDB fails to build:

In file included from /wrkdirs/usr/ports/graphics/py-openimageio/work-py39/oiio-2.4.13.0/src/openvdb.imageio/openvdbinput.cpp:14:
In file included from /usr/local/include/openvdb/openvdb.h:8:
In file included from /usr/local/include/openvdb/Types.h:9:
/usr/local/include/openvdb/TypeList.h:858:41: error: no template named 'tuple_size_v' in namespace 'std'; did you mean 'tuple_size'?
    constexpr auto size() { return std::tuple_size_v<TupleT>; }
                                   ~~~~~^
/usr/include/c++/v1/__tuple_dir/tuple_size.h:25:50: note: 'tuple_size' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
                                                 ^

log

Idclip commented 4 months ago

tuple_size_v is part of the C++17 standard. The link to your build log doesn't work for me, please make sure you're building OpenVDB with C++17 or file this issue with whoever maintains py39-openimageio

arrowd commented 4 months ago

Yes, that was our (downstream) mistake, but the project should also require a specific C++ standard in CMake to prevent such mistakes.

yurivict commented 4 months ago

@Idclip

I agree with @arrowd . You should check that the C++ standard level requested is compatible with OpenVDB. The __cplusplus variable contains the currently used C++ level.

arrowd commented 4 months ago

I'm sure CMake has a built-in function to perform this check.

yurivict commented 4 months ago

Ideally both cmake and C++ checks should be present, because some people just don't use cmake and link directly.

Idclip commented 4 months ago

This check is performed here when building OpenVDB:

https://github.com/AcademySoftwareFoundation/openvdb/blob/e1b176f437eeb714ff29858b50129982c55fbcec/cmake/config/OpenVDBCXX.cmake#L26

When building against OpenVDB, you're correct in that there is no define requirement. We could add one in the future to make things clearer