Commit 25742c58 authored by Kyle Edwards's avatar Kyle Edwards
Browse files

CMakePresets.json: Add ${sourceDirName} macro

Fixes: #21312
parent 60912200
Pipeline #195944 failed with stages
in 66 minutes and 43 seconds
......@@ -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.
......
......@@ -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;
......
......@@ -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}",
......
......@@ -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="[^
......
......@@ -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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment