Skip to content

Commit

Permalink
Add support for new keywords from CMake 3.28
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankSpruce committed Dec 17, 2023
1 parent 3888983 commit 810dd9a
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.9.4] 2023-12-17
### Added
- support for new keywords in native commands available in CMake 3.28

## [0.9.3] 2023-10-18
### Fixed
- warn about conflicting definitions for macros and functions, make usage of conflicting definitions consistent and deterministic (#11)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can use gersemi with a pre-commit hook by adding the following to `.pre-comm
```yaml
repos:
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.9.3
rev: 0.9.4
hooks:
- id: gersemi
```
Expand Down
2 changes: 1 addition & 1 deletion gersemi/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
__license__ = "MPL 2.0"
__title__ = "gersemi"
__url__ = "https://github.com/BlankSpruce/gersemi"
__version__ = "0.9.3"
__version__ = "0.9.4"
9 changes: 8 additions & 1 deletion gersemi/command_invocation_dumpers/module_command_dumpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class ExternalProjectAdd(CommandLineFormatter, ArgumentAwareCommandInvocationDum
# Build Step
"BUILD_IN_SOURCE",
"BUILD_ALWAYS",
"BUILD_JOB_SERVER_AWARE",
# Install Step
# Test Step
"TEST_BEFORE_INSTALL",
Expand Down Expand Up @@ -375,7 +376,7 @@ class SetPackageProperties(ArgumentAwareCommandInvocationDumper):


class FetchContentDeclare(CommandLineFormatter, ArgumentAwareCommandInvocationDumper):
options = ["SYSTEM", "OVERRIDE_FIND_PACKAGE"]
options = ["SYSTEM", "OVERRIDE_FIND_PACKAGE", "EXCLUDE_FROM_ALL"]
one_value_keywords = [
# Download Step
"URL_HASH",
Expand Down Expand Up @@ -722,6 +723,11 @@ class PkgCheckModules(ArgumentAwareCommandInvocationDumper):
]


class PkgGetVariable(ArgumentAwareCommandInvocationDumper):
front_positional_arguments = ["<resultVar>", "<moduleName>", "<varName>"]
multi_value_keywords = ["DEFINE_VARIABLES"]


class PkgSearchModule(ArgumentAwareCommandInvocationDumper):
options = [
"REQUIRED",
Expand Down Expand Up @@ -844,6 +850,7 @@ class ExternalDataAddTarget(ArgumentAwareCommandInvocationDumper):
"matlab_add_unit_test": MatlabAddUnitTest,
"matlab_add_mex": MatlabAddMex,
"pkg_check_modules": PkgCheckModules,
"pkg_get_variable": PkgGetVariable,
"pkg_search_module": PkgSearchModule,
"protobuf_generate_cpp": ProtobufGenerateCpp,
"qt4_wrap_cpp": Qt4WrapCpp,
Expand Down
12 changes: 10 additions & 2 deletions gersemi/command_invocation_dumpers/project_command_dumpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AddCustomCommand(CommandLineFormatter, MultipleSignatureCommandInvocationD
"COMMENT",
"DEPFILE",
"JOB_POOL",
"JOB_SERVER_AWARE",
],
multi_value_keywords=[
"OUTPUT",
Expand Down Expand Up @@ -60,7 +61,12 @@ class AddCustomCommand(CommandLineFormatter, MultipleSignatureCommandInvocationD
class AddCustomTarget(CommandLineFormatter, ArgumentAwareCommandInvocationDumper):
front_positional_arguments = ["Name", "ALL"]
options = ["VERBATIM", "USES_TERMINAL", "COMMAND_EXPAND_LISTS"]
one_value_keywords = ["WORKING_DIRECTORY", "COMMENT", "JOB_POOL"]
one_value_keywords = [
"WORKING_DIRECTORY",
"COMMENT",
"JOB_POOL",
"JOB_SERVER_AWARE",
]
multi_value_keywords = ["COMMAND", "DEPENDS", "BYPRODUCTS", "SOURCES"]
keyword_formatters = {"COMMAND": "_format_command_line"}

Expand Down Expand Up @@ -181,7 +187,8 @@ class GetTargetProperty(ArgumentAwareCommandInvocationDumper):


class GetTestProperty(ArgumentAwareCommandInvocationDumper):
front_positional_arguments = ["<VAR>", "target", "property"]
front_positional_arguments = ["test", "property"]
one_value_keywords = ["DIRECTORY"]


class IncludeDirectories(ArgumentAwareCommandInvocationDumper):
Expand Down Expand Up @@ -513,6 +520,7 @@ class SetTargetProperties(
class SetTestsProperties(
KeywordWithPairsFormatter, ArgumentAwareCommandInvocationDumper
):
one_value_keywords = ["DIRECTORY"]
multi_value_keywords = ["PROPERTIES"]
keyword_formatters = {"PROPERTIES": "_format_keyword_with_pairs"}

Expand Down
24 changes: 20 additions & 4 deletions gersemi/command_invocation_dumpers/scripting_command_dumpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,16 @@ class GetFilenameComponent(ArgumentAwareCommandInvocationDumper):
class GetProperty(ArgumentAwareCommandInvocationDumper):
front_positional_arguments = ["<variable>"]
options = ["GLOBAL", "VARIABLE", "SET", "DEFINED", "BRIEF_DOCS", "FULL_DOCS"]
one_value_keywords = ["TARGET", "INSTALL", "TEST", "CACHE", "PROPERTY"]
multi_value_keywords = ["DIRECTORY", "SOURCE"]
one_value_keywords = [
"TARGET",
"INSTALL",
"TEST",
"CACHE",
"PROPERTY",
"TARGET_DIRECTORY",
"SOURCE",
]
multi_value_keywords = ["DIRECTORY"]


class GetSourceFileProperty(ArgumentAwareCommandInvocationDumper):
Expand Down Expand Up @@ -753,8 +761,16 @@ class SeparateArguments(ArgumentAwareCommandInvocationDumper):

class SetProperty(ArgumentAwareCommandInvocationDumper):
options = ["GLOBAL", "APPEND", "APPEND_STRING"]
one_value_keywords = ["DIRECTORY"]
multi_value_keywords = ["TARGET", "SOURCE", "INSTALL", "TEST", "CACHE", "PROPERTY"]
multi_value_keywords = [
"TARGET",
"SOURCE",
"INSTALL",
"TEST",
"CACHE",
"PROPERTY",
"TARGET_DIRECTORIES",
"DIRECTORY",
]
keyword_formatters = {"PROPERTY": "_format_property"}

def _format_property(self, args):
Expand Down
8 changes: 7 additions & 1 deletion tests/formatter/get_property_command.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ if(TRUE)
get_property(FOO GLOBAL PROPERTY BAR)

get_property(FOO GLOBAL PROPERTY LONG_PROPERTY_NAME_______________________________)
endif()
endif()

get_property(FOO SOURCE foo DIRECTORY qux__________________________________________________)

get_property(FOO SOURCE foo TARGET_DIRECTORY qux__________________________________________________)

get_property(FOO TEST foo DIRECTORY qux__________________________________________________)
18 changes: 18 additions & 0 deletions tests/formatter/get_property_command.out.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,21 @@ if(TRUE)
PROPERTY LONG_PROPERTY_NAME_______________________________
)
endif()

get_property(
FOO
SOURCE foo
DIRECTORY qux__________________________________________________
)

get_property(
FOO
SOURCE foo
TARGET_DIRECTORY qux__________________________________________________
)

get_property(
FOO
TEST foo
DIRECTORY qux__________________________________________________
)
4 changes: 4 additions & 0 deletions tests/formatter/set_property_command.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ endif()
set_property(GLOBAL PROPERTY BAR_____________________________________________________________80 VALUE)

set_property(GLOBAL PROPERTY BAR______________________________________________________________81 VALUE)

set_property(SOURCE foo__________________________________________________ bar__________________________________________________ baz__________________________________________________ DIRECTORY qux__________________________________________________ TARGET_DIRECTORIES foo__________________________________________________ bar__________________________________________________ baz__________________________________________________ qux__________________________________________________)

set_property(TEST foo__________________________________________________ bar__________________________________________________ baz__________________________________________________ DIRECTORY qux__________________________________________________)
21 changes: 21 additions & 0 deletions tests/formatter/set_property_command.out.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,24 @@ set_property(
BAR______________________________________________________________81
VALUE
)

set_property(
SOURCE
foo__________________________________________________
bar__________________________________________________
baz__________________________________________________
DIRECTORY qux__________________________________________________
TARGET_DIRECTORIES
foo__________________________________________________
bar__________________________________________________
baz__________________________________________________
qux__________________________________________________
)

set_property(
TEST
foo__________________________________________________
bar__________________________________________________
baz__________________________________________________
DIRECTORY qux__________________________________________________
)

0 comments on commit 810dd9a

Please sign in to comment.