aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2020-03-21 14:16:00 +1300
committerGitHub <noreply@github.com>2020-03-21 14:16:00 +1300
commitb76acd354ca376194fb1fb682e5347dbf2e20f8d (patch)
tree2112c2a945ab8470373bbc1539b5d5e01c686885
parent56b0d6c5066205be5a046b6a999681b9197246bf (diff)
downloadPROJ-b76acd354ca376194fb1fb682e5347dbf2e20f8d.tar.gz
PROJ-b76acd354ca376194fb1fb682e5347dbf2e20f8d.zip
Add post-install checks for CMake and Autotools/pkg-config (#2077)
* Checks CMake's find_package(PROJ) and find_package(PROJ4) * Checks pkg-config used with a Makefile (Linux and macOS only) * Use proj.h / libproj with a simple 'testappprojinfo'
-rw-r--r--appveyor.yml3
-rwxr-xr-xtest/postinstall/test_cmake.bat40
-rwxr-xr-xtest/postinstall/test_cmake.sh43
-rwxr-xr-xtest/postinstall/test_pkg-config.sh83
-rw-r--r--test/postinstall/testappprojinfo/CMakeLists.txt58
-rw-r--r--test/postinstall/testappprojinfo/Makefile15
-rw-r--r--test/postinstall/testappprojinfo/testappprojinfo.c19
-rwxr-xr-xtravis/install.sh28
8 files changed, 282 insertions, 7 deletions
diff --git a/appveyor.yml b/appveyor.yml
index f6616653..c34c935f 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -24,7 +24,7 @@ build_script:
# update vcpkg
- cmd: |
cd "C:\Tools\vcpkg"
- git pull
+ git pull > nul
.\bootstrap-vcpkg.bat
cd %APPVEYOR_BUILD_FOLDER%
- vcpkg install sqlite3[core,tool]:"%platform%"-windows
@@ -52,6 +52,7 @@ test_script:
- cd %PROJ_BUILD%
- ctest -V -C Release
- set PATH=%PROJ_DIR%\bin;%PATH%
+ - call %APPVEYOR_BUILD_FOLDER%\test\postinstall\test_cmake.bat %PROJ_DIR%
- proj
deploy: off
diff --git a/test/postinstall/test_cmake.bat b/test/postinstall/test_cmake.bat
new file mode 100755
index 00000000..d2e7baaf
--- /dev/null
+++ b/test/postinstall/test_cmake.bat
@@ -0,0 +1,40 @@
+@echo off
+:: Post-install tests with CMake
+::
+:: First required argument is the installed prefix, which
+:: is used to set CMAKE_PREFIX_PATH
+
+echo Running post-install tests with CMake
+
+set CMAKE_PREFIX_PATH=%1
+if not defined CMAKE_PREFIX_PATH (
+ echo First positional argument CMAKE_PREFIX_PATH required
+ exit /B 1
+)
+
+echo CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%
+
+cd %~dp0
+
+cd testappprojinfo
+del /f /q build 2> nul
+
+:: Check CMake project name PROJ
+md build
+cd build
+cmake -G "%VS_FULL%" -DCMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH% -DUSE_PROJ_NAME=PROJ .. || exit /B 2
+cmake --build . --config Release || exit /B 3
+ctest --build-config Release -VV || exit /B 4
+cd ..
+del /f /q build
+
+:: Check legacy CMake project name PROJ4
+md build
+cd build
+cmake -G "%VS_FULL%" -DCMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH% -DUSE_PROJ_NAME=PROJ4 .. || exit /B 2
+cmake --build . --config Release || exit /B 3
+ctest --build-config Release -VV || exit /B 4
+cd ..
+del /f /q build
+
+cd ..
diff --git a/test/postinstall/test_cmake.sh b/test/postinstall/test_cmake.sh
new file mode 100755
index 00000000..e72af7c7
--- /dev/null
+++ b/test/postinstall/test_cmake.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Post-install tests with CMake
+#
+# First required argument is the installed prefix, which
+# is used to set CMAKE_PREFIX_PATH
+
+set -e
+
+echo "Running post-install tests with CMake"
+
+CMAKE_PREFIX_PATH=$1
+if [ -z "$CMAKE_PREFIX_PATH" ]; then
+ echo "First positional argument CMAKE_PREFIX_PATH required"
+ exit 1
+fi
+
+echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH"
+
+cd $(dirname $0)
+
+cd testappprojinfo
+rm -rf build
+
+# Check CMake project name PROJ
+mkdir build
+cd build
+cmake -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DUSE_PROJ_NAME=PROJ -DCMAKE_VERBOSE_MAKEFILE=ON ..
+cmake --build .
+ctest -VV .
+cd ..
+rm -rf build
+
+# Check legacy CMake project name PROJ4
+mkdir build
+cd build
+cmake -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DUSE_PROJ_NAME=PROJ4 -DCMAKE_VERBOSE_MAKEFILE=ON ..
+cmake --build .
+ctest -VV .
+cd ..
+rm -rf build
+
+cd ..
diff --git a/test/postinstall/test_pkg-config.sh b/test/postinstall/test_pkg-config.sh
new file mode 100755
index 00000000..fc7fb8b7
--- /dev/null
+++ b/test/postinstall/test_pkg-config.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# Post-install tests with pkg-config
+#
+# First required argument is the installed prefix, which
+# is used to set PKG_CONFIG_PATH and LD_LIBRARY_PATH
+
+set -e
+
+echo "Running post-install tests with pkg-config"
+
+prefix=$1
+if [ -z "$prefix" ]; then
+ echo "First positional argument to the the installed prefix is required"
+ exit 1
+fi
+
+export PKG_CONFIG_PATH=$prefix/lib/pkgconfig
+export LD_LIBRARY_PATH=$prefix/lib
+
+echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
+
+PKG_CONFIG_MODVERSION=$(pkg-config proj --modversion)
+echo "pkg-config proj --modversion: $PKG_CONFIG_MODVERSION"
+PKG_CONFIG_DATADIR=$(pkg-config proj --variable=datadir)
+echo "pkg-config proj --variable=datadir: $PKG_CONFIG_DATADIR"
+
+UNAME=$(uname)
+case $UNAME in
+ Darwin*)
+ alias ldd="otool -L" ;;
+ Linux*)
+ ;;
+ *)
+ echo "no ldd equivalent found for UNAME=$UNAME"
+ exit 1 ;;
+esac
+
+cd $(dirname $0)
+
+PROGRAM=testappprojinfo
+cd $PROGRAM
+make
+
+# Run tests from shell, count any errors
+ERRORS=0
+
+LDD_OUTPUT=$(ldd ./$PROGRAM | grep proj)
+LDD_SUBSTR=$LD_LIBRARY_PATH/libproj.
+printf "Testing expected ldd output ... "
+case "$LDD_OUTPUT" in
+ *$LDD_SUBSTR*)
+ echo "passed" ;;
+ *)
+ ERRORS=$(($ERRORS + 1))
+ echo "failed: ldd output '$LDD_OUTPUT' does not contain '$LDD_SUBSTR'" ;;
+esac
+
+SEARCHPATH_OUTPUT=$(./$PROGRAM -s)
+printf "Testing expected searchpath/datadir ... "
+case "$SEARCHPATH_OUTPUT" in
+ *$PKG_CONFIG_DATADIR*)
+ echo "passed" ;;
+ *)
+ ERRORS=$(($ERRORS + 1))
+ echo "failed: searchpath '$SEARCHPATH_OUTPUT' does not contain '$PKG_CONFIG_DATADIR'" ;;
+esac
+
+VERSION_OUTPUT=$(./$PROGRAM -v)
+printf "Testing expected version ... "
+case "$VERSION_OUTPUT" in
+ $PKG_CONFIG_MODVERSION)
+ echo "passed" ;;
+ *)
+ ERRORS=$(($ERRORS + 1))
+ echo "failed: '$VERSION_OUTPUT' != '$PKG_CONFIG_MODVERSION'" ;;
+esac
+
+make clean
+
+cd ..
+
+exit $ERRORS
diff --git a/test/postinstall/testappprojinfo/CMakeLists.txt b/test/postinstall/testappprojinfo/CMakeLists.txt
new file mode 100644
index 00000000..2405bc8c
--- /dev/null
+++ b/test/postinstall/testappprojinfo/CMakeLists.txt
@@ -0,0 +1,58 @@
+cmake_minimum_required(VERSION 3.5)
+project(testappprojinfo LANGUAGES C)
+
+set(USE_PROJ_NAME "PROJ"
+ CACHE STRING "Either PROJ (default) or PROJ4")
+
+find_package(${USE_PROJ_NAME})
+
+# Show some target properties
+get_cmake_property(_variableNames VARIABLES)
+list(SORT _variableNames)
+foreach(_variableName ${_variableNames})
+ string(REGEX MATCH "^${USE_PROJ_NAME}_" _matched ${_variableName})
+ if(NOT ${_matched} STREQUAL "")
+ message(STATUS "${_variableName}=${${_variableName}}")
+ endif()
+endforeach()
+
+add_executable(testappprojinfo testappprojinfo.c)
+target_link_libraries(testappprojinfo ${${USE_PROJ_NAME}_LIBRARIES})
+
+include(CTest)
+
+if(APPLE)
+ set(LDD_CL "otool -L")
+ set(EXPECTED_LDD_CL_OUT "@rpath/libproj")
+elseif(UNIX)
+ set(LDD_CL "ldd")
+ set(EXPECTED_LDD_CL_OUT "${CMAKE_PREFIX_PATH}/lib/libproj")
+endif()
+
+if(LDD_CL)
+ add_test(NAME test_ldd
+ COMMAND sh -c "${LDD_CL} ${CMAKE_BINARY_DIR}/testappprojinfo | grep proj")
+ set_tests_properties(test_ldd PROPERTIES
+ PASS_REGULAR_EXPRESSION ${EXPECTED_LDD_CL_OUT}
+ )
+else()
+ add_test(NAME test_ldd COMMAND testappprojinfo)
+ set_tests_properties(test_ldd PROPERTIES SKIP_RETURN_CODE 1)
+endif()
+
+# data directory property not available, so recreate one
+get_filename_component(EXPECTED_DATADIR
+ "${${USE_PROJ_NAME}_DIR}/../../../share/proj" ABSOLUTE)
+if(WIN32)
+ # Match each '/' with either '\' or '/'
+ string(REPLACE "/" "[\\/]" EXPECTED_DATADIR ${EXPECTED_DATADIR})
+endif()
+add_test(NAME test_searchpath COMMAND testappprojinfo -s)
+set_tests_properties(test_searchpath PROPERTIES
+ PASS_REGULAR_EXPRESSION "${EXPECTED_DATADIR}"
+)
+
+add_test(NAME test_version COMMAND testappprojinfo -v)
+set_tests_properties(test_version PROPERTIES
+ PASS_REGULAR_EXPRESSION "${${USE_PROJ_NAME}_VERSION}"
+)
diff --git a/test/postinstall/testappprojinfo/Makefile b/test/postinstall/testappprojinfo/Makefile
new file mode 100644
index 00000000..98c47f28
--- /dev/null
+++ b/test/postinstall/testappprojinfo/Makefile
@@ -0,0 +1,15 @@
+PROGRAM = testappprojinfo
+OBJECTS = $(addsuffix .o,$(PROGRAM))
+
+override CFLAGS += -g -Wall -Werror $(shell pkg-config proj --cflags)
+override LDFLAGS += $(shell pkg-config proj --libs)
+
+all: $(PROGRAM)
+
+$(PROGRAM): $(OBJECTS)
+ $(CC) -o $@ $< $(LDFLAGS)
+
+clean:
+ $(RM) $(PROGRAM) $(OBJECTS)
+
+.PHONY: clean
diff --git a/test/postinstall/testappprojinfo/testappprojinfo.c b/test/postinstall/testappprojinfo/testappprojinfo.c
new file mode 100644
index 00000000..64b5d665
--- /dev/null
+++ b/test/postinstall/testappprojinfo/testappprojinfo.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <proj.h>
+
+int main(int argc, char *argv[]) {
+ PJ_INFO info;
+ info = proj_info();
+ if(argc == 2 && argv[1][0] == '-') {
+ switch(argv[1][1]) {
+ case 's':
+ printf("%s\n", info.searchpath);
+ return(0);
+ case 'v':
+ printf("%d.%d.%d\n", info.major, info.minor, info.patch);
+ return(0);
+ }
+ }
+ printf("Use option -v or -s\n");
+ return(1);
+}
diff --git a/travis/install.sh b/travis/install.sh
index 701eef21..8a434264 100755
--- a/travis/install.sh
+++ b/travis/install.sh
@@ -12,10 +12,10 @@ if test "x${NPROC}" = "x"; then
NPROC=2;
fi
echo "NPROC=${NPROC}"
+export MAKEFLAGS="-j ${NPROC}"
# prepare build files
./autogen.sh
-TOP_DIR=$PWD
# autoconf build
mkdir build_autoconf
@@ -36,19 +36,24 @@ mkdir build_autoconf
cd build_autoconf
../configure --prefix=/tmp/proj_autoconf_install_from_dist_all
-make -j${NPROC}
+make
if [ "$(uname)" == "Linux" -a -f src/.libs/libproj.so ]; then
if objdump -TC "$1" | grep "elf64-x86-64">/dev/null; then
echo "Checking exported symbols..."
- ${TOP_DIR}/scripts/dump_exported_symbols.sh src/.libs/libproj.so > /tmp/got_symbols.txt
- diff -u ${TOP_DIR}/scripts/reference_exported_symbols.txt /tmp/got_symbols.txt || (echo "Difference(s) found in exported symbols. If intended, refresh scripts/reference_exported_symbols.txt with 'scripts/dump_exported_symbols.sh src/.libs/libproj.so > scripts/reference_exported_symbols.txt'"; exit 1)
+ $TRAVIS_BUILD_DIR/scripts/dump_exported_symbols.sh src/.libs/libproj.so > /tmp/got_symbols.txt
+ diff -u $TRAVIS_BUILD_DIR/scripts/reference_exported_symbols.txt /tmp/got_symbols.txt || (echo "Difference(s) found in exported symbols. If intended, refresh scripts/reference_exported_symbols.txt with 'scripts/dump_exported_symbols.sh src/.libs/libproj.so > scripts/reference_exported_symbols.txt'"; exit 1)
fi
fi
make check
make install
find /tmp/proj_autoconf_install_from_dist_all
+if [ $BUILD_NAME = "linux_gcc" ] || [ $BUILD_NAME = "osx" ]; then
+ $TRAVIS_BUILD_DIR/test/postinstall/test_pkg-config.sh /tmp/proj_autoconf_install_from_dist_all
+else
+ echo "Skipping test_pkg-config.sh test for $BUILD_NAME"
+fi
/tmp/proj_autoconf_install_from_dist_all/bin/projinfo EPSG:32631 -o PROJJSON -q > out.json
cat out.json
@@ -85,6 +90,12 @@ if [ $TRAVIS_OS_NAME != "osx" ]; then
mv /tmp/proj_autoconf_install_from_dist_all /tmp/proj_autoconf_install_from_dist_all_renamed/subdir
LD_LIBRARY_PATH=/tmp/proj_autoconf_install_from_dist_all_renamed/subdir/lib /tmp/proj_autoconf_install_from_dist_all_renamed/subdir/bin/projsync --source-id ? --dry-run --system-directory || /bin/true
LD_LIBRARY_PATH=/tmp/proj_autoconf_install_from_dist_all_renamed/subdir/lib /tmp/proj_autoconf_install_from_dist_all_renamed/subdir/bin/projsync --source-id ? --dry-run --system-directory 2>/dev/null | grep "Downloading from https://cdn.proj.org into /tmp/proj_autoconf_install_from_dist_all_renamed/subdir/share/proj"
+ sed -i '1cprefix=/tmp/proj_autoconf_install_from_dist_all_renamed/subdir' /tmp/proj_autoconf_install_from_dist_all_renamed/subdir/lib/pkgconfig/proj.pc
+ if [ $BUILD_NAME = "linux_gcc" ]; then
+ $TRAVIS_BUILD_DIR/test/postinstall/test_pkg-config.sh /tmp/proj_autoconf_install_from_dist_all_renamed/subdir
+ else
+ echo "Skipping test_pkg-config.sh test for $BUILD_NAME"
+ fi
fi
if [ "$BUILD_NAME" != "linux_gcc8" ]; then
@@ -93,10 +104,15 @@ if [ "$BUILD_NAME" != "linux_gcc8" ]; then
mkdir build_cmake
cd build_cmake
cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/proj_cmake_install
- VERBOSE=1 make -j${NPROC}
+ VERBOSE=1 make
make install
ctest
find /tmp/proj_cmake_install
+ if [ $BUILD_NAME = "linux_gcc" ] || [ $BUILD_NAME = "osx" ]; then
+ $TRAVIS_BUILD_DIR/test/postinstall/test_cmake.sh /tmp/proj_cmake_install
+ else
+ echo "Skipping test_cmake.sh test for $BUILD_NAME"
+ fi
cd ..
if [ $TRAVIS_OS_NAME != "osx" ]; then
@@ -121,7 +137,7 @@ if [ "$BUILD_NAME" != "linux_gcc8" ]; then
else
./configure
fi
- make -j${NPROC}
+ make
make check
if [ "$BUILD_NAME" != "linux_clang" ]; then