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¶
- NAMEoptional, defaults to lower case name of the project
name to be given to the package
- FILENAMEoptional, defaults to
<NAME>.pc
file to be generated, including .pc extension
- TEMPLATEoptional, defaults to
${ECBUILD_CMAKE_DIR}/pkg-config.pc.in
template configuration file to use
This is useful to create customised pkg-config files.
- URLoptional, defaults to
${PROJECT_NAME}_URL
url of the package
- DESCRIPTIONoptional, defaults to
${PROJECT_NAME}_DESCRIPTION
description of the package
- LIBRARIESrequired
list of package libraries
- IGNORE_INCLUDE_DIRSoptional
list of include directories to ignore
- IGNORE_LIBRARIESoptional
list of libraries to ignore i.e. those are removed from
LIBRARIES
- VARIABLESoptional
list of additional CMake variables to export to the pkg-config file
- LANGUAGESoptional, 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()