Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve checks for external deps #1246

Merged
merged 4 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 30 additions & 36 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -309,56 +309,50 @@ dnl ---------------------------------------------------------------------------
dnl Check for sqlite3 library and binary
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(sqlite3-include,
[ --with-sqlite3-include=ARG sqlite3 include directory],,,)

if test "x$with_sqlite3_include" = "x" ; then
SQLITE3_FLAGS=""
if test -z "`uname | grep Darwin`" ; then
AC_CHECK_HEADERS([sqlite3.h])
if test "$ac_cv_header_sqlite3_h" = "no" ; then
AC_MSG_ERROR([Please install sqlite3 development package.])
fi
fi
else
SQLITE3_FLAGS="-I$with_sqlite3_include"
fi
AC_SUBST(SQLITE3_FLAGS,$SQLITE3_FLAGS)

AC_ARG_WITH(sqlite3-ldflags,
[ --with-sqlite3-ldflags=ARG sqlite3 link flags (i.e. -L/xxx -lsqlite3)],,,)

SQLITE3_LDFLAGS=""
if test "x$with_sqlite3_ldflags" = "x" ; then
AC_CHECK_LIB(sqlite3,sqlite3_open,SQLITE3_LIB_FOUND=yes,SQLITE3_LIB_FOUND=no,)
if test x"$SQLITE3_LIB_FOUND" != x"yes"; then
AC_MSG_ERROR([Please install sqlite3 development package.])
fi
SQLITE3_LDFLAGS="-lsqlite3"
else
SQLITE3_LDFLAGS="$with_sqlite3_ldflags"
fi
AC_SUBST(SQLITE3_LDFLAGS,$SQLITE3_LDFLAGS)

PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.7])
AC_SUBST(SQLITE3_CFLAGS,$SQLITE3_CFLAGS)
AC_SUBST(SQLITE3_LIBS,$SQLITE3_LIBS)

AC_CHECK_PROG(SQLITE3_CHECK,sqlite3,yes)
if test x"$SQLITE3_CHECK" != x"yes" ; then
AC_MSG_ERROR([Please install sqlite3 binary.])
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])
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TESTS = geodtest
check_PROGRAMS = geodtest

AM_CPPFLAGS = -DPROJ_LIB=\"$(pkgdatadir)\" \
-DMUTEX_@MUTEX_SETTING@ @JNI_INCLUDE@ -I$(top_srcdir)/include @SQLITE3_FLAGS@
-DMUTEX_@MUTEX_SETTING@ @JNI_INCLUDE@ -I$(top_srcdir)/include @SQLITE3_CFLAGS@
AM_CXXFLAGS = @CXX_WFLAGS@ @FLTO_FLAG@ -DPROJ_COMPILATION

include_HEADERS = proj.h proj_experimental.h proj_constants.h proj_api.h geodesic.h \
Expand Down Expand Up @@ -45,7 +45,7 @@ geodtest_LDADD = libproj.la
lib_LTLIBRARIES = libproj.la

libproj_la_LDFLAGS = -no-undefined -version-info 14:1:1
libproj_la_LIBADD = @SQLITE3_LDFLAGS@
libproj_la_LIBADD = @SQLITE3_LIBS@

libproj_la_SOURCES = \
pj_list.h proj_internal.h proj_math.h \
Expand Down
5 changes: 4 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# CMake configuration for PROJ unit tests

option(USE_EXTERNAL_GTEST "Compile against external GTest" OFF)

if (USE_EXTERNAL_GTEST)

message(STATUS "Using external GTest")
find_package(GTest 1.8.0)
Copy link
Contributor

@dg0yt dg0yt Feb 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this supposed to work? The Gtest configuration file exports prefixed targets, e.g. GTest::gtest. But the targets below link unprefixed targets, e.g. gtest. Thus the build rules do not pick up the include directories etc. carried by the target.
So IMO the build rules need to use the prefix, and for consistency, a find_package with the explicit internal path should be added to the else branch (internal GTest).

BTW it wouldn't hurt to declare this REQUIRED.

BTW 1.8.0 will not work with MinGW. 1.8.1 is fixed, google/googletest#721.

BTW later in this file there is a test commented as "ph_phi2_test not compatible of a .dll build". The surrounding tests needs to use WIN32 instead of MSVC, because its not compatible with MinGW, too.

I can prepare a PR with these changes if desired:

  • find_package and prefix corrections
  • googletest 1.8.1
  • ph_phi2_test correction

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can prepare a PR with these changes if desired

Please do. But be aware that I am preparing a release candidate tomorrow so you need to work fast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried it? I just tried prefixing them and it doesn't understand it (with GTest 1.8.1.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried it? I just tried prefixing them and it doesn't understand it (with GTest 1.8.1.)

Yes, I tried with USE_EXTERNAL_GTEST=ON and CMake 3.11 or so.

Did you check the command line how the tests are compiled? I couldn't spot the include directories before the change. I guess it works for you because you have GTest in the compiler's standard directories. But these are not always the right ones for cmake, depending on CMAKE_FIND_... configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean CMake (3.12.1) doesn't configure. It's true that everything here is in a standard directory though, for the working build.

If you open a PR, I can try out what you mean.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #1265.


else (USE_EXTERNAL_GTEST)

message(STATUS "Using internal GTest")

# FIXME: Deal with our old-school CMakeLists.txt behaving badly
set(_save_c_flags "${CMAKE_C_FLAGS}")
set(_save_cxx_flags "${CMAKE_CXX_FLAGS}")
Expand Down Expand Up @@ -47,6 +58,8 @@ set(CMAKE_CXX_FLAGS "${_save_cxx_flags}")
unset(_save_c_flags)
unset(_save_cxx_flags)

endif(USE_EXTERNAL_GTEST)

#
# Build PROJ unit tests
#
Expand Down
16 changes: 8 additions & 8 deletions test/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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_FLAGS@
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
Expand All @@ -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_LDFLAGS@
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_LDFLAGS@
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
Expand Down
8 changes: 4 additions & 4 deletions travis/mingw32/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ ln -s /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll $HOME/.wine/drive_c/windo
# build sqlite3
wget https://sqlite.org/2018/sqlite-autoconf-3250100.tar.gz
tar xzf sqlite-autoconf-3250100.tar.gz
(cd sqlite-autoconf-3250100 && CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld ./configure --host=x86_64-w64-mingw32 --prefix=/tmp/proj_autoconf_install && make -j3 && make install)
ln -s /tmp/proj_autoconf_install/bin/libsqlite3-0.dll $HOME/.wine/drive_c/windows
(cd sqlite-autoconf-3250100 && CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld ./configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 && make -j3 && sudo make install)
ln -s /usr/x86_64-w64-mingw32/bin/libsqlite3-0.dll $HOME/.wine/drive_c/windows

# prepare build files
./autogen.sh
# autoconf build
mkdir build_autoconf
cd build_autoconf
CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld ../configure --host=x86_64-w64-mingw32 --with-sqlite3_include=/tmp/proj_autoconf_install/include --with-sqlite3_ldflags="-L/tmp/proj_autoconf_install/lib -lsqlite3" --prefix=/tmp/proj_autoconf_install
CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld ../configure --host=x86_64-w64-mingw32 --prefix=/tmp/proj_autoconf_install
make -j3
make install
make dist-all
Expand All @@ -37,7 +37,7 @@ cd ..
# autoconf build with grids
mkdir build_autoconf_grids
cd build_autoconf_grids
CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld ../configure --host=x86_64-w64-mingw32 --with-sqlite3_include=/tmp/proj_autoconf_install/include --with-sqlite3_ldflags="-L/tmp/proj_autoconf_install/lib -lsqlite3" --prefix=/tmp/proj_autoconf_install_nad
CC="ccache x86_64-w64-mingw32-gcc" CXX="ccache x86_64-w64-mingw32-g++" LD=x86_64-w64-mingw32-ld ../configure --host=x86_64-w64-mingw32 --prefix=/tmp/proj_autoconf_install_nad
make -j3
make install
find /tmp/proj_autoconf_install_nad
Expand Down