diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-07-16 14:18:31 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2021-07-16 14:25:40 (GMT) |
commit | aa874dc6090cf6b6c9621572419738d105ff4ba3 (patch) | |
tree | c61ee79c28a4d8b3ff104eb317195eb738c8f2f7 /Source/cmCMakePresetsFile.cxx | |
parent | 7c6234dd21b7af95e7edea6b281d859dafb2ae81 (diff) | |
download | CMake-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.cxx | 10 |
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; |