Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils-sfg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils-sfg
Commits
0bbe5b44
Commit
0bbe5b44
authored
5 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
add a CONFIG_MODULE parameter to SFG cmake registration function
parent
94fbd0a9
No related branches found
No related tags found
2 merge requests
!12
Improve versatility and robustness of `cpptype`, and document it in the user guide
,
!8
Add CONFIG_MODULE parameter to CMake function. Add Tests for CMake Integration.
Pipeline
#71210
passed
5 months ago
Stage: Code Quality
Stage: Tests
Stage: Documentation
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/source/usage/project_integration.md
+12
-3
12 additions, 3 deletions
docs/source/usage/project_integration.md
src/pystencilssfg/cmake/modules/PystencilsSfg.cmake
+19
-13
19 additions, 13 deletions
src/pystencilssfg/cmake/modules/PystencilsSfg.cmake
with
31 additions
and
16 deletions
docs/source/usage/project_integration.md
+
12
−
3
View file @
0bbe5b44
...
@@ -74,6 +74,7 @@ find_package( PystencilsSfg )
...
@@ -74,6 +74,7 @@ find_package( PystencilsSfg )
Make sure to set the
`Python_ROOT_DIR`
cache variable to point to the correct Python interpreter
Make sure to set the
`Python_ROOT_DIR`
cache variable to point to the correct Python interpreter
(i.e. the virtual environment you have installed
*pystencils-sfg*
into).
(i.e. the virtual environment you have installed
*pystencils-sfg*
into).
(cmake_add_generator_scripts)=
### Add generator scripts
### Add generator scripts
The primary interaction point in CMake is the function
`pystencilssfg_generate_target_sources`
,
The primary interaction point in CMake is the function
`pystencilssfg_generate_target_sources`
,
...
@@ -85,6 +86,7 @@ pystencilssfg_generate_target_sources( <target>
...
@@ -85,6 +86,7 @@ pystencilssfg_generate_target_sources( <target>
[DEPENDS dependency1.py [dependency2.py...]]
[DEPENDS dependency1.py [dependency2.py...]]
[FILE_EXTENSIONS <header-extension> <impl-extension>]
[FILE_EXTENSIONS <header-extension> <impl-extension>]
[OUTPUT_MODE <standalone|inline|header-only>]
[OUTPUT_MODE <standalone|inline|header-only>]
[CONFIG_MODULE <path-to-config-module.py>]
)
)
```
```
...
@@ -97,6 +99,9 @@ The function takes the following options:
...
@@ -97,6 +99,9 @@ The function takes the following options:
-
`DEPENDS`
: A list of dependencies for the generator scripts
-
`DEPENDS`
: A list of dependencies for the generator scripts
-
`FILE_EXTENSION`
: The desired extensions for the generated files
-
`FILE_EXTENSION`
: The desired extensions for the generated files
-
`OUTPUT_MODE`
: Sets the output mode of the code generator; see {any}
`SfgConfig.output_mode`
.
-
`OUTPUT_MODE`
: Sets the output mode of the code generator; see {any}
`SfgConfig.output_mode`
.
-
`CONFIG_MODULE`
: Set the configuration module for all scripts registered with this call.
If set, this overrides the value of
`PystencilsSfg_CONFIG_MODULE`
in the current scope (see
[](
#cmake_set_config_module
)
)
### Include generated files
### Include generated files
...
@@ -110,9 +115,13 @@ path, such that generated header files for a target `<target>` may be included v
...
@@ -110,9 +115,13 @@ path, such that generated header files for a target `<target>` may be included v
(cmake_set_config_module)=
(cmake_set_config_module)=
### Set a Configuration Module
### Set a Configuration Module
To specify a
[
configuration module
](
#config_module
)
for your project,
There are two ways of specifying a
[
configuration module
](
#config_module
)
for generator scripts
set the scoped variable
`PystencilsSfg_CONFIG_MODULE`
to point at the respective Python file.
registered with CMake:
The pystencils-sfg CMake system will then pass that module to each generator script invocation.
-
To set a configuration module for scripts registered with a single call to
`pystencilssfg_generate_target_sources`
,
use the
`CONFIG_MODULE`
function parameter (see
[](
#cmake_add_generator_scripts
)
).
-
To set a config module for all generator scripts within the current CMake directory and its subdirectories,
set the scoped variable
`PystencilsSfg_CONFIG_MODULE`
to point at the respective Python file, e.g.
`set( PystencilsSfg_CONFIG_MODULE ProjectConfig.py )`
.
You might want to populate your configuration module with information about the current
You might want to populate your configuration module with information about the current
build setup and environment.
build setup and environment.
...
...
This diff is collapsed.
Click to expand it.
src/pystencilssfg/cmake/modules/PystencilsSfg.cmake
+
19
−
13
View file @
0bbe5b44
...
@@ -43,7 +43,7 @@ endfunction()
...
@@ -43,7 +43,7 @@ endfunction()
function
(
pystencilssfg_generate_target_sources TARGET
)
function
(
pystencilssfg_generate_target_sources TARGET
)
set
(
options
)
set
(
options
)
set
(
oneValueArgs OUTPUT_MODE
)
set
(
oneValueArgs OUTPUT_MODE
CONFIG_MODULE
)
set
(
multiValueArgs SCRIPTS DEPENDS FILE_EXTENSIONS
)
set
(
multiValueArgs SCRIPTS DEPENDS FILE_EXTENSIONS
)
cmake_parse_arguments
(
_pssfg
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
_pssfg
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
...
@@ -53,21 +53,27 @@ function(pystencilssfg_generate_target_sources TARGET)
...
@@ -53,21 +53,27 @@ function(pystencilssfg_generate_target_sources TARGET)
list
(
APPEND generatorArgs
"--sfg-output-mode=
${
_pssfg_OUTPUT_MODE
}
"
)
list
(
APPEND generatorArgs
"--sfg-output-mode=
${
_pssfg_OUTPUT_MODE
}
"
)
endif
()
endif
()
if
(
DEFINED PystencilsSfg_CONFIGURATOR_SCRIPT
)
if
(
DEFINED _pssfg_CONFIG_MODULE
)
message
(
AUTHOR_WARNING
"The variable PystencilsSfg_CONFIGURATOR_SCRIPT is deprecated. Set PystencilsSfg_CONFIG_MODULE instead."
)
cmake_path
(
ABSOLUTE_PATH PystencilsSfg_CONFIGURATOR_SCRIPT OUTPUT_VARIABLE configscript
)
list
(
APPEND generatorArgs
"--sfg-config-module=
${
configscript
}
"
)
list
(
APPEND _pssfg_DEPENDS
${
configscript
}
)
endif
()
if
(
DEFINED PystencilsSfg_CONFIG_MODULE
)
if
(
DEFINED PystencilsSfg_CONFIGURATOR_SCRIPT
)
message
(
FATAL_ERROR
"At most one of PystencilsSfg_CONFIGURATOR_SCRIPT and PystencilsSfg_CONFIG_MODULE may be set."
)
endif
()
cmake_path
(
ABSOLUTE_PATH PystencilsSfg_CONFIG_MODULE OUTPUT_VARIABLE config_module
)
cmake_path
(
ABSOLUTE_PATH PystencilsSfg_CONFIG_MODULE OUTPUT_VARIABLE config_module
)
list
(
APPEND generatorArgs
"--sfg-config-module=
${
config_module
}
"
)
list
(
APPEND generatorArgs
"--sfg-config-module=
${
config_module
}
"
)
list
(
APPEND _pssfg_DEPENDS
${
config_module
}
)
list
(
APPEND _pssfg_DEPENDS
${
config_module
}
)
else
()
if
(
DEFINED PystencilsSfg_CONFIGURATOR_SCRIPT
)
message
(
AUTHOR_WARNING
"The variable PystencilsSfg_CONFIGURATOR_SCRIPT is deprecated. Set PystencilsSfg_CONFIG_MODULE instead."
)
cmake_path
(
ABSOLUTE_PATH PystencilsSfg_CONFIGURATOR_SCRIPT OUTPUT_VARIABLE configscript
)
list
(
APPEND generatorArgs
"--sfg-config-module=
${
configscript
}
"
)
list
(
APPEND _pssfg_DEPENDS
${
configscript
}
)
endif
()
if
(
DEFINED PystencilsSfg_CONFIG_MODULE
)
if
(
DEFINED PystencilsSfg_CONFIGURATOR_SCRIPT
)
message
(
FATAL_ERROR
"At most one of PystencilsSfg_CONFIGURATOR_SCRIPT and PystencilsSfg_CONFIG_MODULE may be set."
)
endif
()
cmake_path
(
ABSOLUTE_PATH PystencilsSfg_CONFIG_MODULE OUTPUT_VARIABLE config_module
)
list
(
APPEND generatorArgs
"--sfg-config-module=
${
config_module
}
"
)
list
(
APPEND _pssfg_DEPENDS
${
config_module
}
)
endif
()
endif
()
endif
()
if
(
DEFINED _pssfg_FILE_EXTENSIONS
)
if
(
DEFINED _pssfg_FILE_EXTENSIONS
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment