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

Fix Eigen Plugins compilation when linking to grid_map_core #475

Draft
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Draft
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
13 changes: 8 additions & 5 deletions grid_map_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ project(grid_map_core)
find_package(ament_cmake REQUIRED)
find_package(grid_map_cmake_helpers REQUIRED)

## Define Eigen addons.
include(cmake/${PROJECT_NAME}-extras.cmake)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be moved down till after the library is created. You can't call target_compile_definitions on a target until the target exists.



## System dependencies are found with CMake's conventions
find_package(Eigen3 REQUIRED)
Expand Down Expand Up @@ -35,6 +34,9 @@ add_library(${PROJECT_NAME}
src/iterators/SlidingWindowIterator.cpp
)

## Define Eigen addons.
include(cmake/${PROJECT_NAME}-extras.cmake)

## Specify additional locations of header files
target_include_directories(${PROJECT_NAME}
PUBLIC
Expand Down Expand Up @@ -127,6 +129,7 @@ endif()

ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_dependencies(Eigen3)
ament_package(CONFIG_EXTRAS
cmake/${PROJECT_NAME}-extras.cmake
)
ament_package()
#ament_package(CONFIG_EXTRAS
# cmake/${PROJECT_NAME}-extras.cmake
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks if we leave it in - any tips on how to test the plugins are working in another package?

#)
4 changes: 2 additions & 2 deletions grid_map_core/cmake/grid_map_core-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(EIGEN_FUNCTORS_PLUGIN)
message(FATAL_ERROR "EIGEN_FUNCTORS_PLUGIN already defined")
endif()
else()
add_definitions(-DEIGEN_FUNCTORS_PLUGIN=\"${EIGEN_FUNCTORS_PLUGIN_PATH}\")
target_compile_definitions(grid_map_core PUBLIC EIGEN_FUNCTORS_PLUGIN=\"${EIGEN_FUNCTORS_PLUGIN_PATH}\")
endif()

set(EIGEN_DENSEBASE_PLUGIN_PATH "grid_map_core/eigen_plugins/DenseBasePlugin.hpp")
Expand All @@ -13,5 +13,5 @@ if(EIGEN_DENSEBASE_PLUGIN)
message(FATAL_ERROR "EIGEN_DENSEBASE_PLUGIN already defined!")
endif()
else()
add_definitions(-DEIGEN_DENSEBASE_PLUGIN=\"${EIGEN_DENSEBASE_PLUGIN_PATH}\")
target_compile_definitions(grid_map_core PUBLIC EIGEN_DENSEBASE_PLUGIN=\"${EIGEN_DENSEBASE_PLUGIN_PATH}\")
endif()
13 changes: 13 additions & 0 deletions issue382/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.15)
project(issue382)

find_package(grid_map_core CONFIG REQUIRED)
find_package(Eigen3 CONFIG REQUIRED)


add_executable(main1 main1.cpp)
target_link_libraries(main1 PRIVATE grid_map_core::grid_map_core)


add_executable(main2 main2.cpp)
target_link_libraries(main2 PRIVATE Eigen3::Eigen)
11 changes: 11 additions & 0 deletions issue382/main1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <Eigen/Core>

int main() {

Eigen::VectorXd v(10);
v[0] = 0.1;
v[1] = 0.2;
v(0) = 0.3;
v(1) = 0.4;
return 0;
}
12 changes: 12 additions & 0 deletions issue382/main2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <Eigen/Core>


int main() {

Eigen::VectorXd v(10);
v[0] = 0.1;
v[1] = 0.2;
v(0) = 0.3;
v(1) = 0.4;
return 0;
}
24 changes: 24 additions & 0 deletions issue382/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>issue382</name>
<version>2.0.0</version>
<description>foo.</description>
<maintainer email="[email protected]">ryan f</maintainer>
<maintainer email="[email protected]">Yoshua Nava</maintainer>
<maintainer email="[email protected]">Ryan Friedman</maintainer>
<license>BSD</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>grid_map_core</depend>
<depend>eigen</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading