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

Compile PCL as C++17 by default, switching back to C++14 currently still possible #6201

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/azure-pipelines/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ stages:
CC: gcc
CXX: g++
BUILD_GPU: ON
CMAKE_ARGS: '-DPCL_WARNINGS_ARE_ERRORS=ON'
CMAKE_ARGS: '-DPCL_WARNINGS_ARE_ERRORS=ON -DCMAKE_CXX_STANDARD=14 -DCMAKE_CUDA_STANDARD=14'
24.04 GCC: # latest Ubuntu
CONTAINER: env2404
CC: gcc
Expand Down
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR)

# Set target C++ standard and required compiler features
set(CMAKE_CXX_STANDARD 14 CACHE STRING "The target C++ standard. PCL requires C++14 or higher.")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The target C++ standard. PCL requires C++14 or higher.")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(PCL_CXX_COMPILE_FEATURES cxx_std_14)
if("${CMAKE_CXX_STANDARD}" GREATER_EQUAL 17)
set(PCL_CXX_COMPILE_FEATURES cxx_std_17)
set(PCL__cplusplus 201703L)
set(PCL_REQUIRES_MSC_VER 1912)
elseif("${CMAKE_CXX_STANDARD}" EQUAL 14)
set(PCL_CXX_COMPILE_FEATURES cxx_std_14)
set(PCL__cplusplus 201402L)
set(PCL_REQUIRES_MSC_VER 1900)
else()
message(FATAL_ERROR "Unknown or unsupported C++ standard specified")
endif()

set(CMAKE_CUDA_STANDARD 14 CACHE STRING "The target CUDA/C++ standard. PCL requires CUDA/C++ 14 or higher.")
set(CMAKE_CUDA_STANDARD 17 CACHE STRING "The target CUDA/C++ standard. PCL requires CUDA/C++ 14 or higher.")
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "possible configurations" FORCE)
Expand Down
6 changes: 3 additions & 3 deletions geometry/include/pcl/geometry/mesh_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1804,14 +1804,14 @@ class MeshBase {
typename IndexContainerT::value_type());
Index ind_old(0), ind_new(0);

typename ElementContainerT::const_iterator it_e_old = elements.begin();
auto it_e_old = elements.cbegin();
auto it_e_new = elements.begin();

typename DataContainerT::const_iterator it_d_old = data_cloud.begin();
auto it_d_old = data_cloud.cbegin();
auto it_d_new = data_cloud.begin();

auto it_ind_new = new_indices.begin();
typename IndexContainerT::const_iterator it_ind_new_end = new_indices.end();
auto it_ind_new_end = new_indices.cend();

while (it_ind_new != it_ind_new_end) {
if (!this->isDeleted(ind_old)) {
Expand Down
12 changes: 6 additions & 6 deletions io/src/openni2/openni2_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ pcl::io::openni2::OpenNI2Device::isIRVideoModeSupported (const OpenNI2VideoMode&

bool supported = false;

std::vector<OpenNI2VideoMode>::const_iterator it = ir_video_modes_.begin ();
std::vector<OpenNI2VideoMode>::const_iterator it_end = ir_video_modes_.end ();
auto it = ir_video_modes_.cbegin ();
auto it_end = ir_video_modes_.cend ();

while (it != it_end && !supported)
{
Expand All @@ -234,8 +234,8 @@ pcl::io::openni2::OpenNI2Device::isColorVideoModeSupported (const OpenNI2VideoMo

bool supported = false;

std::vector<OpenNI2VideoMode>::const_iterator it = color_video_modes_.begin ();
std::vector<OpenNI2VideoMode>::const_iterator it_end = color_video_modes_.end ();
auto it = color_video_modes_.cbegin ();
auto it_end = color_video_modes_.cend ();

while (it != it_end && !supported)
{
Expand All @@ -253,8 +253,8 @@ pcl::io::openni2::OpenNI2Device::isDepthVideoModeSupported (const OpenNI2VideoMo

bool supported = false;

std::vector<OpenNI2VideoMode>::const_iterator it = depth_video_modes_.begin ();
std::vector<OpenNI2VideoMode>::const_iterator it_end = depth_video_modes_.end ();
auto it = depth_video_modes_.cbegin ();
auto it_end = depth_video_modes_.cend ();

while (it != it_end && !supported)
{
Expand Down
4 changes: 2 additions & 2 deletions io/src/openni2/openni2_timer_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namespace pcl
{
double sum = 0;

std::deque<double>::const_iterator it = buffer_.begin ();
std::deque<double>::const_iterator it_end = buffer_.end ();
auto it = buffer_.cbegin ();
auto it_end = buffer_.cend ();

while (it != it_end)
{
Expand Down
2 changes: 1 addition & 1 deletion io/src/openni_camera/openni_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ openni_wrapper::OpenNIDriver::getDeviceInfos () noexcept
{
libusb_device* device = devices[devIdx];
std::uint8_t busId = libusb_get_bus_number (device);
std::map<unsigned char, std::map<unsigned char, unsigned> >::const_iterator busIt = bus_map_.find (busId);
auto busIt = bus_map_.find (busId);
if (busIt == bus_map_.end ())
continue;

Expand Down
14 changes: 6 additions & 8 deletions octree/include/pcl/octree/impl/octree2buf_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ Octree2BufBase<LeafContainerT, BranchContainerT>::deserializeTree(
leaf_count_ = 0;

// iterator for binary tree structure vector
std::vector<char>::const_iterator binary_tree_in_it = binary_tree_in_arg.begin();
std::vector<char>::const_iterator binary_tree_in_it_end = binary_tree_in_arg.end();
auto binary_tree_in_it = binary_tree_in_arg.cbegin();
auto binary_tree_in_it_end = binary_tree_in_arg.cend();

deserializeTreeRecursive(root_node_,
depth_mask_,
Expand All @@ -307,19 +307,17 @@ Octree2BufBase<LeafContainerT, BranchContainerT>::deserializeTree(
OctreeKey new_key;

// set data iterator to first element
typename std::vector<LeafContainerT*>::const_iterator leaf_container_vector_it =
leaf_container_vector_arg.begin();
auto leaf_container_vector_it = leaf_container_vector_arg.cbegin();

// set data iterator to last element
typename std::vector<LeafContainerT*>::const_iterator leaf_container_vector_it_end =
leaf_container_vector_arg.end();
auto leaf_container_vector_it_end = leaf_container_vector_arg.cend();

// we will rebuild an octree -> reset leafCount
leaf_count_ = 0;

// iterator for binary tree structure vector
std::vector<char>::const_iterator binary_tree_in_it = binary_tree_in_arg.begin();
std::vector<char>::const_iterator binary_tree_in_it_end = binary_tree_in_arg.end();
auto binary_tree_in_it = binary_tree_in_arg.cbegin();
auto binary_tree_in_it_end = binary_tree_in_arg.cend();

deserializeTreeRecursive(root_node_,
depth_mask_,
Expand Down
14 changes: 6 additions & 8 deletions octree/include/pcl/octree/impl/octree_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ OctreeBase<LeafContainerT, BranchContainerT>::deserializeTree(
deleteTree();

// iterator for binary tree structure vector
std::vector<char>::const_iterator binary_tree_out_it = binary_tree_out_arg.begin();
std::vector<char>::const_iterator binary_tree_out_it_end = binary_tree_out_arg.end();
auto binary_tree_out_it = binary_tree_out_arg.cbegin();
auto binary_tree_out_it_end = binary_tree_out_arg.cend();

deserializeTreeRecursive(root_node_,
depth_mask_,
Expand All @@ -266,19 +266,17 @@ OctreeBase<LeafContainerT, BranchContainerT>::deserializeTree(
OctreeKey new_key;

// set data iterator to first element
typename std::vector<LeafContainerT*>::const_iterator leaf_vector_it =
leaf_container_vector_arg.begin();
auto leaf_vector_it = leaf_container_vector_arg.cbegin();

// set data iterator to last element
typename std::vector<LeafContainerT*>::const_iterator leaf_vector_it_end =
leaf_container_vector_arg.end();
auto leaf_vector_it_end = leaf_container_vector_arg.cend();

// free existing tree before tree rebuild
deleteTree();

// iterator for binary tree structure vector
std::vector<char>::const_iterator binary_tree_input_it = binary_tree_in_arg.begin();
std::vector<char>::const_iterator binary_tree_input_it_end = binary_tree_in_arg.end();
auto binary_tree_input_it = binary_tree_in_arg.cbegin();
auto binary_tree_input_it_end = binary_tree_in_arg.cend();

deserializeTreeRecursive(root_node_,
depth_mask_,
Expand Down
4 changes: 2 additions & 2 deletions pcl_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Ensure the compiler is meeting the minimum C++ standard
// MSVC is not checked via __cplusplus due to
// https://developercommunity.visualstudio.com/content/problem/120156/-cplusplus-macro-still-defined-as-pre-c11-value.html
#if defined(__cplusplus) && ((!defined(_MSC_VER) && __cplusplus < 201402L) || (defined(_MSC_VER) && _MSC_VER < 1900))
#error PCL requires C++14 or above
#if defined(__cplusplus) && ((!defined(_MSC_VER) && __cplusplus < ${PCL__cplusplus}) || (defined(_MSC_VER) && _MSC_VER < ${PCL_REQUIRES_MSC_VER}) || (defined(_MSVC_LANG) && _MSVC_LANG < ${PCL__cplusplus}))
#error C++ standard too low (PCL requires ${PCL__cplusplus} or above)
#endif

#define BUILD_@CMAKE_BUILD_TYPE@
Expand Down
2 changes: 1 addition & 1 deletion recognition/src/ransac_based/obj_rec_ransac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ pcl::recognition::ObjRecRANSAC::buildGraphOfCloseHypotheses (HypothesisOctree& h
i = 0;

// Now create the graph connectivity such that each two neighboring rotation spaces are neighbors in the graph
for ( std::vector<HypothesisOctree::Node*>::const_iterator hypo = hypo_leaves.begin () ; hypo != hypo_leaves.end () ; ++hypo, ++i )
for ( auto hypo = hypo_leaves.cbegin () ; hypo != hypo_leaves.cend () ; ++hypo, ++i )
{
// Compute the fitness of the graph node
graph.getNodes ()[i]->setFitness (static_cast<int> ((*hypo)->getData ().explained_pixels_.size ()));
Expand Down
2 changes: 1 addition & 1 deletion registration/include/pcl/registration/impl/lum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ LUM<PointT>::compute()
// Update the poses
float sum = 0.0;
for (int vi = 1; vi != n; ++vi) {
Eigen::Vector6f difference_pose = static_cast<Eigen::Vector6f>(
auto difference_pose = static_cast<Eigen::Vector6f>(
-incidenceCorrection(getPose(vi)).inverse() * X.segment(6 * (vi - 1), 6));
sum += difference_pose.norm();
setPose(vi, getPose(vi) + difference_pose);
Expand Down
4 changes: 2 additions & 2 deletions segmentation/src/grabcut_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ pcl::segmentation::grabcut::BoykovKolmogorov::adoptOrphans (std::deque<int>& orp
if (cut_[jt->first] != tree_label) continue;

// check edge capacity
const capacitated_edge::iterator kt = nodes_[jt->first].find (u);
const auto kt = nodes_[jt->first].find (u);
if (((tree_label == TARGET) && (jt->second <= 0.0)) ||
((tree_label == SOURCE) && (kt->second <= 0.0)))
continue;
Expand All @@ -483,7 +483,7 @@ pcl::segmentation::grabcut::BoykovKolmogorov::adoptOrphans (std::deque<int>& orp
// free the orphan subtree and remove it from the active set
if (b_free_orphan)
{
for (capacitated_edge::const_iterator jt = nodes_[u].begin (); jt != nodes_[u].end (); ++jt)
for (auto jt = nodes_[u].cbegin (); jt != nodes_[u].cend (); ++jt)
{
if ((cut_[jt->first] == tree_label) && (parents_[jt->first].first == u))
{
Expand Down
6 changes: 3 additions & 3 deletions surface/include/pcl/surface/impl/marching_cubes_rbf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ pcl::MarchingCubesRBF<PointNT>::voxelizeData ()
const Eigen::Vector3d point = point_f.cast<double> ();

double f = 0.0;
std::vector<double>::const_iterator w_it (weights.begin());
for (std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> >::const_iterator c_it = centers.begin ();
c_it != centers.end (); ++c_it, ++w_it)
auto w_it (weights.cbegin());
for (auto c_it = centers.cbegin ();
c_it != centers.cend (); ++c_it, ++w_it)
f += *w_it * kernel (*c_it, point);

grid_[x * res_y_*res_z_ + y * res_z_ + z] = static_cast<float>(f);
Expand Down
8 changes: 4 additions & 4 deletions test/common/test_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ TEST (PointCloud, iterators)
cloud.begin ()->getVector3fMap ());
EXPECT_EQ_VECTORS ((--cloud.end ())->getVector3fMap (),
(--cloud.end ())->getVector3fMap ());
PointCloud<PointXYZ>::const_iterator pit = cloud.begin ();
PointCloud<PointXYZ>::VectorType::const_iterator pit2 = cloud.begin ();
auto pit = cloud.begin ();
auto pit2 = cloud.begin ();
for (; pit < cloud.end (); ++pit2, ++pit)
EXPECT_EQ_VECTORS (pit->getVector3fMap (), pit2->getVector3fMap ());
}
Expand All @@ -125,8 +125,8 @@ TEST (PointCloud, insert_range)
EXPECT_EQ (cloud.width, cloud.size ());
EXPECT_EQ (cloud.height, 1);
EXPECT_EQ (cloud.width, old_size + cloud2.size ());
PointCloud<PointXYZ>::const_iterator pit = cloud.begin ();
PointCloud<PointXYZ>::const_iterator pit2 = cloud2.begin ();
auto pit = cloud.begin ();
auto pit2 = cloud2.begin ();
for (; pit2 < cloud2.end (); ++pit2, ++pit)
EXPECT_EQ_VECTORS (pit->getVector3fMap (), pit2->getVector3fMap ());
}
Expand Down
2 changes: 1 addition & 1 deletion test/fuzz/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $CXX $CXXFLAGS -DPCLAPI_EXPORTS \
-I/src/pcl/build/include -I/src/pcl/common/include \
-I/src/pcl/dssdk/include \
-I/src/pcl/io/include -isystem /usr/include/eigen3 \
-O2 -g -DNDEBUG -fPIC -std=c++14 \
-O2 -g -DNDEBUG -fPIC -std=c++17 \
-o ply_reader_fuzzer.o -c ply_reader_fuzzer.cpp

$CXX $CXXFLAGS $LIB_FUZZING_ENGINE ply_reader_fuzzer.o \
Expand Down
2 changes: 1 addition & 1 deletion visualization/src/pcl_visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ void
pcl::visualization::PCLVisualizer::resetCameraViewpoint (const std::string &id)
{
vtkSmartPointer<vtkMatrix4x4> camera_pose;
const CloudActorMap::iterator it = cloud_actor_map_->find(id);
const auto it = cloud_actor_map_->find(id);
if (it != cloud_actor_map_->end ())
camera_pose = it->second.viewpoint_transformation_;
else
Expand Down
Loading