cburstedde / p4est

The "p4est" forest-of-octrees library

Home Page:www.p4est.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

about pkgconfig file naming

pkestene opened this issue · comments

Description

Currently in p4est and libsc, the pkgconfig filename are suffixed with ${git_version}

A question and a proposition:
First I'd like to ask if there is a strong requirement to have that suffix ?
I'd prefer to have p4est.pc versus p4est-${git_version}.pc
I'll explain why just below.

Proposed solution

One simple solution could be to simply add symbolic link p4est.pc -> p4est-2.8.5.pc in the install directory.

Why ?

The main reason behind this change, is that a downstream cmake-based project that want to use p4est, without having a strong requirement on the version of p4est (just a minimal version), would probably do something like that:

# let say we require to use at least p4est version 2.8.5
set(P4EST_MINIMAL_VERSION 2.8.5)

# first try to detect P4ESTConfig.cmake somewhere in the CMAKE_PREFIX_PATH
# if found, we're ready to go using target P4EST::P4EST
find_package(P4EST ${P4EST_MINIMAL_VERSION} CONFIG QUIET)
if(P4EST_FOUND)
  message(STATUS "P4EST was found with find_package, with version ${P4EST_VERSION}")
endif()

# if not found, we may try to detect p4est through **pkgconfig** (an autotools based build of p4est will at least provide it)
if(NOT P4EST_FOUND)
  # use pkgconfig
  find_package(PkgConfig REQUIRED)
  pkg_check_modules(PC_P4EST QUIET IMPORTED_TARGET p4est-2.8.5>=${P4EST_MINIMAL_VERSION}) # <======= here we need to use the pkgconfig basename 
  if(PC_P4EST_FOUND)
    message(STATUS "P4EST was found with pkgconfig, with version ${PC_P4EST_VERSION}")
    add_library(P4EST::P4EST ALIAS PkgConfig::PC_P4EST)
  endif()
endif()

The last arg of pkg_check_modules is p4est-2.8.5>=${P4EST_MINIMAL_VERSION}; p4est here is the basename of the pkgconfig file; it feels strange having to use e.g. p4est-2.8.5.pc here instead of p4est.pc because it means the downstream project can only detect exactly version 2.8.5, but not all the version above. And we have to somehow hard code the version that will be available on the platform, not any version above the requirement.

The version information is anyway contained inside the pkgconfig file.

Would you agree on adding the symlink ?

This sounds all very reasonable.

Related question: what do you think about the contents of our pkgconfig files. Are they ok and sufficiently similar between cmake and autotools?

That's a good question. Let me come back later. I'm currently checking different libsc config w/ or w/o json, zlib,.. static/dynamic, just to make sure that everything is still ok from p4est side.
I think a small adjustment is needed in p4est regarding json actually.

see #209 which add pkgconfig support

Thanks! Do you think this is resolved?

this is ok on my side.