Skip to content

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.

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