mesonbuild / mesonbuild/meson

The `cmake` module does not support `CMake` custom targets

Open
#12,976 2 comments 0 reactions 0 assignees View on GitHub
module:cmake
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

**Describe the bug**
Custom `CMake` targets cannot be invoked from `meson`

**To Reproduce**

`subprojects/SOMETHING/CMakeLists.ts`:
```
cmake_minimum_required(VERSION 3.16)

project(SOMETHING
DESCRIPTION "something"
LANGUAGES C CXX
)

add_custom_command(
OUTPUT "something"
COMMAND "echo > something"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
VERBATIM
)

add_custom_target(custom_something ALL DEPENDS "something")
```

`meson.build` (important part):
```
project = cmake.subproject('SOMETHING')
dependencies += [ project.dependency('custom_something') ]
```

**Expected behavior**
Simply build the target which does not supply anything

**system parameters**
`meson` is latest git checkout on Ubuntu 22.04 with the system toolchain

Error message is:
```
meson.build:151:10: ERROR: Arguments must be strings.
```

Comes from https://github.com/mmomtchev/meson/blob/0cd74c96f1b58fe89ef9565ab40905d04538d7ed/mesonbuild/modules/cmake.py#L139

`info` contains:

```
{'inc': None, 'src': None, 'dep': None, 'tgt': 'custom_something', 'func': 'custom_target'}
```

Contributor guide

Open the contributing guide

Research direction

Inspect mesonbuild/modules/cmake.py around the referenced line 139, then run the provided CMake and Meson reproducer on Ubuntu 22.04. Done means cmake.subproject().dependency('custom_something') builds the custom target without the “Arguments must be strings” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.