CMake's Pkg-config module findpkgconfig

Source: Internet
Author: User

Findpkgconfig

A pkg-config module for CMake.

CMake's Pkg-config module.

Finds the Pkg-config executable and add the Pkg_check_modules () and Pkg_search_module () commands.

Locate the Pkg-config execution file and add the Pkg_check_modules () and Pkg_search_module () commands.

In order to find the Pkg-config executable, it uses the pkg_config_executable variable or the PKG_CONFIG environment Varia BLE first.

To find the Pkg-config execution file, first use the pkg_config_executable variable or pkg_config environment variable.

Pkg_check_modules

Checks for all the given modules.

Check all the given modules.

Pkg_check_modules (<PREFIX> [REQUIRED] [QUIET]
[No_cmake_path] [No_cmake_environment_path]
<MODULE> [<module>]*]

When the REQUIRED argument is set, the macros would fail with a error when module (s) could isn't be found.

If the REQUIRED parameter is set, the macro errors and fails when the module is not found.

When the QUIET argument is set, no status messages would be printed.

If the QUIET parameter is set, the status information is not printed.

By default, if cmake_minimum_required_version are 3.1 or later, or if Pkg_config_use_cmake_prefix_path is set, the CMAKE_PR Efix_path, Cmake_framework_path, and Cmake_appbundle_path cache and environment variables would be added to Pkg-config sear CH path. The No_cmake_path and No_cmake_environment_path arguments disable this behavior for the cache variables and the Environmen t variables, respectively.

By default, if Cmake_minimum_required_version is 3.1 or later, or if the Pkg_config_use_cmake_prefix_path is set, the following cache and environment variables will be added to the Pkg-config Find paths: Cmake_prefix_path,cmake_framework_path and Cmake_appbundle_path. The No_cmake_path and No_cmake_environment_path parameters disable the behavior of the above-mentioned cache variables and environment variables, respectively.

It sets the following variables:

The following variables are set:

Pkg_config_found ... if Pkg-config executable was FOUND
Pkg_config_executable pathname of the Pkg-config program
Pkg_config_version_string. The VERSION of the Pkg-config program found
(Since CMake 2.8.8)

For the following variables, the sets of values exist; First one is the common one and have the the given PREFIX. The second set contains flags which is given out when Pkg-config is called with the--static option.

The following 2 series values exist: the first series is common and begins with the given PREFIX. The second series contains the given symbol when Pkg-config is called with the--static option.

<xprefix>_found. Set to 1 if module (s) exist
<xprefix>_libraries. Only the LIBRARIES (w/o the '-l ')
<xprefix>_library_dirs. The paths of the libraries (w/o the '-l ')
<XPREFIX>_LDFLAGS ALL required linker flags
<xprefix>_ldflags_other ... all other linker flags
<xprefix>_include_dirs. The '-I ' preprocessor flags (w/o the '-I ')
<xprefix>_cflags all required CFLAGS
<xprefix>_cflags_other. The other compiler flags

<XPREFIX> = <PREFIX> for common case
<XPREFIX> = <prefix>_static for STATIC linking

There is some special variables whose prefix depends on the count of given modules. When there are only one module, <PREFIX> stays unchanged. When there is multiple modules, the prefix would be changed to <PREFIX>_<MODNAME>:

There are some special variable prefixes that depend on the number of modules given. ,<prefix> remains the same when only one module is given. When there are multiple modules, the prefix changes to <PREFIX>_<MODNAME>:

<xprefix>_version ... VERSION of the module
<xprefix>_prefix ... prefix-directory of the module
<xprefix>_includedir ... include-dir of the module
<xprefix>_libdir ... lib-dir of the module

<XPREFIX> = <PREFIX> When | modules| = = 1, Else
<XPREFIX> = <PREFIX>_<MODNAME>

A <MODULE> parameter can have the following formats:
The <MODULE> parameter can be in the following format:

{ModName} ... matches any version
{modname}>={version} ... at least VERSION <VERSION> is required
{modname}={version} ... exactly VERSION <VERSION> is required
{modname}<={version} ... modules must not be newer than <VERSION>

Examples
For example

Pkg_check_modules (GLIB2 glib-2.0)

Pkg_check_modules (GLIB2 glib-2.0>=2.10)

Requires at least version 2.10 of GLIB2 and defines e.g. glib2_version=2.10.3

A version that requires GLIB2 is at least 2.10 and defines items such as glib2_version=2.10.3

Pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)

Requires both Glib2 and gtk2, and defines e.g. foo_glib-2.0_version=2.10.3 and foo_gtk+-2.0_version=2.8.20

Request GLIB2 and GTK2, and define such as foo_glib-2.0_version=2.10.3 and foo_gtk+-2.0_version=2.8.20

Pkg_check_modules (XRENDER REQUIRED XRENDER)

Defines for example:
Definition Examples:

Xrender_libraries=xrender; X11 "
Xrender_static_libraries=xrender; X11;pthread; Xau; Xdmcp

Pkg_search_module

Same as Pkg_check_modules (), but instead it checks for given modules and uses the first working one.

Like Pkg_check_modules (), but instead it examines a given module and uses the first work.

Pkg_search_module (<PREFIX> [REQUIRED] [QUIET]
[No_cmake_path] [No_cmake_environment_path]
<MODULE> [<module>]*]

Examples
For example

Pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)

Pkg_config_executable

Path to the Pkg-config executable.

The path to the Pkg-config execution file.

Pkg_config_use_cmake_prefix_path

Whether pkg_check_modules () and Pkg_search_module () should add the paths in Cmake_prefix_path, Cmake_framework_path, and C Make_appbundle_path cache and environment variables to pkg-config search PATH.

Whether Pkg_check_modules () and Pkg_search_module () should add paths to Cmake_prefix_path, Cmake_framework_path, and Cmake_appbundle_path Cache and environment variables to the Pkg-config search path.

If this variable are not set, this behavior is enabled by default if Cmake_minimum_required_version is 3.1 or later, DISABL Ed otherwise.

If the variable is not set, the behavior is enabled by default on Cmake_minimum_required_version for 3.1 or later, otherwise disabled.

CMake's Pkg-config module findpkgconfig

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.