diff options
| author | Mike Taves <mwtoews@gmail.com> | 2022-01-13 21:55:21 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-13 21:55:21 +1300 |
| commit | 69962fefc233ba06450b353073a2db4a9fce3ceb (patch) | |
| tree | 1c2fdc07d6172fc9f9d33c3d6615740bb6ad92c4 /test/postinstall | |
| parent | 0e26f598ef4b4930dcf3344cf6a430c984e62385 (diff) | |
| download | PROJ-69962fefc233ba06450b353073a2db4a9fce3ceb.tar.gz PROJ-69962fefc233ba06450b353073a2db4a9fce3ceb.zip | |
Specify CMAKE_INSTALL_RPATH for macOS; use -rpath LDFLAGS for tests (#3009)
Diffstat (limited to 'test/postinstall')
| -rw-r--r-- | test/postinstall/README.md | 2 | ||||
| -rw-r--r-- | test/postinstall/c_app/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/postinstall/c_app/Makefile.am | 2 | ||||
| -rw-r--r-- | test/postinstall/c_app/makefile.mak | 2 | ||||
| -rwxr-xr-x | test/postinstall/c_app/test_ldd.sh | 4 | ||||
| -rwxr-xr-x | test/postinstall/c_app/test_libpath.sh | 6 | ||||
| -rw-r--r-- | test/postinstall/common.cmake | 39 | ||||
| -rwxr-xr-x | test/postinstall/common.sh | 81 | ||||
| -rw-r--r-- | test/postinstall/cpp_app/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/postinstall/cpp_app/Makefile.am | 2 | ||||
| -rw-r--r-- | test/postinstall/cpp_app/makefile.mak | 2 | ||||
| -rwxr-xr-x | test/postinstall/cpp_app/test_ldd.sh | 4 | ||||
| -rwxr-xr-x | test/postinstall/cpp_app/test_libpath.sh | 6 | ||||
| -rwxr-xr-x | test/postinstall/test_autotools.sh | 8 | ||||
| -rwxr-xr-x | test/postinstall/test_cmake.bat | 2 | ||||
| -rwxr-xr-x | test/postinstall/test_cmake.sh | 6 | ||||
| -rwxr-xr-x | test/postinstall/test_pkg-config.sh | 7 |
17 files changed, 94 insertions, 83 deletions
diff --git a/test/postinstall/README.md b/test/postinstall/README.md index 3bda47b5..76d027c9 100644 --- a/test/postinstall/README.md +++ b/test/postinstall/README.md @@ -34,7 +34,7 @@ Two build modes are tested with each configure method: All configure methods share the same suite of tests for `c_app` and `cpp_app`: -- `test_ldd` - examines the shared object dependencies to see if "libproj" is found with the correct path (for `shared` build mode), or not listed as a dependency for builds with static libproj. +- `test_libpath` - examines the shared object dependencies to see if "libproj" is found with the correct path (for `shared` build mode), or not listed as a dependency for builds with static libproj. - `test_transform` - example coordinate transform to ensure basic functions work as expected. - `test_searchpath` - compares `searchpath` (from `proj_info()`) to either `datadir` via pkg-config or relative path `PROJ_DIR/../../../share/proj` via CMake. - `test_version` - compares PROJ version components from `proj_info()` to the version from pkg-config or CMake. diff --git a/test/postinstall/c_app/CMakeLists.txt b/test/postinstall/c_app/CMakeLists.txt index a493849b..a5ada471 100644 --- a/test/postinstall/c_app/CMakeLists.txt +++ b/test/postinstall/c_app/CMakeLists.txt @@ -28,7 +28,7 @@ endif() set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/..) include(common) -add_test_ldd(c_app proj) +add_test_libpath(c_app proj) add_test_transform(c_app) add_test_searchpath(c_app) add_test_version(c_app) diff --git a/test/postinstall/c_app/Makefile.am b/test/postinstall/c_app/Makefile.am index 356034ba..912c5431 100644 --- a/test/postinstall/c_app/Makefile.am +++ b/test/postinstall/c_app/Makefile.am @@ -3,7 +3,7 @@ c_app_SOURCES = c_app.c c_app_CFLAGS = $(PROJ_CFLAGS) c_app_LDADD = $(PROJ_LIBS) TESTS = \ - test_ldd.sh \ + test_libpath.sh \ test_transform.sh \ test_searchpath.sh \ test_version.sh diff --git a/test/postinstall/c_app/makefile.mak b/test/postinstall/c_app/makefile.mak index d6c1c8de..3e29d4b1 100644 --- a/test/postinstall/c_app/makefile.mak +++ b/test/postinstall/c_app/makefile.mak @@ -1,7 +1,7 @@ PROGRAM = c_app OBJECTS = $(addsuffix .o,$(PROGRAM)) TESTS = \ - test_ldd.sh \ + test_libpath.sh \ test_transform.sh \ test_searchpath.sh \ test_version.sh diff --git a/test/postinstall/c_app/test_ldd.sh b/test/postinstall/c_app/test_ldd.sh deleted file mode 100755 index 9750db16..00000000 --- a/test/postinstall/c_app/test_ldd.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. ../common.sh - -test_ldd c_app libproj diff --git a/test/postinstall/c_app/test_libpath.sh b/test/postinstall/c_app/test_libpath.sh new file mode 100755 index 00000000..57b3aa41 --- /dev/null +++ b/test/postinstall/c_app/test_libpath.sh @@ -0,0 +1,6 @@ +#!/bin/sh +. ../common.sh + +EXPECTED_LIBPATH="$(pkg-config proj --variable=libdir)" + +test_libpath c_app "${EXPECTED_LIBPATH}" libproj diff --git a/test/postinstall/common.cmake b/test/postinstall/common.cmake index 3a66444c..542fb1d6 100644 --- a/test/postinstall/common.cmake +++ b/test/postinstall/common.cmake @@ -2,39 +2,44 @@ include(CTest) -macro(add_test_ldd EXE) +macro(add_test_libpath EXE) set(EXEPATH ${CMAKE_BINARY_DIR}/${EXE}) + set(HAS_TOOL TRUE) if(APPLE) - set(LDD_CL "otool -L") - set(EXPECTED_LDD_CL_OUT "@rpath/libproj") + set(EXPECTED_SUBSTR "${CMAKE_PREFIX_PATH}/lib") elseif(UNIX) - set(LDD_CL "ldd") - set(EXPECTED_LDD_CL_OUT "${CMAKE_PREFIX_PATH}/lib/libproj") + set(EXPECTED_SUBSTR "${CMAKE_PREFIX_PATH}/lib/libproj") elseif(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") - set(LDD_CL "ldd") # Convert to Unix-style path execute_process( - COMMAND cygpath -u ${CMAKE_PREFIX_PATH}/bin/libproj - OUTPUT_VARIABLE EXPECTED_LDD_CL_OUT + COMMAND cygpath -u "${CMAKE_PREFIX_PATH}/bin/libproj" + OUTPUT_VARIABLE EXPECTED_SUBSTR OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + set(HAS_TOOL FALSE) endif() - if(LDD_CL) - add_test(NAME test_ldd - COMMAND sh -c "${LDD_CL} ${EXEPATH} | grep proj") + if(HAS_TOOL) + if(APPLE) + add_test(NAME test_libpath + COMMAND sh -c "otool -l ${EXEPATH} | grep -m1 \"${EXPECTED_SUBSTR}\"") + else() + add_test(NAME test_libpath + COMMAND sh -c "ldd ${EXEPATH} | grep -m1 proj") + endif() if($ENV{BUILD_MODE} STREQUAL "static") - set_tests_properties(test_ldd PROPERTIES + set_tests_properties(test_libpath PROPERTIES PASS_REGULAR_EXPRESSION "^$" - FAIL_REGULAR_EXPRESSION "${EXPECTED_LDD_CL_OUT};not found" + FAIL_REGULAR_EXPRESSION "${EXPECTED_SUBSTR};not found" ) else() - set_tests_properties(test_ldd PROPERTIES - PASS_REGULAR_EXPRESSION "${EXPECTED_LDD_CL_OUT}" + set_tests_properties(test_libpath PROPERTIES + PASS_REGULAR_EXPRESSION "${EXPECTED_SUBSTR}" FAIL_REGULAR_EXPRESSION "not found" ) endif() else() - add_test(NAME test_ldd COMMAND ${EXEPATH}) - set_tests_properties(test_ldd PROPERTIES SKIP_RETURN_CODE 1) + add_test(NAME test_libpath COMMAND ${EXEPATH}) + set_tests_properties(test_libpath PROPERTIES SKIP_RETURN_CODE 1) endif() endmacro() diff --git a/test/postinstall/common.sh b/test/postinstall/common.sh index 3bb5c080..8439f895 100755 --- a/test/postinstall/common.sh +++ b/test/postinstall/common.sh @@ -16,64 +16,59 @@ main_setup(){ echo "Second argument must be either shared (default) or static" exit 1 ;; esac - - if [ ${BUILD_MODE} = shared ]; then - case $(uname) in - MINGW* | MSYS*) - prefix=$(cygpath -u ${prefix}) - export LD_LIBRARY_PATH=${prefix}/bin - ;; - Darwin*) - export DYLD_LIBRARY_PATH=${prefix}/lib - export LDFLAGS="${LDFLAGS} -Wl,-rpath,${prefix}/lib" - ;; - *) - export LD_LIBRARY_PATH=${prefix}/lib - ;; - esac - fi } -test_ldd(){ - # usage: test_ldd ${PROGRAM} ${LIBNAME} - # use optional 'BUILD_MODE=static' to to pass if LIBNAME is not found - if [ ! $(which ldd) ]; then - UNAME=$(uname) - case ${UNAME} in - Darwin*) alias ldd="otool -L" ;; - *) - echo "no ldd equivalent found for UNAME=${UNAME}" - return 77 ;; # skip - esac - fi - if [ -n "${LD_LIBRARY_PATH}" ]; then - EXPECTED_LDD_SUBSTR="${LD_LIBRARY_PATH}/$2" - elif [ -n "${DYLD_LIBRARY_PATH}" ]; then - EXPECTED_LDD_SUBSTR="${DYLD_LIBRARY_PATH}/$2" - else - EXPECTED_LDD_SUBSTR=$2 - fi - printf "Testing expected ldd output " +test_libpath(){ + # usage: test_libpath ${PROGRAM} ${LIBPATH} ${LIBNAME} + # use optional 'BUILD_MODE=static' to pass if match is not found + UNAME=$(uname) + case ${UNAME} in + Darwin*) + USE_OTOOL=yes + EXPECTED_SUBSTR=$2 + ;; + MINGW* | MSYS*) + EXPECTED_SUBSTR=$(cygpath -u "$2/$3" | sed 's/\/lib\//\/bin\//') + ;; + Linux*) + EXPECTED_SUBSTR=$2/$3 + ;; + *) + echo "test_libpath not set-up for UNAME=${UNAME}" + return 77 # skip + ;; + esac + printf "Testing expected libpath output " if [ "x${BUILD_MODE}" = xstatic ]; then printf "not " fi - printf "containing '${EXPECTED_LDD_SUBSTR}' ... " - LDD_OUTPUT=$(ldd ./$1 | grep "$3") - case "${LDD_OUTPUT}" in + printf "containing '${EXPECTED_SUBSTR}' ... " + if [ "x${USE_OTOOL}" = xyes ]; then + CMD_OUTPUT=$(otool -l ./$1 | grep -m1 "$2") + else + CMD_OUTPUT=$(ldd ./$1 | grep -m1 "$3") + fi + case "${CMD_OUTPUT}" in *"not found"*) - echo "failed: ${LDD_OUTPUT}" + echo "failed: ${CMD_OUTPUT}" return 1 ;; - *${EXPECTED_LDD_SUBSTR}*) found=yes ;; + *${EXPECTED_SUBSTR}*) found=yes ;; *) found=no ;; esac if [ "x${BUILD_MODE}" = xstatic ]; then if [ "x${found}" = "xyes" ] ; then - echo "failed: ${LDD_OUTPUT}" + echo "failed: ${CMD_OUTPUT}" return 1 fi elif [ "x${found}" = "xno" ] ; then echo "failed:" - ldd ./$1 + if [ "x${USE_OTOOL}" = xyes ]; then + echo "otool -l ./$1:" + otool -l ./$1 + else + echo "ldd ./$1:" + ldd ./$1 + fi return 1 fi echo "passed" diff --git a/test/postinstall/cpp_app/CMakeLists.txt b/test/postinstall/cpp_app/CMakeLists.txt index 1f011082..467b6bdf 100644 --- a/test/postinstall/cpp_app/CMakeLists.txt +++ b/test/postinstall/cpp_app/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(cpp_app PRIVATE ${USE_PROJ_NAME}::proj) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/..) include(common) -add_test_ldd(cpp_app) +add_test_libpath(cpp_app) add_test_transform(cpp_app) add_test_searchpath(cpp_app) add_test_version(cpp_app) diff --git a/test/postinstall/cpp_app/Makefile.am b/test/postinstall/cpp_app/Makefile.am index 5451403a..eaf3decd 100644 --- a/test/postinstall/cpp_app/Makefile.am +++ b/test/postinstall/cpp_app/Makefile.am @@ -3,7 +3,7 @@ cpp_app_SOURCES = cpp_app.cpp cpp_app_CXXFLAGS = $(PROJ_CFLAGS) cpp_app_LDADD = $(PROJ_LIBS) TESTS = \ - test_ldd.sh \ + test_libpath.sh \ test_transform.sh \ test_searchpath.sh \ test_version.sh diff --git a/test/postinstall/cpp_app/makefile.mak b/test/postinstall/cpp_app/makefile.mak index 8d84785f..5c5f2505 100644 --- a/test/postinstall/cpp_app/makefile.mak +++ b/test/postinstall/cpp_app/makefile.mak @@ -1,7 +1,7 @@ PROGRAM = cpp_app OBJECTS = $(addsuffix .o,$(PROGRAM)) TESTS = \ - test_ldd.sh \ + test_libpath.sh \ test_transform.sh \ test_searchpath.sh \ test_version.sh diff --git a/test/postinstall/cpp_app/test_ldd.sh b/test/postinstall/cpp_app/test_ldd.sh deleted file mode 100755 index 2e8cd5ea..00000000 --- a/test/postinstall/cpp_app/test_ldd.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. ../common.sh - -test_ldd cpp_app libproj diff --git a/test/postinstall/cpp_app/test_libpath.sh b/test/postinstall/cpp_app/test_libpath.sh new file mode 100755 index 00000000..08222e66 --- /dev/null +++ b/test/postinstall/cpp_app/test_libpath.sh @@ -0,0 +1,6 @@ +#!/bin/sh +. ../common.sh + +EXPECTED_LIBPATH="$(pkg-config proj --variable=libdir)" + +test_libpath cpp_app "${EXPECTED_LIBPATH}" libproj diff --git a/test/postinstall/test_autotools.sh b/test/postinstall/test_autotools.sh index 3e088fac..28954c4d 100755 --- a/test/postinstall/test_autotools.sh +++ b/test/postinstall/test_autotools.sh @@ -3,8 +3,7 @@ # Post-install tests with autotools/pkg-config # # First required argument is the installed prefix, which -# is used to set PKG_CONFIG_PATH and -# LD_LIBRARY_PATH/DYLD_LIBRARY_PATH for shared builds +# is used to set PKG_CONFIG_PATH and rpath for shared. # Second argument is either shared (default) or static cd $(dirname $0) . ./common.sh @@ -19,8 +18,13 @@ else export PKG_CONFIG="pkg-config --static" ENABLE_STATIC_PROJ=yes fi + export PKG_CONFIG_PATH=${prefix}/lib/pkgconfig +if [ ${BUILD_MODE} = shared ]; then + export LDFLAGS="${LDFLAGS} -Wl,-rpath,$(pkg-config proj --variable=libdir)" +fi + autogen_configure_check_clean(){ set -e aclocal diff --git a/test/postinstall/test_cmake.bat b/test/postinstall/test_cmake.bat index 9576a4e9..fced8906 100755 --- a/test/postinstall/test_cmake.bat +++ b/test/postinstall/test_cmake.bat @@ -72,7 +72,7 @@ cmake -DCMAKE_BUILD_TYPE=Release ^ -DUSE_PROJ_NAME=%1 .. || Exit /B 1 cmake --build . --config Release || Exit /B 1 -ctest --output-on-failure -V -C Release || Exit /B 1 +ctest --output-on-failure -C Release || Exit /B 1 Cd .. Rd /s /q build diff --git a/test/postinstall/test_cmake.sh b/test/postinstall/test_cmake.sh index b95b0c02..15525593 100755 --- a/test/postinstall/test_cmake.sh +++ b/test/postinstall/test_cmake.sh @@ -3,8 +3,7 @@ # Post-install tests with CMake # # First required argument is the installed prefix, which -# is used to set CMAKE_PREFIX_PATH and -# LD_LIBRARY_PATH/DYLD_LIBRARY_PATH for shared builds +# is used to set CMAKE_PREFIX_PATH # Second argument is either shared (default) or static cd $(dirname $0) . ./common.sh @@ -12,6 +11,7 @@ main_setup $1 $2 echo "Running post-install tests with CMake (${BUILD_MODE})" + cmake_make_ctest(){ rm -rf build mkdir build @@ -19,7 +19,7 @@ cmake_make_ctest(){ cmake -DCMAKE_PREFIX_PATH=${prefix} -DUSE_PROJ_NAME=$1 .. VERBOSE=1 make - ctest --output-on-failure -V + ctest --output-on-failure cd .. rm -rf build diff --git a/test/postinstall/test_pkg-config.sh b/test/postinstall/test_pkg-config.sh index c417f99d..a9ccabce 100755 --- a/test/postinstall/test_pkg-config.sh +++ b/test/postinstall/test_pkg-config.sh @@ -3,8 +3,7 @@ # Post-install tests with pkg-config and a Makefile # # First required argument is the installed prefix, which -# is used to set PKG_CONFIG_PATH and -# LD_LIBRARY_PATH/DYLD_LIBRARY_PATH for shared builds +# is used to set PKG_CONFIG_PATH and rpath for shared. # Second argument is either shared (default) or static cd $(dirname $0) . ./common.sh @@ -14,6 +13,10 @@ echo "Running post-install tests with pkg-config (${BUILD_MODE})" export PKG_CONFIG_PATH=${prefix}/lib/pkgconfig +if [ ${BUILD_MODE} = shared ]; then + export LDFLAGS="${LDFLAGS} -Wl,-rpath,$(pkg-config proj --variable=libdir)" +fi + make_all_test_clean(){ set -e make -f makefile.mak clean |
