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 {
|
Project {
|
||||||
name: "C++ unit tests"
|
name: "C++ unit tests"
|
||||||
|
condition: project.withAutotests
|
||||||
references: [
|
references: [
|
||||||
"echoserver/echoserver.qbs",
|
"echoserver/echoserver.qbs",
|
||||||
"unittest/unittest.qbs",
|
"unittest/unittest.qbs",
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "gtest-std-printing.h"
|
#include "gtest-std-printing.h"
|
||||||
|
|
||||||
#ifdef CLANG_UNIT_TESTS
|
#ifdef CLANG_UNIT_TESTS
|
||||||
|
#include <clang/Basic/FileManager.h>
|
||||||
#include <clang/Basic/SourceLocation.h>
|
#include <clang/Basic/SourceLocation.h>
|
||||||
#include <clang/Basic/SourceManager.h>
|
#include <clang/Basic/SourceManager.h>
|
||||||
|
|
||||||
|
@@ -1,8 +1,55 @@
|
|||||||
import qbs.File
|
import qbs.File
|
||||||
import qbs.FileInfo
|
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 {
|
QtcProduct {
|
||||||
condition: gtest.present && gmock.present
|
name: "Unit test"
|
||||||
|
condition: qtc_gtest_gmock.hasRepo || qtc_gtest_gmock.externalLibsPresent
|
||||||
type: ["application", "autotest", "json_copy"]
|
type: ["application", "autotest", "json_copy"]
|
||||||
consoleApplication: true
|
consoleApplication: true
|
||||||
destinationDirectory: FileInfo.joinPaths(project.buildDirectory,
|
destinationDirectory: FileInfo.joinPaths(project.buildDirectory,
|
||||||
@@ -25,8 +72,8 @@ QtcProduct {
|
|||||||
|
|
||||||
Depends { name: "pkgconfig"; required: false }
|
Depends { name: "pkgconfig"; required: false }
|
||||||
Depends { name: "benchmark"; 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
|
pluginjson.useVcsData: false
|
||||||
sqlite_sources.buildSharedLib: false
|
sqlite_sources.buildSharedLib: false
|
||||||
@@ -38,6 +85,12 @@ QtcProduct {
|
|||||||
"QT_USE_FAST_OPERATOR_PLUS",
|
"QT_USE_FAST_OPERATOR_PLUS",
|
||||||
"QT_USE_FAST_CONCATENATION",
|
"QT_USE_FAST_CONCATENATION",
|
||||||
"CLANG_UNIT_TESTS",
|
"CLANG_UNIT_TESTS",
|
||||||
|
"CLANGPCHMANAGER_STATIC_LIB",
|
||||||
|
"CLANGSUPPORT_BUILD_STATIC_LIB",
|
||||||
|
"CLANGTOOLS_STATIC_LIBRARY",
|
||||||
|
"CPPTOOLS_STATIC_LIBRARY",
|
||||||
|
"DEBUGGER_STATIC_LIBRARY",
|
||||||
|
"PROJECTEXPLORER_STATIC_LIBRARY",
|
||||||
"UNIT_TESTS",
|
"UNIT_TESTS",
|
||||||
"DONT_CHECK_MESSAGE_COUNTER",
|
"DONT_CHECK_MESSAGE_COUNTER",
|
||||||
'QTC_RESOURCE_DIR="' + path + "/../../../share/qtcreator" + '"',
|
'QTC_RESOURCE_DIR="' + path + "/../../../share/qtcreator" + '"',
|
||||||
@@ -401,7 +454,6 @@ QtcProduct {
|
|||||||
Group {
|
Group {
|
||||||
name: "sources from pchmanager"
|
name: "sources from pchmanager"
|
||||||
prefix: "../../../src/plugins/clangpchmanager/"
|
prefix: "../../../src/plugins/clangpchmanager/"
|
||||||
cpp.defines: outer.concat("CLANGPCHMANAGER_STATIC_LIB")
|
|
||||||
files: [
|
files: [
|
||||||
"clangindexingprojectsettings.cpp",
|
"clangindexingprojectsettings.cpp",
|
||||||
"clangindexingprojectsettings.h",
|
"clangindexingprojectsettings.h",
|
||||||
@@ -669,7 +721,6 @@ QtcProduct {
|
|||||||
Group {
|
Group {
|
||||||
name: "sources from clangsupport"
|
name: "sources from clangsupport"
|
||||||
prefix: "../../../src/libs/clangsupport/"
|
prefix: "../../../src/libs/clangsupport/"
|
||||||
cpp.defines: outer.concat("CLANGSUPPORT_STATIC_LIB")
|
|
||||||
files: [
|
files: [
|
||||||
"*.cpp",
|
"*.cpp",
|
||||||
"*.h",
|
"*.h",
|
||||||
@@ -703,7 +754,6 @@ QtcProduct {
|
|||||||
Group {
|
Group {
|
||||||
name: "sources from cpptools"
|
name: "sources from cpptools"
|
||||||
prefix: "../../../src/plugins/cpptools/"
|
prefix: "../../../src/plugins/cpptools/"
|
||||||
cpp.defines: outer.concat("CPPTOOLS_STATIC_LIBRARY")
|
|
||||||
files: [
|
files: [
|
||||||
"compileroptionsbuilder.cpp",
|
"compileroptionsbuilder.cpp",
|
||||||
"compileroptionsbuilder.h",
|
"compileroptionsbuilder.h",
|
||||||
@@ -729,7 +779,6 @@ QtcProduct {
|
|||||||
name: "sources from clangtools"
|
name: "sources from clangtools"
|
||||||
condition: libclang.present
|
condition: libclang.present
|
||||||
prefix: "../../../src/plugins/clangtools/"
|
prefix: "../../../src/plugins/clangtools/"
|
||||||
cpp.defines: outer.concat("CLANGTOOLS_STATIC_LIBRARY")
|
|
||||||
files: [
|
files: [
|
||||||
"clangtoolsdiagnostic.cpp",
|
"clangtoolsdiagnostic.cpp",
|
||||||
"clangtoolsdiagnostic.h",
|
"clangtoolsdiagnostic.h",
|
||||||
@@ -750,7 +799,6 @@ QtcProduct {
|
|||||||
Group {
|
Group {
|
||||||
name: "sources from ProjectExplorer"
|
name: "sources from ProjectExplorer"
|
||||||
prefix: "../../../src/plugins/projectexplorer/"
|
prefix: "../../../src/plugins/projectexplorer/"
|
||||||
cpp.defines: base.concat("PROJECTEXPLORER_STATIC_LIBRARY")
|
|
||||||
files: [
|
files: [
|
||||||
"projectmacro.cpp",
|
"projectmacro.cpp",
|
||||||
"projectmacro.h",
|
"projectmacro.h",
|
||||||
@@ -809,7 +857,6 @@ QtcProduct {
|
|||||||
Group {
|
Group {
|
||||||
name: "sources from Debugger"
|
name: "sources from Debugger"
|
||||||
prefix: "../../../src/plugins/debugger/analyzer/"
|
prefix: "../../../src/plugins/debugger/analyzer/"
|
||||||
cpp.defines: outer.concat("DEBUGGER_STATIC_LIBRARY")
|
|
||||||
files: [
|
files: [
|
||||||
"diagnosticlocation.cpp",
|
"diagnosticlocation.cpp",
|
||||||
"diagnosticlocation.h",
|
"diagnosticlocation.h",
|
||||||
@@ -829,5 +876,5 @@ QtcProduct {
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user