diff options
author | Craig Scott <craig.scott@crascit.com> | 2024-06-01 07:34:27 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2024-06-01 07:34:27 (GMT) |
commit | afa1d0d0e355cf4bbe246d86b612a2bc56c7385d (patch) | |
tree | 06f7b8198a8fda9a34a32fbe91db3938f3e3a3d1 | |
parent | 719b461b9c5a79f2946ee010deb16dd130570ada (diff) | |
download | CMake-afa1d0d0e355cf4bbe246d86b612a2bc56c7385d.zip CMake-afa1d0d0e355cf4bbe246d86b612a2bc56c7385d.tar.gz CMake-afa1d0d0e355cf4bbe246d86b612a2bc56c7385d.tar.bz2 |
CMakeGUI: Sanitize source and build dirs the same as command line
This makes a difference when projects compare things like
CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR and the source
directory has a trailing slash in the GUI. The command line cmake invocation
cleans the paths at the beginning, so such comparisons return true. But the
GUI currently passes the paths unmodified, so such comparisons return false.
Change the logic to sanitize the paths used through the GUI in the same way
that the command line invocation does.
Fixes: #21421
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 8d63f6d..9a87416 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -238,10 +238,16 @@ void QCMake::configure() #ifdef Q_OS_WIN UINT lastErrorMode = SetErrorMode(0); #endif - - this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toStdString()); + // Apply the same transformations that the command-line invocation does + auto sanitizePath = [](QString const& value) -> std::string { + std::string path = cmSystemTools::CollapseFullPath(value.toStdString()); + cmSystemTools::ConvertToUnixSlashes(path); + return path; + }; + + this->CMakeInstance->SetHomeDirectory(sanitizePath(this->SourceDirectory)); this->CMakeInstance->SetHomeOutputDirectory( - this->BinaryDirectory.toStdString()); + sanitizePath(this->BinaryDirectory)); this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator( this->Generator.toStdString())); |