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

CMake: add support for pkg-config #2547

Merged
merged 4 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,24 @@ endif()
set(docfiles COPYING NEWS AUTHORS)
install(FILES ${docfiles}
DESTINATION "${DOCDIR}")

################################################################################
# pkg-config support
################################################################################
if(UNIX)
Copy link
Contributor

Choose a reason for hiding this comment

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

I just had nothing but MinGW (MSYS2) today, and guess what... There are other pkg-config files here. I successfully tested build/install with:

if(UNIX OR MINGW)

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, possibly this one too, as some of these paths are set from GNUInstallDirs

if(UNIX)
include(GNUInstallDirs)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. I don't see a difference in proj.pc when I change ProjInstallPath.cmake.
And I wouldn't delay PROJ 8.0.0 for MINGW pkgconfig.

Default config for MinGW, generator Ninja:

prefix=c:/OSGeo4W
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
datarootdir=${prefix}/share
datadir=${prefix}/share/proj

Name: PROJ
Description: Coordinate transformation software library
Requires:
Version: 8.0.0
Libs: -L${libdir} -lproj
Libs.private: -lsqlite3 -ltiff -lcurl -lstdc++
Cflags: -I${includedir}

Looks good to me.

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}/cmake/proj.pc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
@ONLY)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
1 change: 1 addition & 0 deletions cmake/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EXTRA_DIST = CMakeLists.txt \
ProjVersion.cmake \
policies.cmake \
proj_config.cmake.in \
proj.pc.cmake.in \
project-config-version.cmake.in \
project-config.cmake.in \
FindSqlite3.cmake
Expand Down
14 changes: 14 additions & 0 deletions cmake/proj.pc.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@LIBDIR@
includedir=${prefix}/@INCLUDEDIR@
datarootdir=${prefix}/share
datadir=${prefix}/@DATADIR@

Name: PROJ
Description: Coordinate transformation software library
Requires:
Version: @PROJ_VERSION@
Libs: -L${libdir} -lproj
Libs.private: @SQLITE3_LIBS@ @TIFF_LIBS@ @CURL_LIBS@ -lstdc++
Cflags: -I${includedir}
5 changes: 4 additions & 1 deletion test/postinstall/test_pkg-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'" ;;
Expand Down
1 change: 1 addition & 0 deletions travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down