summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsFile.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-07-16 14:18:31 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2021-07-16 14:25:40 (GMT)
commitaa874dc6090cf6b6c9621572419738d105ff4ba3 (patch)
treec61ee79c28a4d8b3ff104eb317195eb738c8f2f7 /Source/cmCMakePresetsFile.cxx
parent7c6234dd21b7af95e7edea6b281d859dafb2ae81 (diff)
downloadCMake-aa874dc6090cf6b6c9621572419738d105ff4ba3.zip
CMake-aa874dc6090cf6b6c9621572419738d105ff4ba3.tar.gz
CMake-aa874dc6090cf6b6c9621572419738d105ff4ba3.tar.bz2
CMakePresets.json: Fix expansion issue with empty binaryDir
When resolving binaryDir into a full path from a relative path, we forgot to check if binaryDir is altogether empty, causing empty binaryDir's to resolve to the source directory. Fix this. Fixes: #22434
Diffstat (limited to 'Source/cmCMakePresetsFile.cxx')
-rw-r--r--Source/cmCMakePresetsFile.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx
index 2f9972c..fd578fa 100644
--- a/Source/cmCMakePresetsFile.cxx
+++ b/Source/cmCMakePresetsFile.cxx
@@ -197,11 +197,13 @@ bool ExpandMacros(const cmCMakePresetsFile& file,
std::string binaryDir = preset.BinaryDir;
CHECK_EXPAND(out, binaryDir, macroExpanders, file.GetVersion(preset))
- if (!cmSystemTools::FileIsFullPath(binaryDir)) {
- binaryDir = cmStrCat(file.SourceDir, '/', binaryDir);
+ if (!binaryDir.empty()) {
+ if (!cmSystemTools::FileIsFullPath(binaryDir)) {
+ binaryDir = cmStrCat(file.SourceDir, '/', binaryDir);
+ }
+ out->BinaryDir = cmSystemTools::CollapseFullPath(binaryDir);
+ cmSystemTools::ConvertToUnixSlashes(out->BinaryDir);
}
- out->BinaryDir = cmSystemTools::CollapseFullPath(binaryDir);
- cmSystemTools::ConvertToUnixSlashes(out->BinaryDir);
if (!preset.InstallDir.empty()) {
std::string installDir = preset.InstallDir;