diff --git a/src/libs/cplusplus/cplusplus-lib.pri b/src/libs/cplusplus/cplusplus-lib.pri
index d3053228fc31e4285f603498c7abca622f30f4e8..168fa881e68053f1dad0786d6e725c5a364308c0 100644
--- a/src/libs/cplusplus/cplusplus-lib.pri
+++ b/src/libs/cplusplus/cplusplus-lib.pri
@@ -3,14 +3,24 @@ INCLUDEPATH += $$PWD
 
 include(../../shared/cplusplus/cplusplus.pri)
 
+contains(QT_CONFIG, gui) {
 HEADERS += \
-    $$PWD/SimpleLexer.h \
+    $$PWD/Icons.h \
     $$PWD/ExpressionUnderCursor.h \
     $$PWD/TokenUnderCursor.h \
+    $$PWD/OverviewModel.h
+
+SOURCES += \
+    $$PWD/Icons.cpp \
+    $$PWD/ExpressionUnderCursor.cpp \
+    $$PWD/TokenUnderCursor.cpp \
+    $$PWD/OverviewModel.cpp
+}
+
+HEADERS += \
+    $$PWD/SimpleLexer.h \
     $$PWD/CppDocument.h \
-    $$PWD/Icons.h \
     $$PWD/Overview.h \
-    $$PWD/OverviewModel.h \
     $$PWD/NamePrettyPrinter.h \
     $$PWD/TypeOfExpression.h \
     $$PWD/TypePrettyPrinter.h \
@@ -27,12 +37,8 @@ HEADERS += \
 
 SOURCES += \
     $$PWD/SimpleLexer.cpp \
-    $$PWD/ExpressionUnderCursor.cpp \
-    $$PWD/TokenUnderCursor.cpp \
     $$PWD/CppDocument.cpp \
-    $$PWD/Icons.cpp \
     $$PWD/Overview.cpp \
-    $$PWD/OverviewModel.cpp \
     $$PWD/NamePrettyPrinter.cpp \
     $$PWD/TypeOfExpression.cpp \
     $$PWD/TypePrettyPrinter.cpp \
diff --git a/tests/auto/cplusplus/lookup/lookup.pro b/tests/auto/cplusplus/lookup/lookup.pro
index 5b68c169a8f4f22d9e93d70ae3196e3569cb8165..cd02b709575605ebe5d0e25a538441a18f950f21 100644
--- a/tests/auto/cplusplus/lookup/lookup.pro
+++ b/tests/auto/cplusplus/lookup/lookup.pro
@@ -1,4 +1,7 @@
-load(qttest_p4)
+TEMPLATE = app
+CONFIG += qt warn_on console depend_includepath
+QT = core testlib
+
 include(../../../../src/libs/cplusplus/cplusplus-lib.pri)
 
 SOURCES += tst_lookup.cpp