From dae85219a17a72ad1b09ccebdd95a0fcb663531a Mon Sep 17 00:00:00 2001 From: Tom Moore Date: Thu, 19 Sep 2024 15:11:46 +0100 Subject: [PATCH] Fixing issue with Eigen in Ubuntu Jammy on ARM (#378) * Fixing issue with Eigen in Ubuntu Jammy on ARM --- fuse_constraints/CMakeLists.txt | 9 +++++++++ fuse_core/CMakeLists.txt | 9 +++++++++ fuse_models/CMakeLists.txt | 9 +++++++++ fuse_publishers/CMakeLists.txt | 14 ++++++++++++++ fuse_viz/CMakeLists.txt | 14 ++++++++++++++ 5 files changed, 55 insertions(+) diff --git a/fuse_constraints/CMakeLists.txt b/fuse_constraints/CMakeLists.txt index 1a4d8c874..ce0891c50 100644 --- a/fuse_constraints/CMakeLists.txt +++ b/fuse_constraints/CMakeLists.txt @@ -77,6 +77,15 @@ else() add_compile_options(-Wall -Werror) endif() +# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes +# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning +# for ARM builds here. +if(Eigen3_VERSION VERSION_EQUAL 3.4 AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND + CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu") + add_compile_options(-Wno-class-memaccess) +endif() + # fuse_constraints library add_library(${PROJECT_NAME} src/absolute_constraint.cpp diff --git a/fuse_core/CMakeLists.txt b/fuse_core/CMakeLists.txt index 7cb841059..00d5dd0d0 100644 --- a/fuse_core/CMakeLists.txt +++ b/fuse_core/CMakeLists.txt @@ -35,6 +35,15 @@ catkin_package( ########### add_compile_options(-Wall -Werror) +# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes +# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning +# for ARM builds here. +if(Eigen3_VERSION VERSION_EQUAL 3.4 AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND + CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu") + add_compile_options(-Wno-class-memaccess) +endif() + ## fuse_core library add_library(${PROJECT_NAME} src/async_motion_model.cpp diff --git a/fuse_models/CMakeLists.txt b/fuse_models/CMakeLists.txt index 9b861f5b9..dadbc40ba 100644 --- a/fuse_models/CMakeLists.txt +++ b/fuse_models/CMakeLists.txt @@ -81,6 +81,15 @@ roslint_cpp() ########### add_compile_options(-Wall -Werror) +# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes +# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning +# for ARM builds here. +if(Eigen3_VERSION VERSION_EQUAL 3.4 AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND + CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu") + add_compile_options(-Wno-class-memaccess) +endif() + ## Declare a C++ library add_library(${PROJECT_NAME} src/acceleration_2d.cpp diff --git a/fuse_publishers/CMakeLists.txt b/fuse_publishers/CMakeLists.txt index a2f78f010..d6ee2affe 100644 --- a/fuse_publishers/CMakeLists.txt +++ b/fuse_publishers/CMakeLists.txt @@ -31,6 +31,20 @@ catkin_package( ########### add_compile_options(-Wall -Werror) +# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes +# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning +# for ARM builds here. However, this package does not depend directly upon Eigen, but includes headers from other +# packages that do. So to prevent the error, we need to find Eigen and then check the version. +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND + CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu") + + find_package(Eigen3) + + if(Eigen3_FOUND AND Eigen3_VERSION VERSION_EQUAL 3.4) + add_compile_options(-Wno-class-memaccess) + endif() +endif() + # fuse_publishers library add_library(${PROJECT_NAME} src/path_2d_publisher.cpp diff --git a/fuse_viz/CMakeLists.txt b/fuse_viz/CMakeLists.txt index bde535755..32a681ffd 100644 --- a/fuse_viz/CMakeLists.txt +++ b/fuse_viz/CMakeLists.txt @@ -35,6 +35,20 @@ add_definitions(-DQT_NO_KEYWORDS) ########### add_compile_options(-Wall -Werror) +# On ARM, the use of Eigen 3.4 with g++11 (both the versions in Jammy) causes a warning, which in turn causes +# the build to fail. Details are here: https://gitlab.com/libeigen/eigen/-/issues/2326. We can suppress the warning +# for ARM builds here. However, this package does not depend directly upon Eigen, but includes headers from other +# packages that do. So to prevent the error, we need to find Eigen and then check the version. +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0 AND + CMAKE_LIBRARY_ARCHITECTURE STREQUAL "aarch64-linux-gnu") + + find_package(Eigen3) + + if(Eigen3_FOUND AND Eigen3_VERSION VERSION_EQUAL 3.4) + add_compile_options(-Wno-class-memaccess) + endif() +endif() + catkin_package( INCLUDE_DIRS include LIBRARIES ${PROJECT_NAME}