Skip to content

Commit 9c0c260

Browse files
committed
Add support for CMake 4.1
1 parent 6c4e996 commit 9c0c260

File tree

7 files changed

+102
-24
lines changed

7 files changed

+102
-24
lines changed

.gersemirc.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/0.19.3/gersemi/configuration.schema.json
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/0.20.0/gersemi/configuration.schema.json
22

33
definitions: []
44
disable_formatting: false

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Changelog
2-
## [0.20.0] 2025-XX-XX
2+
## [0.20.0] 2025-06-30
33
### Added
44
- Support extension files.
55
- Support `sort`, `unique` and `sort+unique` hints for custom commands.
66
- Support overriding and tweaking builtin commands through extensions.
7+
- Support for new keywords in native commands available in CMake 4.1.
78

89
### Fixed
910
- Proper formatting of `FILE_SET` and associated keywords in `target_sources`.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ You can use gersemi with a pre-commit hook by adding the following to `.pre-comm
136136
```yaml
137137
repos:
138138
- repo: https://github.com/BlankSpruce/gersemi
139-
rev: 0.19.3
139+
rev: 0.20.0
140140
hooks:
141141
- id: gersemi
142142
```
@@ -152,7 +152,7 @@ If you want to use extensions with pre-commit list them with [`additional_depend
152152
```yaml
153153
repos:
154154
- repo: https://github.com/BlankSpruce/gersemi
155-
rev: 0.19.3
155+
rev: 0.20.0
156156
hooks:
157157
- id: gersemi
158158
additional_dependencies:
@@ -754,6 +754,7 @@ You can extend gersemi capabilities through Python modules listed with `--extens
754754
- be module installed in gersemi's environment that follows naming convention `gersemi_{extension module name}`,
755755
- be file that ends with `.py` extension, for example: `acme_corporation.py`
756756
- implement `command_definitions` mapping, where key describes command in its canonical casing and value describes command properties,
757+
757758
> [!IMPORTANT]
758759
1) Exact details on command properties are available in [extension example implementation](extension-example/extension/gersemi_extension_example/__init__.py).
759760
2) It's possible to override or tweak builtin commands. Extension example shows how to do that with `target_sources` command example. Use with caution.

gersemi/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__license__ = "MPL 2.0"
55
__title__ = "gersemi"
66
__url__ = "https://github.com/BlankSpruce/gersemi"
7-
__version__ = "0.19.3"
7+
__version__ = "0.20.0"

gersemi/builtin_commands.py

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,62 @@
314314
},
315315
},
316316
"cmake_pkg_config": {
317-
"options": ["REQUIRED", "EXACT", "QUIET"],
318-
"one_value_keywords": [
319-
"STRICTNESS",
320-
"ENV_MODE",
321-
"DISABLE_UNINSTALLED",
322-
"PC_SYSROOT_DIR",
323-
"TOP_BUILD_DIR",
324-
"ALLOW_SYSTEM_INCLUDES",
325-
"ALLOW_SYSTEM_LIBS",
326-
],
327-
"multi_value_keywords": [
328-
"EXTRACT",
329-
"PC_LIBDIR",
330-
"PC_PATH",
331-
"SYSTEM_INCLUDE_DIRS",
332-
"SYSTEM_LIBRARY_DIRS",
333-
],
317+
"signatures": {
318+
"EXTRACT": {
319+
"options": ["REQUIRED", "EXACT", "QUIET"],
320+
"one_value_keywords": [
321+
"STRICTNESS",
322+
"ENV_MODE",
323+
"DISABLE_UNINSTALLED",
324+
"PC_SYSROOT_DIR",
325+
"TOP_BUILD_DIR",
326+
"ALLOW_SYSTEM_INCLUDES",
327+
"ALLOW_SYSTEM_LIBS",
328+
],
329+
"multi_value_keywords": [
330+
"EXTRACT",
331+
"PC_LIBDIR",
332+
"PC_PATH",
333+
"SYSTEM_INCLUDE_DIRS",
334+
"SYSTEM_LIBRARY_DIRS",
335+
],
336+
},
337+
"POPULATE": {
338+
"options": ["REQUIRED", "EXACT", "QUIET"],
339+
"one_value_keywords": [
340+
"PREFIX",
341+
"STRICTNESS",
342+
"ENV_MODE",
343+
"DISABLE_UNINSTALLED",
344+
"PC_SYSROOT_DIR",
345+
"TOP_BUILD_DIR",
346+
],
347+
"multi_value_keywords": [
348+
"POPULATE",
349+
"BIND_PC_REQUIRES",
350+
"PC_LIBDIR",
351+
"PC_PATH",
352+
],
353+
},
354+
"IMPORT": {
355+
"options": ["REQUIRED", "EXACT", "QUIET"],
356+
"one_value_keywords": [
357+
"NAME",
358+
"PREFIX",
359+
"STRICTNESS",
360+
"ENV_MODE",
361+
"DISABLE_UNINSTALLED",
362+
"PC_SYSROOT_DIR",
363+
"TOP_BUILD_DIR",
364+
],
365+
"multi_value_keywords": [
366+
"IMPORT",
367+
"BIND_PC_REQUIRES",
368+
"PC_LIBDIR",
369+
"PC_PATH",
370+
],
371+
},
372+
}
334373
},
335374
"cmake_policy": {
336375
"signatures": {
@@ -1336,6 +1375,7 @@
13361375
"MESSAGE_NEVER",
13371376
"EXCLUDE_FROM_ALL",
13381377
"FILES_MATCHING",
1378+
"EXCLUDE_EMPTY_DIRECTORIES",
13391379
],
13401380
"one_value_keywords": ["TYPE", "DESTINATION", "COMPONENT"],
13411381
"multi_value_keywords": [
@@ -1457,7 +1497,12 @@
14571497
},
14581498
"project": {
14591499
"front_positional_arguments": ["<PROJECT-NAME>"],
1460-
"one_value_keywords": ["VERSION", "DESCRIPTION", "HOMEPAGE_URL"],
1500+
"one_value_keywords": [
1501+
"VERSION",
1502+
"DESCRIPTION",
1503+
"HOMEPAGE_URL",
1504+
"COMPAT_VERSION",
1505+
],
14611506
"multi_value_keywords": ["LANGUAGES"],
14621507
},
14631508
"remove_definitions": {},
@@ -3006,14 +3051,14 @@
30063051
"PROTOC_OUT_DIR",
30073052
"PLUGIN",
30083053
"PLUGIN_OPTIONS",
3009-
"DEPENDENCIES",
30103054
"PROTOC_EXE",
30113055
],
30123056
"multi_value_keywords": [
30133057
"PROTOS",
30143058
"IMPORT_DIRS",
30153059
"GENERATE_EXTENSIONS",
30163060
"PROTOC_OPTIONS",
3061+
"DEPENDENCIES",
30173062
],
30183063
},
30193064
#

tests/formatter/cmake_pkg_config.in.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ cmake_pkg_config(EXTRACT foo REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz
33
cmake_pkg_config(EXTRACT foo REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz /foo__________________________________________________)
44

55
cmake_pkg_config(EXTRACT foo 1.2.3 REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz /foo__________________________________________________)
6+
7+
cmake_pkg_config(POPULATE foo 1.2.3 PREFIX bar REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz /foo__________________________________________________)
8+
9+
cmake_pkg_config(IMPORT foo 1.2.3 NAME bar PREFIX baz REQUIRED ENV_MODE PKGCONF PC_PATH /foo/bar /foo/baz /bar /baz /foo__________________________________________________)

tests/formatter/cmake_pkg_config.out.cmake

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,30 @@ cmake_pkg_config(
2828
/baz
2929
/foo__________________________________________________
3030
)
31+
32+
cmake_pkg_config(
33+
POPULATE foo 1.2.3
34+
PREFIX bar
35+
REQUIRED
36+
ENV_MODE PKGCONF
37+
PC_PATH
38+
/foo/bar
39+
/foo/baz
40+
/bar
41+
/baz
42+
/foo__________________________________________________
43+
)
44+
45+
cmake_pkg_config(
46+
IMPORT foo 1.2.3
47+
NAME bar
48+
PREFIX baz
49+
REQUIRED
50+
ENV_MODE PKGCONF
51+
PC_PATH
52+
/foo/bar
53+
/foo/baz
54+
/bar
55+
/baz
56+
/foo__________________________________________________
57+
)

0 commit comments

Comments
 (0)