summaryrefslogtreecommitdiff
path: root/qbs
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2022-02-21 11:10:54 +0100
committerChristian Stenger <christian.stenger@qt.io>2022-02-22 05:33:10 +0000
commiteccbc0fbcc5d23c4a4d0d7961f28dfbcb497affa (patch)
treed7f3552dac780b274fcffde4dfb9f7516e51ff20 /qbs
parente59b7612b171c6f0378f990b7235353b67b2ee7d (diff)
downloadqt-creator-eccbc0fbcc5d23c4a4d0d7961f28dfbcb497affa.tar.gz
Qbs: Factor out gtest dependency check
..to make it re-usable. Change-Id: I7653ee7b3ced5fb9d2b7262aecdab12438628928 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'qbs')
-rw-r--r--qbs/modules/qtc_gtest_gmock/qtc_gtest_gmock.qbs65
1 files changed, 65 insertions, 0 deletions
diff --git a/qbs/modules/qtc_gtest_gmock/qtc_gtest_gmock.qbs b/qbs/modules/qtc_gtest_gmock/qtc_gtest_gmock.qbs
new file mode 100644
index 0000000000..5229db1440
--- /dev/null
+++ b/qbs/modules/qtc_gtest_gmock/qtc_gtest_gmock.qbs
@@ -0,0 +1,65 @@
+import qbs
+import qbs.File
+import qbs.FileInfo
+
+Module {
+ property bool preferExternalLibs: true
+
+ Depends { name: "pkgconfig"; condition: preferExternalLibs; required: false }
+ Depends { name: "gtest"; condition: preferExternalLibs; required: false }
+ Depends { name: "gmock"; condition: preferExternalLibs; required: false }
+ Depends { name: "cpp" }
+
+ Probe {
+ id: gtestProbe
+
+ property string repoDir
+ property string gtestDir
+ property string gmockDir
+ property bool hasRepo
+
+ configure: {
+ repoDir = FileInfo.cleanPath(path + "/../../../tests/unit/unittest/3rdparty/googletest");
+ gtestDir = FileInfo.joinPaths(repoDir, "googletest");
+ gmockDir = FileInfo.joinPaths(repoDir, "googlemock");
+ hasRepo = File.exists(gtestDir);
+ found = hasRepo;
+ }
+ }
+
+ property bool hasRepo: gtestProbe.hasRepo
+ property bool externalLibsPresent: preferExternalLibs && gtest.present && gmock.present
+ property bool useRepo: !externalLibsPresent && hasRepo
+ property string gtestDir: gtestProbe.gtestDir
+ property string gmockDir: gtestProbe.gmockDir
+
+ Group {
+ name: "Files from repository"
+ condition: qtc_gtest_gmock.useRepo
+ cpp.includePaths: [
+ qtc_gtest_gmock.gtestDir,
+ qtc_gtest_gmock.gmockDir,
+ FileInfo.joinPaths(qtc_gtest_gmock.gtestDir, "include"),
+ FileInfo.joinPaths(qtc_gtest_gmock.gmockDir, "include"),
+ ]
+ files: [
+ FileInfo.joinPaths(qtc_gtest_gmock.gtestDir, "src", "gtest-all.cc"),
+ FileInfo.joinPaths(qtc_gtest_gmock.gmockDir, "src", "gmock-all.cc"),
+ ]
+ }
+
+ Properties {
+ condition: qtc_gtest_gmock.useRepo
+ cpp.includePaths: [
+ FileInfo.joinPaths(qtc_gtest_gmock.gtestDir, "include"),
+ FileInfo.joinPaths(qtc_gtest_gmock.gmockDir, "include"),
+ ]
+ }
+
+ validate: {
+ if (!qtc_gtest_gmock.externalLibsPresent && !gtestProbe.found) {
+ console.warn("No GTest found.");
+ throw new Error();
+ }
+ }
+}