Skip to content

Commit 4b1f438

Browse files
Zinputjason
and
jason
authored
Feature/meson support (#522)
* set remote branch * add subprojects * give up compiling unit tests in Meson because no user-defined function feature * add support for installing m4 macros * add comments in root meson.build * add pkg-config generator * remove gtest subproject because removed unit tests earlier * add python support * add lua support * remove 'bin' install directories because meson defaults to standard conforming directory i.e. bin * add basic java support * reset options * change meson.options to meson_options.txt for backward compatibility * make doxygen not required * remove compiler warnings to match cmake * remove -Wno-unused-result c_arg * add option to disable compilation of lcmgen * mark java as WIP in meson.build * create meson ci tests * edit windows build dependencies and linking in meson * make full lcm_export.h * try not compiling static libs for windows * try verbose output in ci for windows * add compiler arg for windows in meson * build static liblcm again * add basic test to meson build ci * install shared library lcm * use grep to create test for lcm windows * remove verbose output from cmake windows build * remove verbose output from meson windows build * install lcm lib headers * install man pages * clean up commented code and unused code * fix lcm header install subdir into lcm subdir * add build files for c example * add ci test for building c example * install lcm before using in Windows ci test * fix directories * fix fedora docker command and don't build c example for windows * add build files for cpp example and lcm_log_writer * add ci tests for building c++ and lcm log writer example * comment placeholder code for java pkg-config generation * address documentation support not implemented yet * add generated file from examples to gitignore * shorten code and remove unused exe variable declarations * remove jchart2d meson files until further development * shorten library building code using Meson's * add generated c example code to gitignore * add back variable for static lcm lib fix python library installation and remove comment * build all modules with met dependencies by default * remove building java because broken * check for optional module dependencies and don't build optional modules if not found * add options summary * remove generated java targets from main meson build * remove name_suffix from windows python build * remove python support for Windows and describe WIP status for python and java * remove mysterious meson/ directory from gitignore * shorten lcm lib building code * rename lcm-python module to lcm * add detailed summary * add build instructions for Meson * use meson built in default_library switch for building shared/static instead of unused option * fix lcm-lua install_dir and name * mark all optional modules as not working * add spaces * fix python installation for linux and macos * move pure keyword from find_installation() to install_sources() and bring back hacky platlib dir for compatibility with ubuntu 22.04's ancient meson version * fix macos lua install oserror * update lua install_dir to match cmake * replace unsupported message with disabled message when unsupported features are disabled * fix if statement * fix python/lua typo * remove python, lua, and java support * use threads dependency * remove threads dep for windows * include stdbool.h for windows * format code * add rationale for nested broken modules --------- Co-authored-by: jason <[email protected]>
1 parent a234e3a commit 4b1f438

24 files changed

+646
-15
lines changed

.github/workflows/test_meson.yml

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: test_meson
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
7+
ubuntu:
8+
strategy:
9+
matrix:
10+
os: [ubuntu-24.04, ubuntu-22.04]
11+
build_type: [Debug, Release]
12+
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install Dependencies
19+
run: |
20+
sudo apt install liblua5.3-dev lua5.3 libjchart2d-java libglib2.0-dev meson
21+
22+
- name: Setup Meson
23+
run: meson setup ${{github.workspace}}/build
24+
25+
- name: Build
26+
run: ninja -C ${{github.workspace}}/build
27+
28+
- name: Test
29+
run : '${{github.workspace}}/build/liblcm-test/lcm-tester | grep "LCM: OK!"'
30+
31+
- name: Install
32+
run : sudo ninja -C ${{github.workspace}}/build install
33+
34+
- name : Build C Example
35+
working-directory: ${{github.workspace}}/examples/c
36+
run: |
37+
meson setup build
38+
ninja -C build
39+
40+
- name: Build C++ Example
41+
working-directory: ${{github.workspace}}/examples/cpp
42+
run: |
43+
meson setup build
44+
ninja -C build
45+
46+
- name: Build and Run C++ Log Writer Example
47+
working-directory: ${{github.workspace}}/examples/cpp/lcm_log_writer
48+
run: |
49+
meson setup build
50+
ninja -C build
51+
LD_LIBRARY_PATH=/usr/local/lib/ build/lcm_log_writer build/example.log
52+
53+
fedora:
54+
runs-on: ubuntu-24.04
55+
56+
steps:
57+
- uses: actions/checkout@v3
58+
59+
- name: Build and Start Container
60+
run: |
61+
docker build -f docker/Dockerfile.fedora -t lcm-fedora docker
62+
docker run -v $(pwd):/work -d --rm -it --name lcm-fedora lcm-fedora /bin/bash
63+
64+
- name: Setup Meson
65+
run: docker exec lcm-fedora meson setup ${{github.workspace}}/build
66+
67+
- name: Build
68+
run: docker exec lcm-fedora ninja -C ${{github.workspace}}/build
69+
70+
- name: Test
71+
run : 'docker exec lcm-fedora ${{github.workspace}}/build/liblcm-test/lcm-tester | grep "LCM: OK!"'
72+
73+
- name: Install
74+
run : docker exec lcm-fedora ninja -C ${{github.workspace}}/build install
75+
76+
- name : Build C Example
77+
run: |
78+
docker exec --workdir /work/examples/c lcm-fedora meson setup build
79+
docker exec --workdir /work/examples/c lcm-fedora ninja -C build
80+
81+
- name: Build C++ Example
82+
run: |
83+
docker exec --workdir /work/examples/cpp lcm-fedora meson setup build
84+
docker exec --workdir /work/examples/cpp lcm-fedora ninja -C build
85+
86+
- name: Build and Run C++ Log Writer Example
87+
working-directory: ${{github.workspace}}/examples/cpp/lcm_log_writer
88+
run: |
89+
docker exec --workdir /work/examples/cpp/lcm_log_writer lcm-fedora meson setup build
90+
docker exec --workdir /work/examples/cpp/lcm_log_writer lcm-fedora ninja -C build
91+
docker exec --workdir /work/examples/cpp/lcm_log_writer -e LD_LIBRARY_PATH=/usr/local/lib64/ lcm-fedora build/lcm_log_writer build/example.log
92+
93+
macos:
94+
strategy:
95+
matrix:
96+
os: [macos-13, macos-14]
97+
98+
runs-on: ${{ matrix.os }}
99+
100+
steps:
101+
- uses: actions/checkout@v3
102+
103+
- name: Install Dependencies
104+
run: |
105+
brew install lua meson
106+
107+
- name: Setup Meson
108+
run: meson setup ${{github.workspace}}/build
109+
110+
- name: Build
111+
run: ninja -C ${{github.workspace}}/build
112+
113+
- name: Test
114+
run : '${{github.workspace}}/build/liblcm-test/lcm-tester | grep "LCM: OK!"'
115+
116+
- name: Install
117+
run : sudo ninja -C ${{github.workspace}}/build install
118+
119+
- name : Build C Example
120+
working-directory: ${{github.workspace}}/examples/c
121+
run: |
122+
meson setup build
123+
ninja -C build
124+
125+
- name: Build C++ Example
126+
working-directory: ${{github.workspace}}/examples/cpp
127+
run: |
128+
meson setup build
129+
ninja -C build
130+
131+
- name: Build and Run C++ Log Writer Example
132+
working-directory: ${{github.workspace}}/examples/cpp/lcm_log_writer
133+
run: |
134+
meson setup build
135+
ninja -C build
136+
build/lcm_log_writer build/example.log
137+
138+
windows:
139+
strategy:
140+
matrix:
141+
os: [windows-2019, windows-2022]
142+
143+
runs-on: ${{ matrix.os }}
144+
145+
defaults:
146+
run:
147+
shell: msys2 {0}
148+
149+
steps:
150+
- uses: actions/checkout@v3
151+
- uses: msys2/setup-msys2@v2
152+
with:
153+
msystem: mingw64
154+
update: false
155+
install: >-
156+
git
157+
make
158+
pacboy: >-
159+
toolchain:p
160+
cmake:p
161+
glib2:p
162+
gtest:p
163+
meson:p
164+
165+
- name: Setup Meson
166+
run: meson setup build --prefix /mingw64/
167+
168+
- name: Build
169+
run: ninja -C build
170+
171+
- name: Install
172+
run: ninja -C build install
173+
174+
- name: Test
175+
run : 'lcm-tester | grep "LCM: OK"'

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ docs/_build/
88
.project
99
.classpath
1010
.venv
11-
.DS_Store
11+
.DS_Store
12+
.cache/

docker/Dockerfile.fedora

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RUN dnf install -y \
1010
clang \
1111
glib2-devel \
1212
java-17-openjdk-devel \
13-
python3-devel
13+
python3-devel \
14+
meson
1415

1516
WORKDIR /work

docs/content/build-instructions.md

+40-13
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,43 @@ To build the Python module from source and install it, run:
2929
pip3 install -v .
3030
```
3131

32-
## CMake Overview
32+
## CMake and Meson overview
3333

3434
These instructions assume that you will build in a directory named `build` as
3535
a direct subdirectory of the source directory, and that you will use the
36-
default generator. CMake permits the build directory to be almost anywhere
37-
(although in-source builds are strongly discouraged), and supports multiple
38-
generators. To users familiar with CMake, we recommend using
39-
[Ninja](https://ninja-build.org/).
36+
default generator. CMake and Meson support multiple generators and permit the
37+
build directory to be almost anywhere (although in-source builds are strongly
38+
discouraged for both and are prohibited in Meson). To users familiar with
39+
CMake, we recommend using [Ninja](https://ninja-build.org/).
4040

41-
A detailed description of how to use CMake is not specific to LCM and is beyond
42-
the scope of these instructions.
41+
A detailed description of how to use CMake or Meson is not specific to LCM and
42+
is beyond the scope of these instructions.
4343

44-
By default CMake is configured to produce a release build. To build with debug symbols instead, use:
44+
By default CMake and Meson are configured to produce a release build. To build with debug symbols instead, use:
4545

4646
```shell
4747
cmake .. -DCMAKE_BUILD_TYPE=Debug
4848
```
4949

50-
when configuring a build directory in the following sections.
50+
for CMake, and use:
51+
52+
```shell
53+
meson setup build -Dbuildtype=debug
54+
```
55+
56+
for Meson when configuring a build directory in the following sections.
5157

5258
## Ubuntu and Debian
5359

5460
Required packages:
5561
- build-essential
56-
- cmake
62+
- cmake # note: if using CMake
63+
- meson # note: if using Meson
5764
- libglib2.0-dev
5865

5966
Optional packages (e.g., for language-specific support or building documentation):
6067
- default-jdk
61-
- libjchart2d-java # note: if not installed, jchart2d will be built from source
68+
- libjchart2d-java # note: if not installed, jchart2d will be built from source in CMake
6269
- doxygen
6370
- liblua5.3-dev
6471
- lua5.3
@@ -69,7 +76,7 @@ Python packages needed for building documentation:
6976
- myst-parser
7077
- sphinx-rtd-theme
7178

72-
From a terminal, run the following commands.
79+
From a terminal, run the following commands for CMake:
7380

7481
```shell
7582
mkdir build
@@ -79,14 +86,23 @@ make
7986
sudo make install
8087
```
8188

89+
or run the following commands for Meson:
90+
91+
```shell
92+
meson setup build
93+
cd build
94+
meson compile
95+
sudo meson install
96+
```
97+
8298
## OS X
8399

84100
There are several ways to build LCM on OS X, none of which are necessarily
85101
better than the others.
86102

87103
### Homebrew
88104

89-
Install Homebrew packages
105+
Install Homebrew packages (swap `cmake` for `meson` if building with Meson)
90106

91107
```shell
92108
brew install glib pkg-config cmake
@@ -96,6 +112,8 @@ Install Java. Type `javac` in a terminal, then follow the instructions.
96112

97113
Download and build LCM.
98114

115+
For CMake, run:
116+
99117
```shell
100118
mkdir build
101119
cd build
@@ -104,6 +122,15 @@ make
104122
make install
105123
```
106124

125+
For Meson, run:
126+
127+
```shell
128+
meson setup build
129+
cd build
130+
meson compile
131+
meson install
132+
```
133+
107134
## Windows
108135

109136
LCM is officially supported on MSYS2. There is some residual support for Visual Studio that is

docs/meson.build

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Placeholder code until documentation support is implemented
2+
# doxygen = find_program('doxygen', required : false)
3+
# if not doxygen.found()
4+
# warning('Doxygen was not found; documentation generation will be incomplete')
5+
# endif

examples/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,14 @@
99
/c/exlcm_example_t.c
1010
/c/exlcm_example_t.h
1111
/c/listener-async
12+
/c/exlcm_example_list_t.c
13+
/c/exlcm_example_list_t.h
14+
/c/exlcm_exampleconst_t.c
15+
/c/exlcm_exampleconst_t.h
16+
/c/exlcm_muldim_array_t.c
17+
/c/exlcm_muldim_array_t.h
18+
/c/exlcm_node_t.c
19+
/c/exlcm_node_t.h
20+
/cpp/lcm_log_writer/pronto/
1221
/java/temperature_demo_java/lcmtypes/
1322
!/go/listener/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
lcm-gen -c ../types/*

examples/c/meson.build

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
project('lcm_c_example', 'c')
2+
3+
lcm_dep = dependency('lcm')
4+
glib_dep = dependency('glib-2.0')
5+
6+
generate_example_messages_c_exe = find_program('generate_example_messages_c.sh')
7+
run_command(generate_example_messages_c_exe, check: true)
8+
9+
example_messages_source = ['exlcm_exampleconst_t.c', 'exlcm_example_list_t.c', 'exlcm_example_t.c', 'exlcm_muldim_array_t.c', 'exlcm_node_t.c']
10+
example_messages_c_lib = library('example_messages-c',
11+
example_messages_source,
12+
dependencies : lcm_dep)
13+
14+
example_messages_c_dep = declare_dependency(link_with : example_messages_c_lib,
15+
dependencies : lcm_dep)
16+
17+
executable('listener',
18+
'listener.c',
19+
dependencies : example_messages_c_dep)
20+
executable('listener-async',
21+
'listener-async.c',
22+
dependencies : example_messages_c_dep)
23+
executable('listener-glib',
24+
'listener-glib.c',
25+
dependencies : [example_messages_c_dep, glib_dep])
26+
executable('send_message',
27+
'send_message.c',
28+
dependencies : example_messages_c_dep)
29+
executable('read_log',
30+
'read_log.c',
31+
dependencies : example_messages_c_dep)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
lcm-gen -x ../types/*
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
project('lcm_log_writer', 'cpp')
2+
3+
lcm_dep = dependency('lcm')
4+
glib_dep = dependency('glib-2.0')
5+
6+
run_command('lcm-gen', '-x', 'pronto_joint_state_t.lcm', check: true)
7+
8+
lcm_log_writer_exe = executable('lcm_log_writer',
9+
'main.cpp',
10+
include_directories : include_directories('pronto'),
11+
dependencies : [lcm_dep, glib_dep])

0 commit comments

Comments
 (0)