aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-07-26 15:09:12 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-07-29 08:47:08 +0000
commit02e224fcfa7135f1e32adb02a14426ea153ae618 (patch)
tree59dadd19f1cdb3b34e6695758317f29e307cd71b
parent4aee38e04c5d30dc90300300443a6357262fc6a5 (diff)
CMake: Support CMAKE_CURRENT_LIST_DIR and CMAKE_CURRENT_SOURCE_DIR
Support CMAKE_CURRENT_LIST_DIR and CMAKE_CURRENT_SOURCE_DIR as variables in filenames when handling links in the CMake editor. Having a way to find out variable values in CMake would be nice, till that arrives, we have to live with hacks to make the most common variables work:-/ Task-number: QTCREATORBUG-21065 Change-Id: Iffaaae8665e0662226d08b88de37b66d5a5fc4d4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index 042cb363c8..d3a4fd1d29 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -130,12 +130,9 @@ void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
static bool isValidFileNameChar(const QChar &c)
{
- return c.isLetterOrNumber()
- || c == QLatin1Char('.')
- || c == QLatin1Char('_')
- || c == QLatin1Char('-')
- || c == QLatin1Char('/')
- || c == QLatin1Char('\\');
+ return c.isLetterOrNumber() || c == QLatin1Char('.') || c == QLatin1Char('_')
+ || c == QLatin1Char('-') || c == QLatin1Char('/') || c == QLatin1Char('\\') || c == '{'
+ || c == '}' || c == '$';
}
void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
@@ -185,9 +182,12 @@ void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
if (buffer.isEmpty())
return processLinkCallback(link);
- // TODO: Resolve variables
-
QDir dir(textDocument()->filePath().toFileInfo().absolutePath());
+ buffer.replace("${CMAKE_CURRENT_SOURCE_DIR}", dir.path());
+ buffer.replace("${CMAKE_CURRENT_LIST_DIR}", dir.path());
+
+ // TODO: Resolve more variables
+
QString fileName = dir.filePath(buffer);
QFileInfo fi(fileName);
if (fi.exists()) {