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

Conversation

mwtoews
Copy link
Member

@mwtoews mwtoews commented Feb 24, 2021

This addresses part of #2546 to install a pkg-config file.

@mwtoews
Copy link
Member Author

mwtoews commented Feb 24, 2021

Does anyone feel qualified to review this? Nevertheless, the CMake-generated set-up passes post-install tests with Linux and macOS.

One observation discovered here between autotools vs CMake installs on macOS is that the dynamic library via CMake has the relative reference @rpath/libproj.22.dylib (via otool -L) whereas the autotools library uses an absolute path '/tmp/proj_cmake_install/lib/libproj.22.dylib`. This shouldn't be surprising given the CMake options, but is a difference to note.

@rouault
Copy link
Member

rouault commented Feb 24, 2021

not a cmake expert, but that looks very reasonable to me

@dg0yt
Copy link
Contributor

dg0yt commented Feb 25, 2021

Given the syntax of the root proj.pc.in, did you conside creating a function (i.e. scope) that sets the variables needed to configure that file, instead of introducing a separate cmake/proj.pc.cmake.in? But changes should be rare, so redundancy may be acceptable.

CMakeLists.txt Outdated

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
DESTINATION lib/pkgconfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess Debian will be unhappy about this rule. Due to multi-arch, proj.pc resides in /usr/lib/x86_64-linux-gnu/pkgconfig/. In a GNUInstallDirs context, the destination would probably be ${CMAKE_INSTALL_LIBDIR}/pkgconfig.

@kbevers
Copy link
Member

kbevers commented Feb 25, 2021

Is everyone happy with this PR in its current state?

CMakeLists.txt Outdated
################################################################################
# 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.

@mwtoews
Copy link
Member Author

mwtoews commented Feb 25, 2021

Given the syntax of the root proj.pc.in, did you conside creating a function (i.e. scope) that sets the variables needed to configure that file

Sure, I'll give this a "go"...

@dg0yt
Copy link
Contributor

dg0yt commented Feb 25, 2021

LGTM.

$ diff former-mingw current-mingw
6c6
< datadir=${prefix}/share/proj
---
> datadir=${datarootdir}/proj

@mwtoews
Copy link
Member Author

mwtoews commented Feb 25, 2021

This last update, which uses the same proj.pc.in file as by autotools, creates an identical proj.pc file for a given prefix.

@mwtoews mwtoews merged commit 3d22f6f into OSGeo:master Feb 25, 2021
@kbevers kbevers added this to the 8.0.0 milestone Feb 25, 2021
@sikmir sikmir mentioned this pull request Aug 17, 2021
9 tasks
@mwtoews mwtoews deleted the cmake-pkg-config branch March 4, 2022 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants