Skip to content

Commit 0dfb3fc

Browse files
authored
[CMake] Add option to choose pcl::index_t while compiling (#4166)
1 parent c6d1aa2 commit 0dfb3fc

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

cmake/pcl_options.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,14 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
6464
option(BUILD_tools "Useful PCL-based command line tools" ON)
6565

6666
option(WITH_DOCS "Build doxygen documentation" OFF)
67+
68+
# set index size
69+
set(PCL_INDEX_SIZE -1 CACHE STRING "Set index size. Available options are: 8 16 32 64. A negative value indicates default size (32 for PCL >= 1.12, 8*sizeof(int) i.e., the number of bits in int, otherwise)")
70+
71+
#set whether indices are signed or unsigned
72+
set(PCL_INDEX_SIGNED true CACHE BOOL "Set whether indices need to be signed or unsigned. Signed by default.")
73+
if (PCL_INDEX_SIGNED)
74+
set(PCL_INDEX_SIGNED_STR "true")
75+
else()
76+
set (PCL_INDEX_SIGNED_STR "false")
77+
endif()

common/include/pcl/types.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
* \ingroup common
4444
*/
4545

46+
#include <pcl/pcl_config.h>
4647
#include <pcl/pcl_macros.h>
47-
4848
#include <vector>
4949

5050
#include <cstdint>
@@ -61,21 +61,6 @@ namespace pcl
6161
using int64_t PCL_DEPRECATED(1, 12, "use std::int64_t instead of pcl::int64_t") = std::int64_t;
6262
using int_fast16_t PCL_DEPRECATED(1, 12, "use std::int_fast16_t instead of pcl::int_fast16_t") = std::int_fast16_t;
6363

64-
// temporary macros for customization. Only use for PCL < 1.12
65-
// Aim is to remove macros and instead allow multiple index types to coexist together
66-
#ifndef PCL_INDEX_SIZE
67-
#if PCL_MINOR_VERSION <= 11
68-
// sizeof returns bytes, while we measure size by bits in the template
69-
#define PCL_INDEX_SIZE (sizeof(int) * 8)
70-
#else
71-
#define PCL_INDEX_SIZE 32
72-
#endif // PCL_MINOR_VERSION
73-
#endif // PCL_INDEX_SIZE
74-
75-
#ifndef PCL_INDEX_SIGNED
76-
#define PCL_INDEX_SIGNED true
77-
#endif
78-
7964
namespace detail {
8065
/**
8166
* \brief int_type::type refers to an integral type that satisfies template parameters
@@ -112,17 +97,16 @@ namespace pcl
11297
/**
11398
* \brief number of bits in PCL's index type
11499
*
115-
* For PCL 1.11, please use PCL_INDEX_SIZE to choose a size best suited for your needs.
116-
* PCL 1.12 will come with default 32, along with client code compile time choice
100+
* Please use PCL_INDEX_SIZE when building PCL to choose a size best suited for your needs.
101+
* PCL 1.12 will come with default 32
117102
*
118103
* PCL 1.11 has a default size = sizeof(int)
119104
*/
120105
constexpr std::uint8_t index_type_size = PCL_INDEX_SIZE;
121106

122107
/**
123108
* \brief signed/unsigned nature of PCL's index type
124-
* For PCL 1.11, please use PCL_INDEX_SIGNED to choose a type best suited for your needs.
125-
* PCL 1.12 will come with default signed, along with client code compile time choice
109+
* Please use PCL_INDEX_SIGNED when building PCL to choose a type best suited for your needs.
126110
* Default: signed
127111
*/
128112
constexpr bool index_type_signed = PCL_INDEX_SIGNED;

pcl_config.h.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
#define PCL_VERSION_COMPARE(OP, MAJ, MIN, PATCH) \
2121
(PCL_VERSION*10+PCL_DEV_VERSION OP PCL_VERSION_CALC(MAJ, MIN, PATCH)*10)
2222

23+
/* Index type and signed/unsigned property */
24+
#define PCL_INDEX_SIGNED ${PCL_INDEX_SIGNED_STR}
25+
26+
#if (${PCL_INDEX_SIZE} > 0)
27+
#define PCL_INDEX_SIZE ${PCL_INDEX_SIZE}
28+
#else
29+
#if PCL_MINOR_VERSION <= 11
30+
// sizeof returns bytes, while we measure size by bits in the template
31+
#define PCL_INDEX_SIZE (sizeof(int) * 8)
32+
#else
33+
#define PCL_INDEX_SIZE 32
34+
#endif //PCL_MINOR_VERSION
35+
#endif
36+
2337
#cmakedefine HAVE_TBB 1
2438

2539
#cmakedefine HAVE_OPENNI 1

0 commit comments

Comments
 (0)