ecbuild_pkgconfig

Create a pkg-config file for the current project.

ecbuild_pkgconfig( [ NAME <name> ]
                   [ FILENAME <filename> ]
                   [ TEMPLATE <template> ]
                   [ URL <url> ]
                   [ DESCRIPTION <description> ]
                   [ LIBRARIES <lib1> [ <lib2> ... ] ]
                   [ IGNORE_INCLUDE_DIRS <dir1> [ <dir2> ... ] ]
                   [ IGNORE_LIBRARIES <lib1> [ <lib2> ... ] ]
                   [ LANGUAGES <language1> [ <language2> ... ] ]
                   [ VARIABLES <variable1> [ <variable2> ... ] ]
                   [ NO_PRIVATE_INCLUDE_DIRS ] )

Options

NAME : optional, defaults to lower case name of the project
name to be given to the package
FILENAME : optional, defaults to <NAME>.pc
file to be generated, including .pc extension
TEMPLATE : optional, defaults to ${ECBUILD_CMAKE_DIR}/pkg-config.pc.in

template configuration file to use

This is useful to create customised pkg-config files.

URL : optional, defaults to ${PROJECT_NAME}_URL
url of the package
DESCRIPTION : optional, defaults to ${PROJECT_NAME}_DESCRIPTION
description of the package
LIBRARIES : required
list of package libraries
IGNORE_INCLUDE_DIRS : optional
list of include directories to ignore
IGNORE_LIBRARIES : optional
list of libraries to ignore i.e. those are removed from LIBRARIES
VARIABLES : optional
list of additional CMake variables to export to the pkg-config file
LANGUAGES : optional, defaults to all loaded languages
list of languages to use. Accepted languages: C CXX Fortran
NO_PRIVATE_INCLUDE_DIRS

do not add include directories of dependencies to Cflags

This is mainly useful for Fortran only packages, when only modules need to be added to Cflags.

Input variables

The following CMake variables are used as default values for some of the options listed above:

<PROJECT_NAME>_DESCRIPTION:
 package description
<PROJECT_NAME>_URL:
 package URL
<PROJECT_NAME>_VERSION:
 package version
<PROJECT_NAME>_GIT_SHA1:
 Git revision

Usage

It is good practice to provide a separate pkg-config file for each library a package exports. This can be achieved as follows:

foreach( _lib ${${PNAME}_LIBRARIES} )
  if( TARGET ${_lib} )
    ecbuild_pkgconfig( NAME ${_lib}
                       DESCRIPTION "..."
                       URL "..."
                       LIBRARIES ${_lib} )
  endif()
endforeach()