Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
25742c58
Commit
25742c58
authored
Oct 16, 2020
by
Kyle Edwards
Browse files
CMakePresets.json: Add ${sourceDirName} macro
Fixes:
#21312
parent
60912200
Pipeline
#195944
failed with stages
in 66 minutes and 43 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Help/manual/cmake-presets.7.rst
View file @
25742c58
...
...
@@ -308,6 +308,11 @@ Format
Path to the project source directory's parent directory.
``${sourceDirName}``
The last filename component of ``${sourceDir}``. For example, if
``${sourceDir}`` is ``/path/to/source``, this would be ``source``.
``${presetName}``
Name specified in the preset's ``name`` field.
...
...
Source/cmCMakePresetsFile.cxx
View file @
25742c58
...
...
@@ -638,6 +638,10 @@ ExpandMacroResult ExpandMacro(const cmCMakePresetsFile& file,
out
+=
cmSystemTools
::
GetParentDirectory
(
file
.
SourceDir
);
return
ExpandMacroResult
::
Ok
;
}
if
(
macroName
==
"sourceDirName"
)
{
out
+=
cmSystemTools
::
GetFilenameName
(
file
.
SourceDir
);
return
ExpandMacroResult
::
Ok
;
}
if
(
macroName
==
"presetName"
)
{
out
+=
preset
.
Name
;
return
ExpandMacroResult
::
Ok
;
...
...
Tests/RunCMake/CMakePresets/CMakePresets.json.in
View file @
25742c58
...
...
@@ -72,6 +72,7 @@
"TEST_DOLLAR": {
"value": "${dollar}"
},
"TEST_SOURCE_DIR_NAME": "${sourceDirName}",
"TEST_ENV_REF": "$env{TEST_ENV_REF}",
"TEST_ENV": "$env{TEST_ENV}",
"TEST_D_ENV_REF": "$env{TEST_D_ENV_REF}",
...
...
Tests/RunCMake/CMakePresets/Good-stdout.txt
View file @
25742c58
...
...
@@ -26,6 +26,7 @@ Preset CMake variables:
TEST_PRESET_NAME:STRING="xGoodx"
TEST_SOURCE_DIR:PATH="[^
]*/Tests/RunCMake/CMakePresets/Good"
TEST_SOURCE_DIR_NAME="Good"
TEST_SOURCE_LIST:FILEPATH="[^
]*/Tests/RunCMake/CMakePresets/Good/CMakeLists\.txt"
TEST_SOURCE_PARENT_DIR:PATH="[^
...
...
Tests/RunCMake/CMakePresets/Good.cmake
View file @
25742c58
...
...
@@ -17,6 +17,7 @@ test_variable(TEST_UNTYPED_BOOL_FALSE "UNINITIALIZED" "FALSE")
test_variable
(
TEST_PRESET_NAME
"STRING"
"xGoodx"
)
test_variable
(
TEST_GENERATOR
"UNINITIALIZED"
"x
${
CMAKE_GENERATOR
}
x"
)
test_variable
(
TEST_DOLLAR
"UNINITIALIZED"
"$"
)
test_variable
(
TEST_SOURCE_DIR_NAME
"UNINITIALIZED"
"Good"
)
test_variable
(
TEST_ENV_REF
"UNINITIALIZED"
"Environment variable"
)
test_variable
(
TEST_ENV
"UNINITIALIZED"
"Environment variable"
)
test_variable
(
TEST_D_ENV_REF
"UNINITIALIZED"
"xEnvironment variablex"
)
...
...
Craig Scott
@craig.scott
mentioned in commit
761dc324
·
Oct 23, 2020
mentioned in commit
761dc324
mentioned in commit 761dc324e043a504f6cec26b03bd86eb59c48710
Toggle commit list
Craig Scott
@craig.scott
mentioned in commit
5d20e6d8
·
Oct 23, 2020
mentioned in commit
5d20e6d8
mentioned in commit 5d20e6d8036a158df8b512682d394492ab7161b9
Toggle commit list
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment