aboutsummaryrefslogtreecommitdiff
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
parent64915e0291cd8ad00fbdf9526977961de8341368 (diff)
downloadextra-cmake-modules-5.41.0-rc1.tar.gz
extra-cmake-modules-5.41.0-rc1.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
-rw-r--r--modules/ECMGeneratePkgConfigFile.cmake22
-rw-r--r--tests/ECMGeneratePkgConfigFile/KF5CoreAddons.pc1
-rw-r--r--tests/ECMGeneratePkgConfigFile/KF5CoreAddons2.pc7
-rw-r--r--tests/ECMGeneratePkgConfigFile/KF5CoreAddons3.pc7
-rw-r--r--tests/ECMGeneratePkgConfigFile/metainfo_with_description.yaml21
-rw-r--r--tests/ECMGeneratePkgConfigFile/metainfo_with_empty_description.yaml21
-rw-r--r--tests/ECMGeneratePkgConfigFile/metainfo_without_description.yaml20
-rw-r--r--tests/ECMGeneratePkgConfigFile/run_test.cmake.config57
8 files changed, 154 insertions, 2 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}
diff --git a/tests/ECMGeneratePkgConfigFile/KF5CoreAddons.pc b/tests/ECMGeneratePkgConfigFile/KF5CoreAddons.pc
index 68e0004d..adfee6fe 100644
--- a/tests/ECMGeneratePkgConfigFile/KF5CoreAddons.pc
+++ b/tests/ECMGeneratePkgConfigFile/KF5CoreAddons.pc
@@ -1,5 +1,6 @@
Name: KF5CoreAddons
+Description: KF5CoreAddons test
Version: 5.43
Libs: -L/usr/lib -lKF5CoreAddons
Cflags: -I/usr/KCoreAddons
diff --git a/tests/ECMGeneratePkgConfigFile/KF5CoreAddons2.pc b/tests/ECMGeneratePkgConfigFile/KF5CoreAddons2.pc
new file mode 100644
index 00000000..132a7aaa
--- /dev/null
+++ b/tests/ECMGeneratePkgConfigFile/KF5CoreAddons2.pc
@@ -0,0 +1,7 @@
+
+Name: KF5CoreAddons2
+Description: Addons to QtCore
+Version: 5.43
+Libs: -L/usr/lib -lKF5CoreAddons2
+Cflags: -I/usr/KCoreAddons
+Requires: Qt5Core
diff --git a/tests/ECMGeneratePkgConfigFile/KF5CoreAddons3.pc b/tests/ECMGeneratePkgConfigFile/KF5CoreAddons3.pc
new file mode 100644
index 00000000..1f9d3457
--- /dev/null
+++ b/tests/ECMGeneratePkgConfigFile/KF5CoreAddons3.pc
@@ -0,0 +1,7 @@
+
+Name: KF5CoreAddons3
+Description: KF5CoreAddons3 library.
+Version: 5.43
+Libs: -L/usr/lib -lKF5CoreAddons3
+Cflags: -I/usr/KCoreAddons
+Requires: Qt5Core
diff --git a/tests/ECMGeneratePkgConfigFile/metainfo_with_description.yaml b/tests/ECMGeneratePkgConfigFile/metainfo_with_description.yaml
new file mode 100644
index 00000000..0c0d33ff
--- /dev/null
+++ b/tests/ECMGeneratePkgConfigFile/metainfo_with_description.yaml
@@ -0,0 +1,21 @@
+maintainer: mpyne
+description: Addons to QtCore
+tier: 1
+type: functional
+platforms:
+ - name: Linux
+ - name: FreeBSD
+ - name: Windows
+ - name: MacOSX
+ - name: Android
+portingAid: false
+deprecated: false
+release: true
+libraries:
+ - qmake: KCoreAddons
+ cmake: "KF5::CoreAddons"
+cmakename: KF5CoreAddons
+
+public_lib: true
+group: Frameworks
+subgroup: Tier 1
diff --git a/tests/ECMGeneratePkgConfigFile/metainfo_with_empty_description.yaml b/tests/ECMGeneratePkgConfigFile/metainfo_with_empty_description.yaml
new file mode 100644
index 00000000..c46465d1
--- /dev/null
+++ b/tests/ECMGeneratePkgConfigFile/metainfo_with_empty_description.yaml
@@ -0,0 +1,21 @@
+maintainer: mpyne
+description:
+tier: 1
+type: functional
+platforms:
+ - name: Linux
+ - name: FreeBSD
+ - name: Windows
+ - name: MacOSX
+ - name: Android
+portingAid: false
+deprecated: false
+release: true
+libraries:
+ - qmake: KCoreAddons
+ cmake: "KF5::CoreAddons"
+cmakename: KF5CoreAddons
+
+public_lib: true
+group: Frameworks
+subgroup: Tier 1
diff --git a/tests/ECMGeneratePkgConfigFile/metainfo_without_description.yaml b/tests/ECMGeneratePkgConfigFile/metainfo_without_description.yaml
new file mode 100644
index 00000000..b7f094c2
--- /dev/null
+++ b/tests/ECMGeneratePkgConfigFile/metainfo_without_description.yaml
@@ -0,0 +1,20 @@
+maintainer: mpyne
+tier: 1
+type: functional
+platforms:
+ - name: Linux
+ - name: FreeBSD
+ - name: Windows
+ - name: MacOSX
+ - name: Android
+portingAid: false
+deprecated: false
+release: true
+libraries:
+ - qmake: KCoreAddons
+ cmake: "KF5::CoreAddons"
+cmakename: KF5CoreAddons
+
+public_lib: true
+group: Frameworks
+subgroup: Tier 1
diff --git a/tests/ECMGeneratePkgConfigFile/run_test.cmake.config b/tests/ECMGeneratePkgConfigFile/run_test.cmake.config
index dad4369b..5885c97f 100644
--- a/tests/ECMGeneratePkgConfigFile/run_test.cmake.config
+++ b/tests/ECMGeneratePkgConfigFile/run_test.cmake.config
@@ -47,8 +47,63 @@ ecm_setup_version(5.43 VARIABLE_PREFIX KCOREADDONS
message(STATUS "Test 1: no optional arguments")
set(origfiles "${CMAKE_CURRENT_SOURCE_DIR}/KF5CoreAddons.pc")
-ecm_generate_pkgconfig_file(BASE_NAME KF5CoreAddons DEPS Qt5Core INCLUDE_INSTALL_DIR /usr/KCoreAddons FILENAME_VAR OutputFile)
+ecm_generate_pkgconfig_file(BASE_NAME KF5CoreAddons
+ DESCRIPTION "KF5CoreAddons test"
+ DEPS Qt5Core
+ INCLUDE_INSTALL_DIR /usr/KCoreAddons
+ FILENAME_VAR OutputFile)
compare_files(GENERATED ${OutputFile}
ORIGINALS ${origfiles})
file(REMOVE ${OutputFile})
+
+message(STATUS "Test2: no description parameter, metainfo.yaml with description found")
+set(origfiles "${CMAKE_CURRENT_SOURCE_DIR}/KF5CoreAddons2.pc")
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/metainfo_with_description.yaml
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/metainfo_with_description.yaml ${CMAKE_CURRENT_BINARY_DIR}/metainfo.yaml)
+
+ecm_generate_pkgconfig_file(BASE_NAME KF5CoreAddons2
+ DEPS Qt5Core
+ INCLUDE_INSTALL_DIR /usr/KCoreAddons
+ FILENAME_VAR OutputFile)
+
+compare_files(GENERATED ${OutputFile}
+ ORIGINALS ${origfiles})
+file(REMOVE ${OutputFile})
+file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/metainfo.yaml)
+
+message(STATUS "Test3: no description parameter, metainfo.yaml with empty description found")
+set(origfiles "${CMAKE_CURRENT_SOURCE_DIR}/KF5CoreAddons3.pc")
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/metainfo_with_empty_description.yaml
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/metainfo_with_empty_description.yaml ${CMAKE_CURRENT_BINARY_DIR}/metainfo.yaml)
+
+ecm_generate_pkgconfig_file(BASE_NAME KF5CoreAddons3
+ DEPS Qt5Core
+ INCLUDE_INSTALL_DIR /usr/KCoreAddons
+ FILENAME_VAR OutputFile)
+
+compare_files(GENERATED ${OutputFile}
+ ORIGINALS ${origfiles})
+file(REMOVE ${OutputFile})
+file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/metainfo.yaml)
+
+message(STATUS "Test4: no description parameter, metainfo.yaml without description")
+set(origfiles "${CMAKE_CURRENT_SOURCE_DIR}/KF5CoreAddons3.pc")
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/metainfo_without_description.yaml
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/metainfo_without_description.yaml ${CMAKE_CURRENT_BINARY_DIR}/metainfo.yaml)
+
+ecm_generate_pkgconfig_file(BASE_NAME KF5CoreAddons3
+ DEPS Qt5Core
+ INCLUDE_INSTALL_DIR /usr/KCoreAddons
+ FILENAME_VAR OutputFile)
+
+compare_files(GENERATED ${OutputFile}
+ ORIGINALS ${origfiles})
+file(REMOVE ${OutputFile})
+file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/metainfo.yaml)