Skip to content

Commit 3e7b654

Browse files
committed
create mrpt_data with example config files and small datasets for unit tests
1 parent ed07bb5 commit 3e7b654

File tree

193 files changed

+151
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+151
-68
lines changed

modules/mrpt_common/cmake/mrpt_cmake_functions.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,25 @@ function(mrpt_add_test)
665665
# Use relative paths for embedded files:
666666
target_compile_definitions(${MRPT_ADD_TEST_TARGET} PRIVATE CMAKE_UNITTEST_BASEDIR=".")
667667
endif()
668-
668+
669+
# Path to mrpt_data shared test data (config_files/, datasets/, tests/):
670+
if (NOT DEFINED MRPT_DATA_SOURCE_DIR)
671+
# Try to find it as a sibling module (colcon layout):
672+
if (EXISTS "${CMAKE_SOURCE_DIR}/../mrpt_data")
673+
get_filename_component(MRPT_DATA_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../mrpt_data" ABSOLUTE)
674+
set(MRPT_DATA_SOURCE_DIR "${MRPT_DATA_SOURCE_DIR}" CACHE PATH "Path to mrpt_data module")
675+
else()
676+
# Fallback: try installed package:
677+
find_package(mrpt_data QUIET)
678+
if (mrpt_data_FOUND)
679+
set(MRPT_DATA_SOURCE_DIR "${mrpt_data_DATA_DIR}" CACHE PATH "Path to mrpt_data (installed)")
680+
endif()
681+
endif()
682+
endif()
683+
if (MRPT_DATA_SOURCE_DIR)
684+
target_compile_definitions(${MRPT_ADD_TEST_TARGET} PRIVATE MRPT_DATA_DIR="${MRPT_DATA_SOURCE_DIR}")
685+
endif()
686+
669687
# Run it:
670688
#add_custom_target(run_${MRPT_ADD_TEST_TARGET} COMMAND $<TARGET_FILE:${MRPT_ADD_TEST_TARGET}>)
671689
add_test(${MRPT_ADD_TEST_TARGET}_build "${CMAKE_COMMAND}" --build ${CMAKE_CURRENT_BINARY_DIR} --target ${MRPT_ADD_TEST_TARGET})

modules/mrpt_common/common_headers/test_mrpt_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
namespace mrpt
1616
{
1717
std::string UNITTEST_BASEDIR();
18+
std::string mrpt_data_dir();
1819
}

modules/mrpt_common/common_sources/mrpt_test_main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313

1414
std::string mrpt::UNITTEST_BASEDIR() { return CMAKE_UNITTEST_BASEDIR; }
1515

16+
#ifdef MRPT_DATA_DIR
17+
static const std::string mrpt_data_dir_value = MRPT_DATA_DIR;
18+
#undef MRPT_DATA_DIR
19+
std::string mrpt::mrpt_data_dir() { return mrpt_data_dir_value; }
20+
#else
21+
std::string mrpt::mrpt_data_dir() { return CMAKE_UNITTEST_BASEDIR; }
22+
#endif
23+
1624
int main(int argc, char** argv)
1725
{
1826
testing::InitGoogleTest(&argc, argv);

modules/mrpt_data/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(mrpt_data LANGUAGES NONE)
3+
4+
# This package ships no code, only data files for unit tests and
5+
# example configuration files.
6+
#
7+
# After find_package(mrpt_data), the following variable is defined:
8+
# mrpt_data_DATA_DIR - Absolute path to the installed data root directory
9+
# containing: config_files/, datasets/, tests/
10+
11+
# Install data files preserving directory structure:
12+
install(DIRECTORY
13+
config_files
14+
datasets
15+
tests
16+
DESTINATION share/${PROJECT_NAME}
17+
)
18+
19+
# Generate and install a CMake config file so that downstream packages
20+
# can do find_package(mrpt_data) and get mrpt_data_DATA_DIR:
21+
include(CMakePackageConfigHelpers)
22+
23+
# The config file will compute the data dir relative to its own location.
24+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/mrpt_dataConfig.cmake"
25+
"# mrpt_data CMake config file
26+
# Provides: mrpt_data_DATA_DIR
27+
get_filename_component(_mrpt_data_CONFIG_DIR \"\${CMAKE_CURRENT_LIST_DIR}\" ABSOLUTE)
28+
get_filename_component(mrpt_data_DATA_DIR \"\${_mrpt_data_CONFIG_DIR}/../../../share/mrpt_data\" ABSOLUTE)
29+
unset(_mrpt_data_CONFIG_DIR)
30+
")
31+
32+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mrpt_dataConfig.cmake"
33+
DESTINATION lib/cmake/${PROJECT_NAME}
34+
)

share/mrpt/config_files/2d-slam-demo/2dslam-test.ini renamed to modules/mrpt_data/config_files/2d-slam-demo/2dslam-test.ini

File renamed without changes.

share/mrpt/config_files/graphslam-engine/doxygen_config_files/config_params_preamble.txt renamed to modules/mrpt_data/config_files/graphslam-engine/doxygen_config_files/config_params_preamble.txt

File renamed without changes.

share/mrpt/config_files/graphslam-engine/doxygen_config_files/graphslam-engine_config_params_preamble.txt renamed to modules/mrpt_data/config_files/graphslam-engine/doxygen_config_files/graphslam-engine_config_params_preamble.txt

File renamed without changes.

share/mrpt/config_files/graphslam-engine/laser_odometry.ini renamed to modules/mrpt_data/config_files/graphslam-engine/laser_odometry.ini

File renamed without changes.

share/mrpt/config_files/graphslam-engine/laser_odometry_LC.ini renamed to modules/mrpt_data/config_files/graphslam-engine/laser_odometry_LC.ini

File renamed without changes.

0 commit comments

Comments
 (0)