1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
commit 83f868ea8decbbe97891631fe142e84c883ee33d
Author: Ilya Tumaykin <itumaykin@gmail.com>
Date: Wed Jun 1 20:00:37 2016 +0300
Allow to build and run tests with a system copy of gtest (googletest)
Also add LIBS_UCHARDET to the mix only when uchardet is requested.
Closes #1923
Bug: http://devel.aegisub.org/ticket/1923
---
diff --git a/configure.ac b/configure.ac
index 856e38993..197d0a788 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,7 +144,7 @@ AS_IF([test x$enable_compiler_flags != xno], [
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing"
# For mac compiler which still stuck on c++98
- AC_CXX_FLAG([-std=c++11])
+ AC_CXX_FLAG([-std=c++14])
# -O* messes with debugging.
AS_IF([test x$enable_debug = xyes], [
diff --git a/tests/Makefile b/tests/Makefile
index 137430854..bafb59a0f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,24 +1,46 @@
include $(dir $(lastword $(MAKEFILE_LIST)))../header.mk
+WITH_SYSTEM_GTEST ?= no
+
+ifeq (no, $(WITH_SYSTEM_GTEST))
GTEST_ROOT ?= $(TOP)vendor/googletest
GTEST_FILE := ${GTEST_ROOT}/src/gtest-all
+GTEST_CPPFLAGS := -I$(GTEST_ROOT) -I$(GTEST_ROOT)/include
+GTEST_LIBS := $(LIBS_PTHREAD)
+else
+GTEST_CPPFLAGS := $(shell ${PKG_CONFIG} --cflags-only-I gtest)
+GTEST_LIBS := $(shell ${PKG_CONFIG} --libs gtest)
+endif
+
+GTEST_CXXFLAGS := $(CFLAGS_PTHREAD)
run_PCH := $(d)support/tests_pre.h
run_CPPFLAGS := -I$(TOP)libaegisub/include -I$(TOP) -I$(d)support \
- -I$(GTEST_ROOT) -I$(GTEST_ROOT)/include $(CPPFLAGS_BOOST) $(CFLAGS_LUA)
-run_CXXFLAGS := -Wno-unused-value -Wno-sign-compare
-run_LIBS := $(LIBS_BOOST) $(LIBS_ICU) $(LIBS_UCHARDET) $(LIBS_PTHREAD)
+ $(CPPFLAGS_BOOST) $(CFLAGS_LUA) $(GTEST_CPPFLAGS)
+run_CXXFLAGS := -Wno-unused-value -Wno-sign-compare $(GTEST_CXXFLAGS)
+run_LIBS := $(LIBS_BOOST) $(LIBS_ICU) $(LIBS_UCHARDET) $(LIBS_PTHREAD) $(GTEST_LIBS)
run_OBJ := \
$(patsubst %.cpp,%.o,$(wildcard $(d)tests/*.cpp)) \
$(d)support/main.o \
$(d)support/util.o \
- $(TOP)lib/libaegisub.a \
- $(GTEST_FILE).o
+ $(TOP)lib/libaegisub.a
+
+ifeq (yes, $(HAVE_UCHARDET))
+run_LIBS += $(LIBS_UCHARDET)
+endif
+
+ifeq (no, $(WITH_SYSTEM_GTEST))
+run_OBJ += $(GTEST_FILE).o
# This bit of goofiness is to make it only try to build the tests if google
# test can be found and silently skip it if not, by using $(wildcard) to check
# for file existence
PROGRAM += $(subst $(GTEST_FILE).cc,$(d)run,$(wildcard $(GTEST_FILE).cc))
+test: $(subst $(GTEST_FILE).cc,test-libaegisub,$(wildcard $(GTEST_FILE).cc))
+else
+PROGRAM += $(d)run
+test: test-libaegisub
+endif
ifeq (yes, $(BUILD_DARWIN))
run_LIBS += -framework ApplicationServices -framework Foundation
@@ -31,6 +53,4 @@ gtest_filter ?= *
test-libaegisub: $(d)run $(d)data
cd $(TOP)tests; ./run --gtest_filter="$(gtest_filter)"
-test: $(subst $(GTEST_FILE).cc,test-libaegisub,$(wildcard $(GTEST_FILE).cc))
-
include $(TOP)Makefile.target
|