aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt11
-rw-r--r--cmake/ProjInstallPath.cmake2
-rw-r--r--cmake/ProjUtilities.cmake31
-rwxr-xr-xtest/postinstall/test_pkg-config.sh5
-rwxr-xr-xtravis/install.sh1
5 files changed, 48 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7658aa8b..1f9cfafc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -282,3 +282,14 @@ endif()
set(docfiles COPYING NEWS AUTHORS)
install(FILES ${docfiles}
DESTINATION "${DOCDIR}")
+
+################################################################################
+# pkg-config support
+################################################################################
+if(UNIX OR MINGW)
+ configure_proj_pc()
+
+ install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/proj.pc
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+endif()
diff --git a/cmake/ProjInstallPath.cmake b/cmake/ProjInstallPath.cmake
index b7f7b821..fa67161e 100644
--- a/cmake/ProjInstallPath.cmake
+++ b/cmake/ProjInstallPath.cmake
@@ -40,6 +40,8 @@ else()
set(DEFAULT_INCLUDE_SUBDIR include)
set(DEFAULT_DOC_SUBDIR share/doc/proj)
set(DEFAULT_CMAKE_SUBDIR lib/cmake)
+ # Used for proj.pc
+ set(CMAKE_INSTALL_DATAROOTDIR share)
endif()
# Locations are changeable by user to customize layout of PROJ installation
diff --git a/cmake/ProjUtilities.cmake b/cmake/ProjUtilities.cmake
index 6f43edb5..f8688cd6 100644
--- a/cmake/ProjUtilities.cmake
+++ b/cmake/ProjUtilities.cmake
@@ -14,7 +14,8 @@
# Macros in this module:
#
# print_variable
-# proj_target_output_name:
+# proj_target_output_name
+# configure_proj_pc
#
################################################################################
@@ -60,3 +61,31 @@ function(proj_target_output_name TARGET_NAME OUTPUT_NAME)
set(${OUTPUT_NAME} ${TARGET_NAME}${SUFFIX} PARENT_SCOPE)
endfunction()
+
+#
+# Configure a pkg-config file proj.pc
+# See also ProjInstallPath.cmake
+#
+
+function(configure_proj_pc)
+ set(prefix "${CMAKE_INSTALL_PREFIX}")
+ set(exec_prefix "$\{prefix\}")
+ set(libdir "$\{exec_prefix\}/${PROJ_LIB_SUBDIR}")
+ set(includedir "$\{prefix\}/${PROJ_INCLUDE_SUBDIR}")
+ set(datarootdir "$\{prefix\}/${CMAKE_INSTALL_DATAROOTDIR}")
+ set(datadir "$\{datarootdir\}")
+ set(PACKAGE "proj")
+ set(VERSION ${PROJ_VERSION})
+ set(SQLITE3_LIBS -lsqlite3)
+ if(TIFF_ENABLED)
+ set(TIFF_LIBS -ltiff)
+ endif()
+ if(CURL_ENABLED)
+ set(CURL_LIBS -lcurl)
+ endif()
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/proj.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/proj.pc
+ @ONLY)
+endfunction()
diff --git a/test/postinstall/test_pkg-config.sh b/test/postinstall/test_pkg-config.sh
index 98c0815e..f9ae36c2 100755
--- a/test/postinstall/test_pkg-config.sh
+++ b/test/postinstall/test_pkg-config.sh
@@ -47,10 +47,13 @@ ERRORS=0
LDD_OUTPUT=$(ldd ./$PROGRAM | grep proj)
LDD_SUBSTR=$LD_LIBRARY_PATH/libproj.
+LDD_RPATH_SUBSTR=@rpath/libproj.
printf "Testing expected ldd output ... "
case "$LDD_OUTPUT" in
*$LDD_SUBSTR*)
- echo "passed" ;;
+ echo "passed (using path)" ;;
+ *$LDD_RPATH_SUBSTR*)
+ echo "passed (using rpath)" ;;
*)
ERRORS=$(($ERRORS + 1))
echo "failed: ldd output '$LDD_OUTPUT' does not contain '$LDD_SUBSTR'" ;;
diff --git a/travis/install.sh b/travis/install.sh
index 6426e1b3..a39323eb 100755
--- a/travis/install.sh
+++ b/travis/install.sh
@@ -112,6 +112,7 @@ if [ "$BUILD_NAME" != "linux_gcc8" -a "$BUILD_NAME" != "linux_gcc_32bit" ]; then
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
+ $TRAVIS_BUILD_DIR/test/postinstall/test_pkg-config.sh /tmp/proj_cmake_install
else
echo "Skipping test_cmake.sh test for $BUILD_NAME"
fi