aboutsummaryrefslogtreecommitdiff
path: root/modules/ECMGeneratePkgConfigFile.cmake
diff options
context:
space:
mode:
authorChristophe Giboudeaux <christophe@krop.fr>2017-11-29 16:31:42 +0100
committerChristophe Giboudeaux <christophe@krop.fr>2017-11-30 08:42:14 +0100
commitfd60f2b893d0b07f96f0fd715109cbd8d4e66140 (patch)
tree943e0ff49b4ed2a8b28d3907b3d0ef56ebd427e6 /modules/ECMGeneratePkgConfigFile.cmake
parent64915e0291cd8ad00fbdf9526977961de8341368 (diff)
downloadextra-cmake-modules-fd60f2b893d0b07f96f0fd715109cbd8d4e66140.tar.gz
extra-cmake-modules-fd60f2b893d0b07f96f0fd715109cbd8d4e66140.tar.bz2
Add the description tag to the generated pkgconfig filesv5.41.0-rc1v5.41.0
Summary: pkgconfig complains when the .pc file doesn't have a description. eg: $ pkg-config Baloo Package 'Baloo' has no Description: field With this change, if the DESCRIPTION parameter is not used, ECM_GENERATE_PKGCONFIG_FILE will : - First look if there's a metainfo.yaml file and get the description from there - If the file doesn't exist, or if the description tag is empty or non-existent, create a description based on the LIB_NAME value Test Plan: Tests added & pass Reviewers: dfaure, apol Reviewed By: dfaure Subscribers: #frameworks, #build_system Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D9056
Diffstat (limited to 'modules/ECMGeneratePkgConfigFile.cmake')
-rw-r--r--modules/ECMGeneratePkgConfigFile.cmake22
1 files changed, 21 insertions, 1 deletions
diff --git a/modules/ECMGeneratePkgConfigFile.cmake b/modules/ECMGeneratePkgConfigFile.cmake
index 11f043d8..09d7e2b4 100644
--- a/modules/ECMGeneratePkgConfigFile.cmake
+++ b/modules/ECMGeneratePkgConfigFile.cmake
@@ -16,6 +16,7 @@
# [INCLUDE_INSTALL_DIR <dir>]
# [LIB_INSTALL_DIR <dir>]
# [DEFINES -D<variable=value>...]
+# [DESCRIPTION <library description>]
# [INSTALL])
#
# ``BASE_NAME`` is the name of the module. It's the name projects will use to
@@ -42,6 +43,10 @@
# ``DEFINES`` is a list of preprocessor defines that it is recommended users of
# the library pass to the compiler when using it.
#
+# ``DESCRIPTION`` describes what this library is. If it's not specified, CMake
+# will first try to get the description from the metainfo.yaml file or will
+# create one based on ``LIB_NAME``.
+#
# ``INSTALL`` will cause the module to be installed to the ``pkgconfig``
# subdirectory of ``LIB_INSTALL_DIR``, unless the ``ECM_PKGCONFIG_INSTALL_DIR``
# cache variable is set to something different. Note that the first call to
@@ -66,6 +71,8 @@
# )
#
# Since 1.3.0.
+# ``DESCRIPTION`` available since 5.1.41
+#
#=============================================================================
# Copyright 2014 Aleix Pol Gonzalez <aleixpol@kde.org>
@@ -96,7 +103,7 @@
function(ECM_GENERATE_PKGCONFIG_FILE)
set(options INSTALL)
- set(oneValueArgs BASE_NAME LIB_NAME FILENAME_VAR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
+ set(oneValueArgs BASE_NAME LIB_NAME FILENAME_VAR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR DESCRIPTION)
set(multiValueArgs DEPS DEFINES)
cmake_parse_arguments(EGPF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -132,6 +139,17 @@ function(ECM_GENERATE_PKGCONFIG_FILE)
set(EGPF_LIB_INSTALL_DIR "lib")
endif()
endif()
+ if(NOT EGPF_DESCRIPTION)
+ if(EXISTS ${CMAKE_SOURCE_DIR}/metainfo.yaml)
+ file(STRINGS "${CMAKE_SOURCE_DIR}/metainfo.yaml" _EGPF_METAINFO_DESCRIPTION_STRING REGEX "^description:.*$")
+ if(_EGPF_METAINFO_DESCRIPTION_STRING)
+ string(REGEX REPLACE "^description:[ ]*(.*)" "\\1" EGPF_DESCRIPTION ${_EGPF_METAINFO_DESCRIPTION_STRING})
+ endif()
+ endif()
+ if("${EGPF_DESCRIPTION}" STREQUAL "")
+ set(EGPF_DESCRIPTION "${EGPF_LIB_NAME} library.")
+ endif()
+ endif()
set(PKGCONFIG_TARGET_BASENAME ${EGPF_BASE_NAME})
set(PKGCONFIG_TARGET_LIBNAME ${EGPF_LIB_NAME})
@@ -148,6 +166,7 @@ function(ECM_GENERATE_PKGCONFIG_FILE)
else()
set(PKGCONFIG_TARGET_LIBS "${CMAKE_INSTALL_PREFIX}/${EGPF_LIB_INSTALL_DIR}")
endif()
+ set(PKGCONFIG_TARGET_DESCRIPTION "${EGPF_DESCRIPTION}")
set(PKGCONFIG_TARGET_DEFINES "")
if(EGPF_DEFINES)
set(PKGCONFIG_TARGET_DEFINES "${EGPF_DEFINE}")
@@ -161,6 +180,7 @@ function(ECM_GENERATE_PKGCONFIG_FILE)
file(WRITE ${PKGCONFIG_FILENAME}
"
Name: ${PKGCONFIG_TARGET_LIBNAME}
+Description: ${PKGCONFIG_TARGET_DESCRIPTION}
Version: ${PROJECT_VERSION}
Libs: -L${CMAKE_INSTALL_PREFIX}/${EGPF_LIB_INSTALL_DIR} -l${PKGCONFIG_TARGET_LIBNAME}
Cflags: ${PKGCONFIG_TARGET_INCLUDES} ${PKGCONFIG_TARGET_DEFINES}