Skip to content

Commit 14b7b72

Browse files
authored
Merge pull request #5793 from mvieth/fix_eigen_overaligned_cxx17
Fix Eigen alignment problem when user project is compiled as C++17 or newer
2 parents c96248b + 3c77869 commit 14b7b72

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

cmake/pcl_pclconfig.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ set(PCLCONFIG_SSE_DEFINITIONS "${SSE_DEFINITIONS}")
1616
set(PCLCONFIG_SSE_COMPILE_OPTIONS ${SSE_FLAGS})
1717
set(PCLCONFIG_AVX_COMPILE_OPTIONS ${AVX_FLAGS})
1818

19+
# Eigen has a custom mechanism to guarantee aligned memory (used for everything older than C++17, see Memory.h in the Eigen project)
20+
# If PCL is compiled with C++14 and the user project is compiled with C++17, this will lead to problems (e.g. memory allocated with the custom mechanism but freed without it)
21+
# Defining EIGEN_HAS_CXX17_OVERALIGN=0 forces Eigen in the user project to use Eigen's custom mechanism, even in C++17 and newer.
22+
if(${CMAKE_CXX_STANDARD} LESS 17)
23+
string(APPEND PCLCONFIG_SSE_DEFINITIONS " -DEIGEN_HAS_CXX17_OVERALIGN=0")
24+
endif()
25+
1926
foreach(_ss ${PCL_SUBSYSTEMS_MODULES})
2027
PCL_GET_SUBSYS_STATUS(_status ${_ss})
2128

0 commit comments

Comments
 (0)