summaryrefslogtreecommitdiff
path: root/mrpt-libbase.spec
blob: 4488bcc8df9b5fe1484a9a0faf0146199d481361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
%define ros_distro humble
%define RosPkgName mrpt-libbase
%define src_version 2.15.20
%define mrpt_version 2.15.21

Name:           ros-%{ros_distro}-%{RosPkgName}
Version:        2.15.20
Release:        1%{?dist}
Summary:        Mobile Robot Programming Toolkit (MRPT) libraries (core C++ libraries)
License:        BSD
URL:            https://github.com/MRPT/mrpt_ros.git
Source0:        %{RosPkgName}-%{src_version}.tar.gz
# mrpt upstream source, pre-fetched to avoid ExternalProject git clone at build time
Source1:        https://github.com/MRPT/mrpt/archive/refs/tags/%{mrpt_version}.tar.gz#/mrpt-%{mrpt_version}.tar.gz

%global debug_package %{nil}
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
%global __provides_exclude_from ^/opt/ros/%{ros_distro}/.*$
%global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$

BuildRequires:  assimp-devel
BuildRequires:  eigen3-devel
BuildRequires:  ffmpeg-devel
BuildRequires:  freeglut
BuildRequires:  git
BuildRequires:  libXrandr-devel
BuildRequires:  libXxf86vm-devel
BuildRequires:  libpcap-devel
BuildRequires:  libudev-devel
BuildRequires:  libusbx-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libzstd-devel
BuildRequires:  mesa-libGL-devel
BuildRequires:  opencv
BuildRequires:  pkgconfig
BuildRequires:  pybind11-devel
BuildRequires:  suitesparse-devel
BuildRequires:  tbb-devel
BuildRequires:  tinyxml2-devel
BuildRequires:  zlib-devel
BuildRequires:  cmake

Requires:       ros-%{ros_distro}-ros-workspace

Provides:       %{name}-devel = %{version}-%{release}
Provides:       %{name}-doc = %{version}-%{release}
Provides:       %{name}-runtime = %{version}-%{release}

%description
Mobile Robot Programming Toolkit (MRPT) libraries (core C++ libraries).
  This package contains: mrpt-io, mrpt-serialization, mrpt-random, mrpt-system, mrpt-rtti, mrpt-containers, mrpt-typemeta, mrpt-core, mrpt-random, mrpt-config, mrpt-expr

%prep
%autosetup -n %{RosPkgName}-%{src_version}
# Pre-populate the ExternalProject SOURCE_DIR so cmake does not attempt a git clone.
# CMakeLists.txt checks: ${CMAKE_BINARY_DIR}/../mrpt_libbase/mrpt-build/src/mrpt/CMakeLists.txt
# With CMAKE_BINARY_DIR = <builddir>/mrpt_libbase/.obj the resolved path is:
#   <builddir>/mrpt_libbase/mrpt-build/src/mrpt/
mkdir -p mrpt_libbase/mrpt-build/src
tar -xzf %{SOURCE1} -C mrpt_libbase/mrpt-build/src
mv mrpt_libbase/mrpt-build/src/mrpt-%{mrpt_version} mrpt_libbase/mrpt-build/src/mrpt
# Write the version cache file so cmake treats the pre-populated tree as current
# VERSION_CACHE = ${CMAKE_BINARY_DIR}/../mrpt_libbase/mrpt-build/MRPT_VERSION_TO_DOWNLOAD.txt
# CMAKE_BINARY_DIR = <srcdir>/mrpt_libbase/.obj,所以实际路径为 mrpt_libbase/mrpt-build/
echo -n "%{mrpt_version}" > mrpt_libbase/mrpt-build/MRPT_VERSION_TO_DOWNLOAD.txt
# Override the version cmake reads from package.xml to match the pre-fetched source
echo 'set(MRPT_VERSION_TO_DOWNLOAD "%{mrpt_version}")' > override_mrpt_version.cmake

%build
[ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true
export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH}
export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
# CMakeLists.txt 用 $ENV{HOME}==/home/buildfarm 判断是否跳过 git clone,
# 在 COPR 构建环境中 HOME=/root,需强制设置以复用 %prep 预置的 mrpt 源码
export HOME=/home/buildfarm
cd mrpt_libbase
mkdir -p .obj && cd .obj
%cmake3 \
    -DCMAKE_INSTALL_PREFIX="/opt/ros/%{ros_distro}" \
    -DAMENT_PREFIX_PATH="/opt/ros/%{ros_distro}" \
    -DCMAKE_PREFIX_PATH="/opt/ros/%{ros_distro}" \
    -UINCLUDE_INSTALL_DIR -ULIB_INSTALL_DIR -USYSCONF_INSTALL_DIR -USHARE_INSTALL_PREFIX -ULIB_SUFFIX \
    -DSETUPTOOLS_DEB_LAYOUT=OFF \
    -DBUILD_TESTING=OFF -DTESTING=OFF -DCMAKE_SUPPRESS_REGENERATION=ON \
    -DMRPT_WITH_FREENECT=OFF \
    -DMRPT_WITH_OPENNI2=OFF \
    -DMRPT_WITH_GLFW=OFF \
    -DMRPT_BUILD_wxThings=OFF \
    ..
make %{?_smp_mflags}

%install
[ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true
export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH}
export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
cd mrpt_libbase
cd .obj
make install DESTDIR=%{buildroot}

%files
/opt/ros/%{ros_distro}

%changelog
* Mon Sep 21 2026 ai-importer <ai-importer@openeuler.org> - 2.15.20-1
- Initial import (ROS batch)