summaryrefslogtreecommitdiff
path: root/src/plugins/cmakeprojectmanager/builddirparameters.cpp
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@qt.io>2020-12-02 19:16:40 +0100
committerCristian Adam <cristian.adam@qt.io>2021-01-08 16:25:24 +0000
commit707a3cfaf33f8f342f4503ad0acb4398784decb7 (patch)
tree3ecd4988f6f423178aae85fbf19974b03442c785 /src/plugins/cmakeprojectmanager/builddirparameters.cpp
parentac378fbe2a788abacda691c4b62dcab0cca96d60 (diff)
downloadqt-creator-707a3cfaf33f8f342f4503ad0acb4398784decb7.tar.gz
CMakeProjectManager: Use CMAKE_HOME_DIRECTORY as source directory
The CMakeCache.txt file has CMAKE_HOME_DIRECTORY pointing to the project source directory used to configure the project. When importing a cmake build the CMAKE_HOME_DIRECTORY from CMakeCache.txt might not point to the same CMakeLists.txt that was opened as a project. qt-cmake-standalone-test from Qt6 uses a CMake template project which does a add_subdirectory with the test source directory, which will not work if opened standalone. Normally this is a user error though, so ask the user if this was intended, before actually importing the build. Task-number: QTBUG-88776 Change-Id: Ifdd5e1d1cb8a1ef9955d22493eba3a1a55dc689f Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/builddirparameters.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/builddirparameters.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/cmakeprojectmanager/builddirparameters.cpp b/src/plugins/cmakeprojectmanager/builddirparameters.cpp
index e240f7ec23..131ad54001 100644
--- a/src/plugins/cmakeprojectmanager/builddirparameters.cpp
+++ b/src/plugins/cmakeprojectmanager/builddirparameters.cpp
@@ -27,6 +27,7 @@
#include "cmakebuildconfiguration.h"
#include "cmakekitinformation.h"
+#include "cmakeprojectconstants.h"
#include "cmakeprojectplugin.h"
#include "cmakespecificsettings.h"
#include "cmaketoolmanager.h"
@@ -67,7 +68,9 @@ BuildDirParameters::BuildDirParameters(CMakeBuildConfiguration *bc)
projectName = p->displayName();
- sourceDirectory = p->projectDirectory();
+ sourceDirectory = bc->sourceDirectory();
+ if (sourceDirectory.isEmpty())
+ sourceDirectory = p->projectDirectory();
buildDirectory = bc->buildDirectory();
environment = bc->environment();