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

Allow hidden visibility default on gcc/clang #5779

Merged
merged 4 commits into from
Sep 30, 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
8 changes: 8 additions & 0 deletions cmake/pcl_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,11 @@ option(PCL_DISABLE_GPU_TESTS "Disable running GPU tests. If disabled, tests will
# Set whether visualizations tests should be run
# (Used to prevent visualizations tests from executing in CI where visualization is unavailable)
option(PCL_DISABLE_VISUALIZATION_TESTS "Disable running visualizations tests. If disabled, tests will still be built." OFF)

# This leads to smaller libraries, possibly faster code, and fixes some bugs. See https://gcc.gnu.org/wiki/Visibility
option(PCL_SYMBOL_VISIBILITY_HIDDEN "Hide all binary symbols by default, export only those explicitly marked (gcc and clang only). Experimental!" OFF)
mark_as_advanced(PCL_SYMBOL_VISIBILITY_HIDDEN)
if(PCL_SYMBOL_VISIBILITY_HIDDEN)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
endif()
23 changes: 12 additions & 11 deletions common/include/pcl/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <stdexcept>
#include <sstream>
#include <boost/current_function.hpp>
#include <pcl/pcl_exports.h> // for PCL_EXPORTS

/** PCL_THROW_EXCEPTION a helper macro to be used for throwing exceptions.
* This is an example on how to use:
Expand All @@ -62,7 +63,7 @@ namespace pcl
* \brief A base class for all pcl exceptions which inherits from std::runtime_error
* \author Eitan Marder-Eppstein, Suat Gedikli, Nizar Sallem
*/
class PCLException : public std::runtime_error
class PCL_EXPORTS PCLException : public std::runtime_error
{
public:

Expand Down Expand Up @@ -134,7 +135,7 @@ namespace pcl
/** \class InvalidConversionException
* \brief An exception that is thrown when a PCLPointCloud2 message cannot be converted into a PCL type
*/
class InvalidConversionException : public PCLException
class PCL_EXPORTS InvalidConversionException : public PCLException
{
public:

Expand All @@ -148,7 +149,7 @@ namespace pcl
/** \class IsNotDenseException
* \brief An exception that is thrown when a PointCloud is not dense but is attempted to be used as dense
*/
class IsNotDenseException : public PCLException
class PCL_EXPORTS IsNotDenseException : public PCLException
{
public:

Expand All @@ -163,7 +164,7 @@ namespace pcl
* \brief An exception that is thrown when a sample consensus model doesn't
* have the correct number of samples defined in model_types.h
*/
class InvalidSACModelTypeException : public PCLException
class PCL_EXPORTS InvalidSACModelTypeException : public PCLException
{
public:

Expand All @@ -177,7 +178,7 @@ namespace pcl
/** \class IOException
* \brief An exception that is thrown during an IO error (typical read/write errors)
*/
class IOException : public PCLException
class PCL_EXPORTS IOException : public PCLException
{
public:

Expand All @@ -192,7 +193,7 @@ namespace pcl
* \brief An exception thrown when init can not be performed should be used in all the
* PCLBase class inheritants.
*/
class InitFailedException : public PCLException
class PCL_EXPORTS InitFailedException : public PCLException
{
public:
InitFailedException (const std::string& error_description = "",
Expand All @@ -206,7 +207,7 @@ namespace pcl
* \brief An exception that is thrown when an organized point cloud is needed
* but not provided.
*/
class UnorganizedPointCloudException : public PCLException
class PCL_EXPORTS UnorganizedPointCloudException : public PCLException
{
public:

Expand All @@ -220,7 +221,7 @@ namespace pcl
/** \class KernelWidthTooSmallException
* \brief An exception that is thrown when the kernel size is too small
*/
class KernelWidthTooSmallException : public PCLException
class PCL_EXPORTS KernelWidthTooSmallException : public PCLException
{
public:

Expand All @@ -231,7 +232,7 @@ namespace pcl
: pcl::PCLException (error_description, file_name, function_name, line_number) { }
} ;

class UnhandledPointTypeException : public PCLException
class PCL_EXPORTS UnhandledPointTypeException : public PCLException
{
public:
UnhandledPointTypeException (const std::string& error_description,
Expand All @@ -241,7 +242,7 @@ namespace pcl
: pcl::PCLException (error_description, file_name, function_name, line_number) { }
};

class ComputeFailedException : public PCLException
class PCL_EXPORTS ComputeFailedException : public PCLException
{
public:
ComputeFailedException (const std::string& error_description,
Expand All @@ -254,7 +255,7 @@ namespace pcl
/** \class BadArgumentException
* \brief An exception that is thrown when the arguments number or type is wrong/unhandled.
*/
class BadArgumentException : public PCLException
class PCL_EXPORTS BadArgumentException : public PCLException
{
public:
BadArgumentException (const std::string& error_description,
Expand Down
8 changes: 7 additions & 1 deletion common/include/pcl/pcl_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#pragma once

#include <pcl/pcl_config.h> // for PCL_SYMBOL_VISIBILITY_HIDDEN

// This header is created to include to NVCC compiled sources.
// Header 'pcl_macros' is not suitable since it includes <Eigen/Core>,
// which can't be eaten by nvcc (it's too weak)
Expand All @@ -45,5 +47,9 @@
#define PCL_EXPORTS
#endif
#else
#define PCL_EXPORTS
#ifdef PCL_SYMBOL_VISIBILITY_HIDDEN
#define PCL_EXPORTS __attribute__ ((visibility ("default")))
#else
#define PCL_EXPORTS
#endif
#endif
6 changes: 5 additions & 1 deletion common/include/pcl/pcl_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ pcl_round (float number)
#define PCL_EXPORTS
#endif
#else
#define PCL_EXPORTS
#ifdef PCL_SYMBOL_VISIBILITY_HIDDEN
#define PCL_EXPORTS __attribute__ ((visibility ("default")))
#else
#define PCL_EXPORTS
#endif
#endif

#if defined WIN32 || defined _WIN32
Expand Down
10 changes: 5 additions & 5 deletions common/include/pcl/range_image/range_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace pcl
/** Constructor */
PCL_EXPORTS RangeImage ();
/** Destructor */
PCL_EXPORTS virtual ~RangeImage () = default;
PCL_EXPORTS virtual ~RangeImage ();

// =====STATIC VARIABLES=====
/** The maximum number of openmp threads that can be used in this class */
Expand Down Expand Up @@ -782,10 +782,10 @@ namespace pcl


// =====STATIC PROTECTED=====
static const int lookup_table_size;
static std::vector<float> asin_lookup_table;
static std::vector<float> atan_lookup_table;
static std::vector<float> cos_lookup_table;
PCL_EXPORTS static const int lookup_table_size;
PCL_EXPORTS static std::vector<float> asin_lookup_table;
PCL_EXPORTS static std::vector<float> atan_lookup_table;
PCL_EXPORTS static std::vector<float> cos_lookup_table;
/** Create lookup tables for trigonometric functions */
static void
createLookupTables ();
Expand Down
2 changes: 2 additions & 0 deletions common/src/range_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ RangeImage::RangeImage () :
unobserved_point.range = -std::numeric_limits<float>::infinity ();
}

RangeImage::~RangeImage () = default;

/////////////////////////////////////////////////////////////////////////
void
RangeImage::reset ()
Expand Down
12 changes: 0 additions & 12 deletions filters/src/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,5 @@ Convolution<pcl::RGB, pcl::RGB>::convolveOneColDense(int i, int j)
result.b = static_cast<std::uint8_t>(b);
return (result);
}

#ifndef PCL_NO_PRECOMPILE
#include <pcl/impl/instantiate.hpp>
#include <pcl/point_types.h>

PCL_INSTANTIATE_PRODUCT(
Convolution, ((pcl::RGB))((pcl::RGB)))

PCL_INSTANTIATE_PRODUCT(
Convolution, ((pcl::PointXYZRGB))((pcl::PointXYZRGB)))
#endif // PCL_NO_PRECOMPILE

} // namespace filters
} // namespace pcl
2 changes: 2 additions & 0 deletions gpu/containers/src/initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
#include <array> // replace c-style array with std::array
#include <cstdio>

#if !defined(HAVE_CUDA)
#define HAVE_CUDA
#endif
//#include <pcl_config.h>

#if !defined(HAVE_CUDA)
Expand Down
3 changes: 2 additions & 1 deletion pcl_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// 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(_MSC_VER) && __cplusplus < 201402L) || (defined(_MSC_VER) && _MSC_VER < 1900)
#if defined(__cplusplus) && ((!defined(_MSC_VER) && __cplusplus < 201402L) || (defined(_MSC_VER) && _MSC_VER < 1900))
#error PCL requires C++14 or above
#endif

#define BUILD_@CMAKE_BUILD_TYPE@
#cmakedefine PCL_SYMBOL_VISIBILITY_HIDDEN
/* PCL version information */
#define PCL_MAJOR_VERSION ${PCL_VERSION_MAJOR}
#define PCL_MINOR_VERSION ${PCL_VERSION_MINOR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace registration {
* \ingroup registration
*/
template <typename PointSource, typename PointTarget, typename Scalar = float>
class PCL_EXPORTS TransformationEstimationSVD
class TransformationEstimationSVD
: public TransformationEstimation<PointSource, PointTarget, Scalar> {
public:
using Ptr = shared_ptr<TransformationEstimationSVD<PointSource, PointTarget, Scalar>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ pcl::CrfNormalSegmentation<PointT>::segmentPoints ()
{
}

#define PCL_INSTANTIATE_CrfNormalSegmentation(T) template class pcl::CrfNormalSegmentation<T>;
#define PCL_INSTANTIATE_CrfNormalSegmentation(T) template class PCL_EXPORTS pcl::CrfNormalSegmentation<T>;

#endif // PCL_CRF_NORMAL_SEGMENTATION_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -686,57 +686,11 @@ pcl::SupervoxelClustering<PointT>::getMaxLabel () const
return max_label;
}

namespace pcl
{
namespace octree
{
//Explicit overloads for RGB types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::addPoint (const pcl::PointXYZRGB &new_point);

template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData>::addPoint (const pcl::PointXYZRGBA &new_point);

//Explicit overloads for RGB types
template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::computeData ();

template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData>::computeData ();

//Explicit overloads for XYZ types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData>::addPoint (const pcl::PointXYZ &new_point);

template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData>::computeData ();
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace pcl
{

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const;

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const;

template<typename PointT> void
pcl::SupervoxelClustering<PointT>::VoxelData::getPoint (PointT &point_arg ) const
{
//XYZ is required or this doesn't make much sense...
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}

{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::SupervoxelClustering<PointT>::VoxelData::getNormal (Normal &normal_arg) const
Expand Down
22 changes: 22 additions & 0 deletions segmentation/include/pcl/segmentation/supervoxel_clustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,33 @@ namespace pcl
owner_ (nullptr)
{}

#ifdef DOXYGEN_ONLY
/** \brief Gets the data of in the form of a point
* \param[out] point_arg Will contain the point value of the voxeldata
*/
void
getPoint (PointT &point_arg) const;
#else
template<typename PointT2 = PointT, traits::HasColor<PointT2> = true> void
getPoint (PointT &point_arg) const
{
point_arg.rgba = static_cast<std::uint32_t>(rgb_[0]) << 16 |
static_cast<std::uint32_t>(rgb_[1]) << 8 |
static_cast<std::uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}

template<typename PointT2 = PointT, traits::HasNoColor<PointT2> = true> void
getPoint (PointT &point_arg ) const
{
//XYZ is required or this doesn't make much sense...
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}
#endif

/** \brief Gets the data of in the form of a normal
* \param[out] normal_arg Will contain the normal value of the voxeldata
Expand Down
33 changes: 4 additions & 29 deletions segmentation/src/supervoxel_clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
#include <pcl/segmentation/impl/supervoxel_clustering.hpp>
#include <pcl/octree/impl/octree_pointcloud_adjacency.hpp>

template class PCL_EXPORTS pcl::SupervoxelClustering<pcl::PointXYZ>;
template class PCL_EXPORTS pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class PCL_EXPORTS pcl::SupervoxelClustering<pcl::PointXYZRGBA>;

namespace pcl
{
namespace octree
Expand Down Expand Up @@ -135,31 +139,6 @@ namespace pcl
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace pcl
{
template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const
{
point_arg.rgba = static_cast<std::uint32_t>(rgb_[0]) << 16 |
static_cast<std::uint32_t>(rgb_[1]) << 8 |
static_cast<std::uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const
{
point_arg.rgba = static_cast<std::uint32_t>(rgb_[0]) << 16 |
static_cast<std::uint32_t>(rgb_[1]) << 8 |
static_cast<std::uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}
}

using VoxelDataT = pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData;
using VoxelDataRGBT = pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData;
using VoxelDataRGBAT = pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData;
Expand All @@ -168,10 +147,6 @@ using AdjacencyContainerT = pcl::octree::OctreePointCloudAdjacencyContainer<pcl:
using AdjacencyContainerRGBT = pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB, VoxelDataRGBT>;
using AdjacencyContainerRGBAT = pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA, VoxelDataRGBAT>;

template class pcl::SupervoxelClustering<pcl::PointXYZ>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGBA>;

template class pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ, VoxelDataT>;
template class pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB, VoxelDataRGBT>;
template class pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA, VoxelDataRGBAT>;
Expand Down
Loading