summaryrefslogtreecommitdiff
path: root/ament_cmake.spec
blob: 9740fe14e445080528e1a9630f8af95ad072d6d3 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# topdir: ament_cmake-2.9.2 (from --transform; no upstream release tag for 2.9.2,
# source is rolling branch HEAD commit 3148e68c3a0fe34cec40c6563c9020261f010fab)
%define ros_distro humble
# ros_distro is not in session.json; derived from COPR project name ROS-humble-2.

Name:           ament_cmake
Version:        2.9.2
Release:        1%{?dist}
Summary:        The entry point package for the ament buildsystem in CMake

License:        Apache-2.0
URL:            https://github.com/ament/ament_cmake
Source0:        https://github.com/ament/ament_cmake/archive/3148e68c3a0fe34cec40c6563c9020261f010fab.tar.gz#/%{name}-%{version}.tar.gz

# ament_cmake is the ROS 2 ament CMake buildsystem. It is a monorepo of ~22
# sub-packages, each with its own package.xml + CMakeLists.txt (no top-level
# CMakeLists.txt). This SRPM builds them all in topological order into one RPM.
BuildRequires:  cmake
BuildRequires:  make
BuildRequires:  gcc-c++
BuildRequires:  python3-devel
BuildRequires:  python3-catkin_pkg
# package_xml_2_cmake.py (ament_cmake_core) imports catkin_pkg.package at configure time
BuildRequires:  python3-ament-package
# templates_2_cmake.py (ament_cmake_core) imports ament_package.templates at configure time
BuildRequires:  python3-setuptools
BuildRequires:  python3-pip
BuildRequires:  python3-wheel
BuildRequires:  gcc
# pre_check completeness gate: default Python build toolchain (available in official repos)

# ROS layout: install to /opt/ros/<distro>; no debug subpackage; strip brp bytecompile
# Also disable check-buildroot: ament cmake config files inherently embed the
# buildroot prefix path (CMAKE_PREFIX_PATH/AMENT_PREFIX_PATH point at
# %%{buildroot} for topological dependency resolution), so check-buildroot
# always finds it and aborts. This is standard practice for ROS RPM packaging.
# On openEuler, check-buildroot runs via the arch install post hook (not
# the os install post hook), so we null the arch hook to disable it.
%global debug_package %{nil}
%global __arch_install_post %{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}/.*$

# Single package, no real subpackages; provide the conventional aliases.
Provides:       %{name}-devel = %{version}-%{release}
Provides:       %{name}-doc = %{version}-%{release}
Provides:       %{name}-runtime = %{version}-%{release}

%description
The entry point package for the ament buildsystem in CMake.
This package aggregates the ament_cmake CMake buildsystem components
(ament_cmake_core and the export/test/python/gmock/gtest sub-packages),
installed under /opt/ros/%{ros_distro}.

%prep
%autosetup -n %{name}-%{version}

%build
# ament_cmake IS the ROS buildsystem bootstrap: the buildroot has no
# pre-existing /opt/ros/<distro>/setup.sh, so guard any sourcing.
[ -f /opt/ros/%{ros_distro}/setup.sh ] && . /opt/ros/%{ros_distro}/setup.sh || true
export CMAKE_PREFIX_PATH="%{buildroot}/opt/ros/%{ros_distro}${CMAKE_PREFIX_PATH:+:${CMAKE_PREFIX_PATH}}"
export AMENT_PREFIX_PATH="%{buildroot}/opt/ros/%{ros_distro}"
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}"

# Topological build order (derived from each package.xml buildtool/build deps).
# With BUILD_TESTING=OFF the test-only find_package() calls are skipped, so
# ament_cmake_gen_version_h does not need ament_cmake_gtest, etc.
SUBPKGS=" \
  ament_cmake_core \
  ament_cmake_export_definitions \
  ament_cmake_export_dependencies \
  ament_cmake_export_include_directories \
  ament_cmake_export_libraries \
  ament_cmake_export_link_flags \
  ament_cmake_export_targets \
  ament_cmake_gen_version_h \
  ament_cmake_gmock \
  ament_cmake_gtest \
  ament_cmake_include_directories \
  ament_cmake_libraries \
  ament_cmake_python \
  ament_cmake_target_dependencies \
  ament_cmake_version \
  ament_cmake_vendor_package \
  ament_cmake_test \
  ament_cmake \
  ament_cmake_google_benchmark \
  ament_cmake_pytest \
  ament_cmake_auto \
  ament_cmake_python_test \
"

for pkg in $SUBPKGS; do
  echo "===== building $pkg ====="
  cmake -S "$pkg" -B ".obj/$pkg" \
    -DCMAKE_INSTALL_PREFIX="/opt/ros/%{ros_distro}" \
    -DCMAKE_PREFIX_PATH="%{buildroot}/opt/ros/%{ros_distro}" \
    -DAMENT_PREFIX_PATH="%{buildroot}/opt/ros/%{ros_distro}" \
    -DBUILD_TESTING=OFF \
    -DTESTING=OFF \
    -DCMAKE_SUPPRESS_REGENERATION=ON \
    -DSETUPTOOLS_DEB_LAYOUT=OFF \
    -UINCLUDE_INSTALL_DIR -ULIB_INSTALL_DIR -USYSCONF_INSTALL_DIR \
    -USHARE_INSTALL_PREFIX -ULIB_SUFFIX \
    -DCMAKE_C_FLAGS="%{optflags}" \
    -DCMAKE_CXX_FLAGS="%{optflags}" \
    -G "Unix Makefiles"
  cmake --build ".obj/$pkg" --verbose -- %{?_smp_mflags}
  DESTDIR="%{buildroot}" cmake --install ".obj/$pkg"
done

%install
# rpmbuild wipes the buildroot before the install phase, so the cmake installs
# done in the build phase are gone. Re-install all sub-packages from the .obj/
# build trees (cmake --install is idempotent — no reconfigure/rebuild needed).
SUBPKGS=" \
  ament_cmake_core \
  ament_cmake_export_definitions \
  ament_cmake_export_dependencies \
  ament_cmake_export_include_directories \
  ament_cmake_export_libraries \
  ament_cmake_export_link_flags \
  ament_cmake_export_targets \
  ament_cmake_gen_version_h \
  ament_cmake_gmock \
  ament_cmake_gtest \
  ament_cmake_include_directories \
  ament_cmake_libraries \
  ament_cmake_python \
  ament_cmake_target_dependencies \
  ament_cmake_version \
  ament_cmake_vendor_package \
  ament_cmake_test \
  ament_cmake \
  ament_cmake_google_benchmark \
  ament_cmake_pytest \
  ament_cmake_auto \
  ament_cmake_python_test \
"

for pkg in $SUBPKGS; do
  DESTDIR="%{buildroot}" cmake --install ".obj/$pkg"
done

%files
/opt/ros/%{ros_distro}
%license LICENSE

%changelog
* Fri Oct 09 2026 AI Importer <ai-importer@openeuler.org> - 2.9.2-1
- Initial packaging of ament_cmake 2.9.2 (ROS ament CMake buildsystem)
- Builds all 22 sub-packages in topological order into /opt/ros/humble