Skip to content

Commit bc47f49

Browse files
committed
Progress porting mrpt_math
1 parent e6826ad commit bc47f49

File tree

12 files changed

+264
-630
lines changed

12 files changed

+264
-630
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ doc/source/doxygen-index.rst
4646
.cmake
4747
doc/venv
4848
.pc
49+
.cache

cmakemodules/script_show_final_summary.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ SHOW_CONFIG_LINE_SYSTEM("OpenGL EGL " CMAKE_MRPT_HAS_EG
139139
SHOW_CONFIG_LINE_SYSTEM("OpenGL GLES " CMAKE_MRPT_HAS_GLES "[Version: ${GLESV2_VERSION}]")
140140
SHOW_CONFIG_LINE_SYSTEM("GLUT " CMAKE_MRPT_HAS_GLUT)
141141
SHOW_CONFIG_LINE_SYSTEM("PCAP (Wireshark logs for Velodyne) " CMAKE_MRPT_HAS_LIBPCAP)
142-
SHOW_CONFIG_LINE_SYSTEM("SuiteSparse " CMAKE_MRPT_HAS_SUITESPARSE "[Version: ${SuiteSparse_VERSION}]")
143142
SHOW_CONFIG_LINE_SYSTEM("TBB " CMAKE_MRPT_HAS_TBB "[Version: ${TBB_VERSION}]")
144143
SHOW_CONFIG_LINE_SYSTEM("tinyxml2 " CMAKE_MRPT_HAS_TINYXML2)
145144
SHOW_CONFIG_LINE_SYSTEM("wxWidgets " CMAKE_MRPT_HAS_WXWIDGETS "[Version: ${wxWidgets_VERSION_STRING} ${CMAKE_WXWIDGETS_TOOLKIT_NAME}]")

cmakemodules/script_suitesparse.cmake

Lines changed: 0 additions & 45 deletions
This file was deleted.

doc/source/doxygen-docs/dependencies.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,3 @@ See:
8383
- [Example code](https://github.com/MRPT/mrpt/tree/master/doc/mrpt-zeromq-example):
8484
- Publisher: [main_pub.cpp](https://github.com/MRPT/mrpt/blob/master/doc/mrpt-zeromq-example/main_pub.cpp)
8585
- Subscriber: [main_sub.cpp](https://github.com/MRPT/mrpt/blob/master/doc/mrpt-zeromq-example/main_sub.cpp)
86-
87-
### `suitesparse`
88-
89-
This suite provides many efficient sparse algebra routines, e.g. CHOLMOD.
90-
91-
SuiteSparse's CSparse library: Mandatory, but an embedded version exists if the library is not found in the system.
92-
93-
Used in these classes:
94-
- mrpt::math::CSparseMatrix relies on the CSparse library.

modules/mrpt_common/cmake/mrpt_cmake_functions.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ endfunction()
243243
# -----------------------------------------------------------------------------
244244
function(mrpt_configure_library TARGETNAME HEADERS_ONLY_LIBRARY ADDITIONAL_EXPORT_TARGETS CMAKE_DEPS)
245245

246-
message(STATUS "HEADERS_ONLY_LIBRARY: ${HEADERS_ONLY_LIBRARY}")
247-
248246
# Public hdrs interface:
249247
if (HEADERS_ONLY_LIBRARY)
250248
target_include_directories(${TARGETNAME} INTERFACE

modules/mrpt_math/CMakeLists.txt

Lines changed: 216 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
2-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_eigen.cmake REQUIRED) # Eigen3
3-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_nanoflann.cmake REQUIRED) # Check for nanoflann
4-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_suitesparse.cmake REQUIRED) # SuiteSparse libs
1+
# ------------------------------------------------------------------------------
2+
# Mobile Robot Programming Toolkit (MRPT)
3+
#
4+
# Copyright (c) 2005-2025, Jose Luis Blanco-Claraco, contributors (see Git history)
5+
# All rights reserved.
6+
# Released under BSD-3 license. See LICENSE file
7+
# ------------------------------------------------------------------------------
58

9+
cmake_minimum_required(VERSION 3.16)
610

7-
# See "DeclareMRPTLib.cmake"
8-
list(APPEND math_EXTRA_SRCS "${MRPT_LIBS_ROOT}/math/*.cpp" "${MRPT_LIBS_ROOT}/math/*.h")
9-
list(APPEND math_EXTRA_SRCS_NAME "math" "math")
11+
# Tell CMake we'll use C++ for use in its tests/flags
12+
project(mrpt_math LANGUAGES C CXX)
1013

11-
# CSparse
12-
if(NOT CMAKE_MRPT_HAS_SUITESPARSE)
13-
list(APPEND math_EXTRA_SRCS "${MRPT_LIBS_ROOT}/math/src/CSparse/*.c" "${MRPT_LIBS_ROOT}/math/include/mrpt/3rdparty/CSparse/*.h")
14-
list(APPEND math_EXTRA_SRCS_NAME "math/CSparse" "math/CSparse")
15-
include_directories("${MRPT_LIBS_ROOT}/math/include/mrpt/3rdparty/CSparse/")
16-
endif()
17-
18-
# kmeans++
19-
list(APPEND math_EXTRA_SRCS "${MRPT_LIBS_ROOT}/math/src/kmeans++/*.cpp" "${MRPT_LIBS_ROOT}/math/src/kmeans++/*.h")
20-
list(APPEND math_EXTRA_SRCS_NAME "math/kmeans" "math/kmeans")
14+
# MRPT CMake scripts: "mrpt_xxx()"
15+
find_package(mrpt_common REQUIRED)
16+
find_package(mrpt_system REQUIRED)
17+
find_package(mrpt_serialization REQUIRED)
18+
find_package(mrpt_random REQUIRED)
2119

22-
# extra dependencies required by unit tests in this module:
23-
set_property(GLOBAL PROPERTY mrpt_math_UNIT_TEST_EXTRA_DEPS mrpt-io)
20+
include(./cmake/script_eigen.cmake REQUIRED) # Eigen3
21+
include(./cmake/script_nanoflann.cmake REQUIRED) # Check for nanoflann
2422

2523
# eigen3:
2624
if (MRPT_EIGEN_USE_EMBEDDED_VERSION)
@@ -29,71 +27,209 @@ else()
2927
set(eigen_dep Eigen3) # find_package() lib name
3028
endif()
3129

32-
# For Ubuntu 16.04, the Eigen version does not support imported target,
33-
# so create it ourselves in the mrpt-math-config.cmake file:
34-
set(EXTRA_CONFIG_CMDS
35-
"if (NOT TARGET Eigen3::Eigen)\n\
36-
add_library(Eigen3::Eigen INTERFACE IMPORTED GLOBAL)\n\
37-
if (TARGET Eigen)\n\
38-
target_link_libraries(Eigen3::Eigen INTERFACE Eigen)\n\
39-
else()\n\
40-
if(EXISTS \"${EIGEN3_INCLUDE_DIR}\")\n\
41-
set(eigen_dirs ${EIGEN3_INCLUDE_DIR})\n\
42-
else()\n\
43-
set(eigen_dirs ${EIGEN_EMBEDDED_INCLUDE_DIR})\n\
44-
endif()\n\
45-
set_target_properties(Eigen3::Eigen PROPERTIES\n\
46-
INTERFACE_INCLUDE_DIRECTORIES\n\
47-
$<BUILD_INTERFACE:\${eigen_dirs}>\n\
48-
)\n\
49-
endif()\n\
50-
endif()\n"
30+
# define lib:
31+
set(LIB_SRCS
32+
src/A_MatrixBase_instantiate_CMatrixDynamic_d.cpp
33+
src/A_MatrixBase_instantiate_CMatrixDynamic_f.cpp
34+
src/CAtan2LookUpTable.cpp
35+
src/CAtan2LookUpTable_unittest.cpp
36+
src/CHistogram.cpp
37+
src/CLevenbergMarquardt_unittest.cpp
38+
src/CMatrixB.cpp
39+
src/CMatrixD.cpp
40+
src/CMatrixDynamic.cpp
41+
src/CMatrixDynamic_unittest.cpp
42+
src/CMatrixF.cpp
43+
src/CMatrixFixed.cpp
44+
src/CMatrixFixed_unittest.cpp
45+
src/container_ops_unittest.cpp
46+
src/CPolygon.cpp
47+
src/CSparseMatrix.cpp
48+
src/CSparseMatrix_unittest.cpp
49+
src/CSplineInterpolator1D.cpp
50+
src/CVectorDynamic.cpp
51+
src/CVectorFixed.cpp
52+
src/distributions_unittest.cpp
53+
src/EigenAlignment_unittest.cpp
54+
src/filters.cpp
55+
src/fourier.cpp
56+
src/fresnel.cpp
57+
src/fresnel_unittest.cpp
58+
src/geometry.cpp
59+
src/geometry_unittest.cpp
60+
src/KDTreeCapable_unittest.cpp
61+
src/kmeans.cpp
62+
src/kmeans++/KMeans.cpp
63+
src/kmeans++/KmTree.cpp
64+
src/kmeans++/KmUtils.cpp
65+
src/math.cpp
66+
src/MatrixBase_instantiate_CMatrixFixed_22_d.cpp
67+
src/MatrixBase_instantiate_CMatrixFixed_22_f.cpp
68+
src/MatrixBase_instantiate_CMatrixFixed_33_d.cpp
69+
src/MatrixBase_instantiate_CMatrixFixed_33_f.cpp
70+
src/matrix_ops1_unittest.cpp
71+
src/matrix_ops2_unittest.cpp
72+
src/matrix_ops3_unittest.cpp
73+
src/matrix_ops4_unittest.cpp
74+
src/matrix_ops5_unittest.cpp
75+
src/matrix_ops_unittest.cpp
76+
src/MatrixVectorBase_instantiate_CMatrixDynamic_d.cpp
77+
src/MatrixVectorBase_instantiate_CMatrixDynamic_f.cpp
78+
src/MatrixVectorBase_instantiate_CMatrixDynamic_ints.cpp
79+
src/MatrixVectorBase_instantiate_CMatrixFixed.cpp
80+
src/MatrixVectorBase_instantiate_CVectorDynamic.cpp
81+
src/MatrixVectorBase_instantiate_CVectorFixed.cpp
82+
src/matrix_yaml_unittest.cpp
83+
src/model_search.cpp
84+
src/poly_roots.cpp
85+
src/poly_roots_unittest.cpp
86+
src/ransac_applications.cpp
87+
src/registerAllClasses.cpp
88+
src/robust_kernels_unittest.cpp
89+
src/slerp.cpp
90+
src/slerp_unittest.cpp
91+
src/S_MatrixBase_instantiate_CMatrixFixed_66_d.cpp
92+
src/S_MatrixBase_instantiate_CMatrixFixed_66_f.cpp
93+
src/S_MatrixBase_instantiate_CMatrixFixed_77_d.cpp
94+
src/TBoundingBox.cpp
95+
src/TBoundingBox_unittest.cpp
96+
src/TLine2D.cpp
97+
src/TLine3D.cpp
98+
src/TObject2D.cpp
99+
src/TObject3D.cpp
100+
src/TPlane.cpp
101+
src/TPoint2D.cpp
102+
src/TPoint3D.cpp
103+
src/TPolygon2D.cpp
104+
src/TPolygon3D.cpp
105+
src/TPolygonWithPlane.cpp
106+
src/TPose2D.cpp
107+
src/TPose3D.cpp
108+
src/TPose3DQuat.cpp
109+
src/TPoseOrPoint_unittest.cpp
110+
src/TSegment2D.cpp
111+
src/TSegment3D.cpp
112+
src/Twist2D.cpp
113+
src/Twist3D.cpp
114+
src/wrap2pi_unittest.cpp
115+
src/Z_MatrixBase_instantiate_CMatrixFixed_44_d.cpp
116+
src/Z_MatrixBase_instantiate_CMatrixFixed_44_f.cpp
51117
)
52118

53-
define_mrpt_lib(
54-
math # Lib name
55-
# Dependencies:
56-
mrpt-serialization
57-
mrpt-random
58-
mrpt-system
59-
# Other imported targets:
60-
nanoflann # find_package() lib name
61-
${eigen_dep}
62-
)
119+
set(LIB_PUBLIC_HDRS
120+
include/mrpt/3rdparty/CSparse/cs.h
121+
include/mrpt/math/CAtan2LookUpTable.h
122+
include/mrpt/math/CBinaryRelation.h
123+
include/mrpt/math/CHistogram.h
124+
include/mrpt/math/CLevenbergMarquardt.h
125+
include/mrpt/math/CMatrixB.h
126+
include/mrpt/math/CMatrixD.h
127+
include/mrpt/math/CMatrixDynamic.h
128+
include/mrpt/math/CMatrixF.h
129+
include/mrpt/math/CMatrixFixed.h
130+
include/mrpt/math/CMonteCarlo.h
131+
include/mrpt/math/CPolygon.h
132+
include/mrpt/math/CProbabilityDensityFunction.h
133+
include/mrpt/math/CQuaternion.h
134+
include/mrpt/math/CSparseMatrixTemplate.h
135+
include/mrpt/math/CSplineInterpolator1D.h
136+
include/mrpt/math/CVectorDynamic.h
137+
include/mrpt/math/CVectorFixed.h
138+
include/mrpt/math/data_utils.h
139+
include/mrpt/math/distributions.h
140+
include/mrpt/math/eigen_extensions.h
141+
include/mrpt/math/epsilon.h
142+
include/mrpt/math/filters.h
143+
include/mrpt/math/fourier.h
144+
include/mrpt/math/fresnel.h
145+
include/mrpt/math/geometry.h
146+
include/mrpt/math/gtsam_wrappers.h
147+
include/mrpt/math/homog_matrices.h
148+
include/mrpt/math/interp_fit.h
149+
include/mrpt/math/KDTreeCapable.h
150+
include/mrpt/math/kmeans.h
151+
include/mrpt/math/mat2eig.h
152+
include/mrpt/math/math_frwds.h
153+
include/mrpt/math/matrix_adaptors.h
154+
include/mrpt/math/MatrixBase.h
155+
include/mrpt/math/MatrixBlockSparseCols.h
156+
include/mrpt/math/matrix_serialization.h
157+
include/mrpt/math/matrix_size_t.h
158+
include/mrpt/math/MatrixVectorBase.h
159+
include/mrpt/math/model_search.h
160+
include/mrpt/math/model_search_impl.h
161+
include/mrpt/math/num_jacobian.h
162+
include/mrpt/math/ops_containers.h
163+
include/mrpt/math/ops_matrices.h
164+
include/mrpt/math/ops_vectors.h
165+
include/mrpt/math/point_poses2vectors.h
166+
include/mrpt/math/poly_roots.h
167+
include/mrpt/math/ransac_applications.h
168+
include/mrpt/math/ransac.h
169+
include/mrpt/math/ransac_impl.h
170+
include/mrpt/math/registerAllClasses.h
171+
include/mrpt/math/robust_kernels.h
172+
include/mrpt/math/slerp.h
173+
include/mrpt/math/TBoundingBox.h
174+
include/mrpt/math/TLine2D.h
175+
include/mrpt/math/TLine3D.h
176+
include/mrpt/math/TObject2D.h
177+
include/mrpt/math/TObject3D.h
178+
include/mrpt/math/TPlane.h
179+
include/mrpt/math/TPoint2D.h
180+
include/mrpt/math/TPoint3D.h
181+
include/mrpt/math/TPolygon2D.h
182+
include/mrpt/math/TPolygon3D.h
183+
include/mrpt/math/TPolygonWithPlane.h
184+
include/mrpt/math/TPose2D.h
185+
include/mrpt/math/TPose3D.h
186+
include/mrpt/math/TPose3DQuat.h
187+
include/mrpt/math/TPoseOrPoint.h
188+
include/mrpt/math/transform_gaussian.h
189+
include/mrpt/math/TSegment2D.h
190+
include/mrpt/math/TSegment3D.h
191+
include/mrpt/math/TTwist2D.h
192+
include/mrpt/math/TTwist3D.h
193+
include/mrpt/math/utils.h
194+
include/mrpt/math/utils_matlab.h
195+
include/mrpt/math/wrap2pi.h
196+
)
63197

64-
if(BUILD_mrpt-math)
65-
# Ignore precompiled headers in some sources:
66-
if(MRPT_ENABLE_PRECOMPILED_HDRS AND MSVC)
67-
set_source_files_properties(
68-
${math/CSparse_FILES}
69-
${math/kmeans_FILES}
70-
PROPERTIES COMPILE_FLAGS "/Y-"
71-
)
72-
endif()
198+
mrpt_add_library(
199+
TARGET ${PROJECT_NAME}
200+
SOURCES ${LIB_SRCS} ${LIB_PUBLIC_HDRS}
201+
PUBLIC_LINK_LIBRARIES
202+
mrpt::mrpt_system
203+
mrpt::mrpt_serialization
204+
mrpt::mrpt_random
205+
Eigen3::Eigen
206+
nanoflann::nanoflann
207+
# PRIVATE_LINK_LIBRARIES
208+
CMAKE_DEPENDENCIES
209+
mrpt_system
210+
mrpt_serialization
211+
mrpt_random
212+
# Other imported targets:
213+
nanoflann # find_package() lib name
214+
${eigen_dep}
215+
)
73216

74-
# eigen3:
75-
target_link_libraries(math PUBLIC Eigen3::Eigen)
76-
if (MSVC)
77-
# This is to prevent the error (in Debug builds):
78-
# LNK1189:library limit of 65535 objects exceeded
79-
target_compile_options(math PRIVATE /Ob2)
80-
endif()
217+
# extra dependencies required by unit tests in this module:
218+
#set_property(GLOBAL PROPERTY mrpt_math_UNIT_TEST_EXTRA_DEPS mrpt-io)
81219

82-
# nanoflann:
83-
target_link_libraries(math PUBLIC nanoflann::nanoflann)
84220

85-
if (TARGET SuiteSparse::CXSparse)
86-
# Modern cmake interface?
87-
target_link_libraries(math PUBLIC SuiteSparse::CXSparse)
88-
else()
89-
if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")
90-
target_link_libraries(math PRIVATE ${SuiteSparse_LIBRARIES})
91-
endif ()
92-
if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")
93-
target_include_directories(math PUBLIC ${SuiteSparse_INCLUDE_DIRS})
94-
endif ()
95-
endif()
221+
# Ignore precompiled headers in some sources:
222+
#if(MRPT_ENABLE_PRECOMPILED_HDRS AND MSVC)
223+
# set_source_files_properties(
224+
# ${math/CSparse_FILES}
225+
# ${math/kmeans_FILES}
226+
# PROPERTIES COMPILE_FLAGS "/Y-"
227+
# )
228+
#endif()
96229

97-
# Minimize debug info for this module:
98-
#mrpt_reduced_debug_symbols(math)
99-
endif()
230+
# Still needed?
231+
#if (MSVC)
232+
# # This is to prevent the error (in Debug builds):
233+
# # LNK1189:library limit of 65535 objects exceeded
234+
# target_compile_options(math PRIVATE /Ob2)
235+
#endif()

0 commit comments

Comments
 (0)