aboutsummaryrefslogtreecommitdiff
path: root/modules/ECMGeneratePkgConfigFile.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ECMGeneratePkgConfigFile.cmake')
-rw-r--r--modules/ECMGeneratePkgConfigFile.cmake37
1 files changed, 34 insertions, 3 deletions
diff --git a/modules/ECMGeneratePkgConfigFile.cmake b/modules/ECMGeneratePkgConfigFile.cmake
index 2fb45c83..99d26ada 100644
--- a/modules/ECMGeneratePkgConfigFile.cmake
+++ b/modules/ECMGeneratePkgConfigFile.cmake
@@ -16,7 +16,7 @@ projects.
ecm_generate_pkgconfig_file(BASE_NAME <baseName>
[LIB_NAME <libName>]
- [DEPS "<dep> [<dep> [...]]"]
+ [DEPS [PRIVATE|PUBLIC] <dep> [[PRIVATE|PUBLIC] <dep> [...]]]
[FILENAME_VAR <filename_variable>]
[INCLUDE_INSTALL_DIR <dir>]
[LIB_INSTALL_DIR <dir>]
@@ -31,6 +31,13 @@ find the module.
it will default to the ``BASE_NAME``. That means the ``LIB_NAME`` will be set
as the name field as well as the library to link to.
+``DEPS`` is the list of libraries required by this library. Libraries that are
+not exposed to applications should be marked with ``PRIVATE``. The default
+is ``PUBLIC``, but note that according to the
+`Guide to pkg-config <https://people.freedesktop.org/~dbn/pkg-config-guide.html>`
+marking dependencies as private is usually preferred. The ``PUBLIC`` and
+``PRIVATE`` keywords are supported since 5.89.0.
+
``FILENAME_VAR`` is specified with a variable name. This variable will
receive the location of the generated file will be set, within the build
directory. This way it can be used in case some processing is required. See
@@ -130,7 +137,24 @@ function(ECM_GENERATE_PKGCONFIG_FILE)
set(PKGCONFIG_TARGET_BASENAME ${EGPF_BASE_NAME})
set(PKGCONFIG_TARGET_LIBNAME ${EGPF_LIB_NAME})
if (DEFINED EGPF_DEPS)
- string(REPLACE ";" " " PKGCONFIG_TARGET_DEPS "${EGPF_DEPS}")
+ # convert the dependencies to a list
+ string(REPLACE " " ";" EGPF_DEPS "${EGPF_DEPS}")
+ foreach(EGPF_DEP ${EGPF_DEPS})
+ if("${EGPF_DEP}" STREQUAL "")
+ elseif("${EGPF_DEP}" STREQUAL "PRIVATE")
+ set(private_deps ON)
+ elseif("${EGPF_DEP}" STREQUAL "PUBLIC")
+ unset(private_deps)
+ else()
+ if(private_deps)
+ list(APPEND PKGCONFIG_TARGET_DEPS_PRIVATE "${EGPF_DEP}")
+ else()
+ list(APPEND PKGCONFIG_TARGET_DEPS "${EGPF_DEP}")
+ endif()
+ endif()
+ endforeach()
+ list(JOIN PKGCONFIG_TARGET_DEPS " " PKGCONFIG_TARGET_DEPS)
+ list(JOIN PKGCONFIG_TARGET_DEPS_PRIVATE " " PKGCONFIG_TARGET_DEPS_PRIVATE)
endif ()
if(IS_ABSOLUTE "${EGPF_INCLUDE_INSTALL_DIR}")
set(PKGCONFIG_TARGET_INCLUDES "${EGPF_INCLUDE_INSTALL_DIR}")
@@ -153,7 +177,7 @@ function(ECM_GENERATE_PKGCONFIG_FILE)
set(${EGPF_FILENAME_VAR} ${PKGCONFIG_FILENAME} PARENT_SCOPE)
endif()
- file(WRITE ${PKGCONFIG_FILENAME}
+ set(PKGCONFIG_CONTENT
"
prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=\${prefix}
@@ -168,6 +192,13 @@ Cflags: -I${PKGCONFIG_TARGET_INCLUDES} ${PKGCONFIG_TARGET_DEFINES}
Requires: ${PKGCONFIG_TARGET_DEPS}
"
)
+ if(PKGCONFIG_TARGET_DEPS_PRIVATE)
+ set(PKGCONFIG_CONTENT
+"${PKGCONFIG_CONTENT}Requires.private: ${PKGCONFIG_TARGET_DEPS_PRIVATE}
+"
+ )
+ endif()
+ file(WRITE ${PKGCONFIG_FILENAME} "${PKGCONFIG_CONTENT}")
if(EGPF_INSTALL)
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")