forked from qt-creator/qt-creator
Unit test: Support qbs build with googletest submodule
This is necessary to be able to build on Windows. Also add an include to fix building with clang 12. Change-Id: I9278a2c942a5e50c89c3aac19492f3a1ef3177b1 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Project {
|
||||
name: "C++ unit tests"
|
||||
condition: project.withAutotests
|
||||
references: [
|
||||
"echoserver/echoserver.qbs",
|
||||
"unittest/unittest.qbs",
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "gtest-std-printing.h"
|
||||
|
||||
#ifdef CLANG_UNIT_TESTS
|
||||
#include <clang/Basic/FileManager.h>
|
||||
#include <clang/Basic/SourceLocation.h>
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
|
||||
|
@@ -1,8 +1,55 @@
|
||||
import qbs.File
|
||||
import qbs.FileInfo
|
||||
|
||||
Project {
|
||||
name: "Unit test & helper products"
|
||||
|
||||
Product {
|
||||
name: "qtc_gtest_gmock"
|
||||
|
||||
Export {
|
||||
property bool useExternalLibs: preferExternalLibs && externalLibsPresent
|
||||
property bool useRepo: !useExternalLibs && hasRepo
|
||||
property bool preferExternalLibs: true
|
||||
property bool externalLibsPresent: gtest.present && gmock.present
|
||||
property string repoDir: FileInfo.joinPaths(path, "3rdparty", "googletest")
|
||||
property string gtestDir: FileInfo.joinPaths(repoDir, "googletest")
|
||||
property string gmockDir: FileInfo.joinPaths(repoDir, "googlemock")
|
||||
property bool hasRepo: File.exists(gtestDir)
|
||||
|
||||
Depends { name: "pkgconfig"; condition: preferExternalLibs; required: false }
|
||||
Depends { name: "gtest"; condition: preferExternalLibs; required: false }
|
||||
Depends { name: "gmock"; condition: preferExternalLibs; required: false }
|
||||
|
||||
Depends { name: "cpp" }
|
||||
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: useRepo
|
||||
cpp.includePaths: [
|
||||
FileInfo.joinPaths(gtestDir, "include"),
|
||||
FileInfo.joinPaths(gmockDir, "include"),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtcProduct {
|
||||
condition: gtest.present && gmock.present
|
||||
name: "Unit test"
|
||||
condition: qtc_gtest_gmock.hasRepo || qtc_gtest_gmock.externalLibsPresent
|
||||
type: ["application", "autotest", "json_copy"]
|
||||
consoleApplication: true
|
||||
destinationDirectory: FileInfo.joinPaths(project.buildDirectory,
|
||||
@@ -25,8 +72,8 @@ QtcProduct {
|
||||
|
||||
Depends { name: "pkgconfig"; required: false }
|
||||
Depends { name: "benchmark"; required: false }
|
||||
Depends { name: "gtest"; required: false }
|
||||
Depends { name: "gmock"; required: false }
|
||||
|
||||
Depends { name: "qtc_gtest_gmock" }
|
||||
|
||||
pluginjson.useVcsData: false
|
||||
sqlite_sources.buildSharedLib: false
|
||||
@@ -38,6 +85,12 @@ QtcProduct {
|
||||
"QT_USE_FAST_OPERATOR_PLUS",
|
||||
"QT_USE_FAST_CONCATENATION",
|
||||
"CLANG_UNIT_TESTS",
|
||||
"CLANGPCHMANAGER_STATIC_LIB",
|
||||
"CLANGSUPPORT_BUILD_STATIC_LIB",
|
||||
"CLANGTOOLS_STATIC_LIBRARY",
|
||||
"CPPTOOLS_STATIC_LIBRARY",
|
||||
"DEBUGGER_STATIC_LIBRARY",
|
||||
"PROJECTEXPLORER_STATIC_LIBRARY",
|
||||
"UNIT_TESTS",
|
||||
"DONT_CHECK_MESSAGE_COUNTER",
|
||||
'QTC_RESOURCE_DIR="' + path + "/../../../share/qtcreator" + '"',
|
||||
@@ -401,7 +454,6 @@ QtcProduct {
|
||||
Group {
|
||||
name: "sources from pchmanager"
|
||||
prefix: "../../../src/plugins/clangpchmanager/"
|
||||
cpp.defines: outer.concat("CLANGPCHMANAGER_STATIC_LIB")
|
||||
files: [
|
||||
"clangindexingprojectsettings.cpp",
|
||||
"clangindexingprojectsettings.h",
|
||||
@@ -669,7 +721,6 @@ QtcProduct {
|
||||
Group {
|
||||
name: "sources from clangsupport"
|
||||
prefix: "../../../src/libs/clangsupport/"
|
||||
cpp.defines: outer.concat("CLANGSUPPORT_STATIC_LIB")
|
||||
files: [
|
||||
"*.cpp",
|
||||
"*.h",
|
||||
@@ -703,7 +754,6 @@ QtcProduct {
|
||||
Group {
|
||||
name: "sources from cpptools"
|
||||
prefix: "../../../src/plugins/cpptools/"
|
||||
cpp.defines: outer.concat("CPPTOOLS_STATIC_LIBRARY")
|
||||
files: [
|
||||
"compileroptionsbuilder.cpp",
|
||||
"compileroptionsbuilder.h",
|
||||
@@ -729,7 +779,6 @@ QtcProduct {
|
||||
name: "sources from clangtools"
|
||||
condition: libclang.present
|
||||
prefix: "../../../src/plugins/clangtools/"
|
||||
cpp.defines: outer.concat("CLANGTOOLS_STATIC_LIBRARY")
|
||||
files: [
|
||||
"clangtoolsdiagnostic.cpp",
|
||||
"clangtoolsdiagnostic.h",
|
||||
@@ -750,7 +799,6 @@ QtcProduct {
|
||||
Group {
|
||||
name: "sources from ProjectExplorer"
|
||||
prefix: "../../../src/plugins/projectexplorer/"
|
||||
cpp.defines: base.concat("PROJECTEXPLORER_STATIC_LIBRARY")
|
||||
files: [
|
||||
"projectmacro.cpp",
|
||||
"projectmacro.h",
|
||||
@@ -809,7 +857,6 @@ QtcProduct {
|
||||
Group {
|
||||
name: "sources from Debugger"
|
||||
prefix: "../../../src/plugins/debugger/analyzer/"
|
||||
cpp.defines: outer.concat("DEBUGGER_STATIC_LIBRARY")
|
||||
files: [
|
||||
"diagnosticlocation.cpp",
|
||||
"diagnosticlocation.h",
|
||||
@@ -829,5 +876,5 @@ QtcProduct {
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user