aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2019-02-03 02:57:38 -0500
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2019-02-04 05:24:04 -0500
commit561a6639c45a4e35a638c2e87869c5991fc7d69e (patch)
tree16046d9063c32e8bdf40b216e35e3c4a41829fdd
parent322493235696097b94294f5f466a32f015a95626 (diff)
downloadPROJ-561a6639c45a4e35a638c2e87869c5991fc7d69e.tar.gz
PROJ-561a6639c45a4e35a638c2e87869c5991fc7d69e.zip
Allow building against external GTest with autotools.
-rw-r--r--configure.ac32
-rw-r--r--test/Makefile.am5
-rw-r--r--test/unit/Makefile.am16
3 files changed, 39 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac
index 180f34d9..f0caf4d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -319,18 +319,40 @@ if test x"$SQLITE3_CHECK" != x"yes" ; then
fi
dnl ---------------------------------------------------------------------------
+dnl Check for external Google Test
+dnl ---------------------------------------------------------------------------
+
+AC_ARG_WITH(external-gtest,
+ AS_HELP_STRING([--with-external-gtest],
+ [Whether to use external Google Test]),,)
+
+if test "x$with_external_gtest" == "xyes" ; then
+ AC_MSG_RESULT([using external GTest.])
+ PKG_CHECK_MODULES([GTEST], [gtest >= 1.8.0])
+else
+ AC_MSG_RESULT([using internal GTest.])
+ GTEST_CFLAGS="-I\$(top_srcdir)/test/googletest/include"
+ GTEST_LIBS="\$(top_builddir)/test/googletest/libgtest.la"
+fi
+AM_CONDITIONAL(USE_EXTERNAL_GTEST, [test "x$with_external_gtest" == "xyes"])
+AC_SUBST(GTEST_CFLAGS,$GTEST_CFLAGS)
+AC_SUBST(GTEST_LIBS,$GTEST_LIBS)
+
+dnl ---------------------------------------------------------------------------
dnl Generate files
dnl ---------------------------------------------------------------------------
AC_CONFIG_FILES([Makefile cmake/Makefile src/Makefile include/Makefile include/proj/Makefile include/proj/internal/Makefile
test/Makefile test/cli/Makefile test/gie/Makefile test/gigs/Makefile test/unit/Makefile
- test/googletest/Makefile test/googletest/include/Makefile
- test/googletest/include/gtest/Makefile
- test/googletest/include/gtest/internal/Makefile
- test/googletest/include/gtest/internal/custom/Makefile
- test/googletest/src/Makefile
man/Makefile man/man1/Makefile man/man3/Makefile data/Makefile
jniwrap/Makefile jniwrap/org.osgeo.proj/Makefile jniwrap/org.osgeo.proj/org/Makefile jniwrap/org.osgeo.proj/org/proj4/Makefile])
+if ! test "x$with_external_gtest" = "xyes" ; then
+ AC_CONFIG_FILES([test/googletest/Makefile test/googletest/include/Makefile
+ test/googletest/include/gtest/Makefile
+ test/googletest/include/gtest/internal/Makefile
+ test/googletest/include/gtest/internal/custom/Makefile
+ test/googletest/src/Makefile])
+fi
AC_CONFIG_FILES([data/install], [chmod +x data/install])
AC_CONFIG_FILES([proj.pc])
diff --git a/test/Makefile.am b/test/Makefile.am
index b65e9785..fa2c1e80 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,4 +7,7 @@ EXTRA_DIST = CMakeLists.txt
# libtestmain_la_LDFLAGS = -no-undefined
# libtestmain_la_SOURCES = test_main.cpp
-SUBDIRS = cli googletest . gie gigs unit
+if !USE_EXTERNAL_GTEST
+MAYBE_GTEST = googletest
+endif
+SUBDIRS = cli $(MAYBE_GTEST) . gie gigs unit
diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am
index c0a05997..210bdc90 100644
--- a/test/unit/Makefile.am
+++ b/test/unit/Makefile.am
@@ -4,7 +4,7 @@ EXTRA_DIST = CMakeLists.txt
noinst_HEADERS = gtest_include.h
-AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_srcdir)/test -I$(top_srcdir)/test/googletest/include @SQLITE3_CFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_srcdir)/test @GTEST_CFLAGS@ @SQLITE3_CFLAGS@
AM_CXXFLAGS = @CXX_WFLAGS@ @NO_ZERO_AS_NULL_POINTER_CONSTANT_FLAG@
PROJ_LIB ?= ../../data
@@ -19,43 +19,43 @@ noinst_PROGRAMS += gie_self_tests
noinst_PROGRAMS += include_proj_h_from_c
pj_transform_test_SOURCES = pj_transform_test.cpp main.cpp
-pj_transform_test_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la
+pj_transform_test_LDADD = ../../src/libproj.la @GTEST_LIBS@
pj_transform_test-check: pj_transform_test
PROJ_LIB=$(PROJ_LIB) ./pj_transform_test
pj_phi2_test_SOURCES = pj_phi2_test.cpp main.cpp
-pj_phi2_test_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la
+pj_phi2_test_LDADD = ../../src/libproj.la @GTEST_LIBS@
pj_phi2_test-check: pj_phi2_test
./pj_phi2_test
proj_errno_string_test_SOURCES = proj_errno_string_test.cpp main.cpp
-proj_errno_string_test_LDADD= ../../src/libproj.la ../../test/googletest/libgtest.la
+proj_errno_string_test_LDADD= ../../src/libproj.la @GTEST_LIBS@
proj_errno_string_test-check: proj_errno_string_test
./proj_errno_string_test
proj_angular_io_test_SOURCES = proj_angular_io_test.cpp main.cpp
-proj_angular_io_test_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la
+proj_angular_io_test_LDADD = ../../src/libproj.la @GTEST_LIBS@
proj_angular_io_test-check: proj_angular_io_test
./proj_angular_io_test
proj_context_test_SOURCES = proj_context_test.cpp main.cpp
-proj_context_test_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la
+proj_context_test_LDADD = ../../src/libproj.la @GTEST_LIBS@
proj_context_test-check: proj_context_test
./proj_context_test
test_cpp_api_SOURCES = test_util.cpp test_common.cpp test_crs.cpp test_metadata.cpp test_io.cpp test_operation.cpp test_datum.cpp test_factory.cpp test_c_api.cpp main.cpp
-test_cpp_api_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la @SQLITE3_LIBS@
+test_cpp_api_LDADD = ../../src/libproj.la @GTEST_LIBS@ @SQLITE3_LIBS@
test_cpp_api-check: test_cpp_api
PROJ_LIB=$(PROJ_LIB) ./test_cpp_api
gie_self_tests_SOURCES = gie_self_tests.cpp main.cpp
-gie_self_tests_LDADD = ../../src/libproj.la ../../test/googletest/libgtest.la @SQLITE3_LIBS@
+gie_self_tests_LDADD = ../../src/libproj.la @GTEST_LIBS@ @SQLITE3_LIBS@
gie_self_tests-check: gie_self_tests
PROJ_LIB=$(PROJ_LIB) ./gie_self_tests