Skip to content

Comments

Replace Boost filesystem with C++17 std::filesystem#6405

Open
kai-waang wants to merge 4 commits intoPointCloudLibrary:masterfrom
kai-waang:remove-boost-fs
Open

Replace Boost filesystem with C++17 std::filesystem#6405
kai-waang wants to merge 4 commits intoPointCloudLibrary:masterfrom
kai-waang:remove-boost-fs

Conversation

@kai-waang
Copy link
Contributor

#6403 has dropped support for C++14, so std::filesystem is now avaliable by default in PCL. As discussed in #5881, boost::filesystem was kept because of C++14 compatibility. So this PR:

  • removing Boost::filesystem from pcl_find_boost.cmake
  • removing the option PCL_PREFER_BOOST_FILESYSTEM.
  • removing linkage with Boost::filesystem
  • changing boost::filesystem usage in outofcore to pcl_fs and now pcl_fs is equal to std::filesystem

Some codes still have boost/filesystem or boost::filesystem usage.

  • pcl/outofcore/boost.h, pcl/visualization/boost.h: includes <boost/filesystem.hpp>. But these two header files are not used in PCL.
  • pcl/outofcore/impl/octree_base_node.hpp 2021:2172, but these codes are wrapped by #if 0, and may be removed by another PR.

@kai-waang kai-waang marked this pull request as draft February 4, 2026 12:05
@kai-waang kai-waang marked this pull request as ready for review February 4, 2026 16:22
@mvieth
Copy link
Member

mvieth commented Feb 14, 2026

First of all, thank you for your pull request. I think there are a few decisions we should discuss (@larshg I would also like to hear your opinion on these, when you have time)

  1. Shall we keep the option PCL_PREFER_BOOST_FILESYSTEM? It might still be useful to have the possibility to switch back, for example if std::filesystem does not work fully on some compiler or operating system? For reference, it was added in this PR: Add option to choose boost filesystem over std filesystem #6005
  2. boost::filesystem was previously used in some public API functions, now replaced by pcl_fs (=std::filesystem). This mainly concerns the outofcore module, perhaps also some functions in apps. The consequence of this hard switch is, if someone updates to a new PCL version and tries to use the functions the same way as before (with the classes from boost::filesystem), their code will not compile. The most careful way to handle this would be to duplicate all functions that have a boost::filesystem parameter (e.g. void loadFromFile (const boost::filesystem::path &path, OutofcoreOctreeBaseNode* super);), switch one to pcl_fs or std::filesystem (so e.g. void loadFromFile (const std::filesystem::path &path, OutofcoreOctreeBaseNode* super);), and mark the one that still uses boost::filesystem as deprecated. This way, everyone who uses the old version will get a warning, but the code that was previously working will still compile (at least until we remove the old version in one or two years). Another option would be that we keep the outofcore module unchanged and let it use boost::filesystem for now. As far as I know, outofcore is not used by many people, and unless we hear strong demands from users that outofcore should work without boost::filesystem, I think it would be okay to force users to install boost::filesystem if they want to use outofcore.

@larshg
Copy link
Contributor

larshg commented Feb 18, 2026

I agree with both points 👍

At least we should change the public api's in Out of core - perhaps if it is possible to avoid using any classes from boost/std filesystem, but rely on std::strings etc?

@kai-waang
Copy link
Contributor Author

As for point 1, I would still suggest removing PCL_PREFER_BOOST_FILESYSTEM, since the CI already tests all major platforms (Ubuntu 20.04+ with GCC 9+, Clang 11+, macOS 14+, Windows VS2019+), where std::filesystem is fully supported. This option was originally added in #6005 for C++14 compatibility, but since #6403 dropped C++14 support and now requires C++17, the fallback is no longer necessary.
If a user encounters platform-specific issues with std::filesystem, they are either using PCL on an unsupported platform — in which case such issues are expected — or they should report it as a bug.

As for point 2, providing deprecated overloads may not be the best option either.
The outofcore module contains a large number of APIs that currently use boost::filesystem, duplicating all of them just to introduce std::filesystem (or pcl_fs) alternatives would likely make the code significantly more verbose and harder to maintain.

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.

3 participants