Cmake Study Notes (5)

Source: Internet
Author: User

In cmake Study Notes (3), I simply learned the find_package model mode and learned something about cmakecache in cmake Study Notes (4. However, with this knowledge, you still cannot understand how to use the cmakelists file in pyside. Next, we will continue to learn about the config mode and package configure file of find_package.

Config mode of find_package

When the find_package command is used in cmakelists.txt, the module mode is enabled first:

  • Search for the find <package>. cmake file in the cmake_module_path path and cmake installation path.

If the finder is not found, the config mode is started:

  • The configuration file <Name> config. cmake or <lower-case-Name>-config. cmake will be searched in the following path

<Prefix>/

(W)

<Prefix>/(cmake | cmake )/

(W)

<Prefix>/<Name> */

(W)

<Prefix>/<Name> */(cmake | cmake )/

(W)

<Prefix>/(share | Lib)/cmake/<Name> */

(U)

<Prefix>/(share | Lib)/<Name> */

(U)

<Prefix>/(share | Lib)/<Name> */(cmake | cmake )/

(U)

  • For find_package parameters and rules, see Manual
<Name> config. cmake

This file must at least provide the header file path and library file information. For example, apiextractorconfig. cmake is used in the next example in Windows:

# - try to find APIEXTRACTOR#  APIEXTRACTOR_INCLUDE_DIR   - Directories to include to use APIEXTRACTOR#  APIEXTRACTOR_LIBRARIES     - Files to link against to use APIEXTRACTORSET(APIEXTRACTOR_INCLUDE_DIR "D:/shiboken/dist/include/apiextractor")if(MSVC)    SET(APIEXTRACTOR_LIBRARY "D:/shiboken/dist/lib/apiextractor.lib")elseif(WIN32)    SET(APIEXTRACTOR_LIBRARY "D:/shiboken/dist/bin/apiextractor.dll")else()    SET(APIEXTRACTOR_LIBRARY "D:/shiboken/dist/lib/apiextractor.dll")endif()

This file is generated through the configure_file mechanism. Let's look at the apiextractorconfig. cmake. In file:

SET(APIEXTRACTOR_INCLUDE_DIR "@[email protected]/include/[email protected][email protected]")if(MSVC)    SET(APIEXTRACTOR_LIBRARY "@[email protected]/@[email protected]@[email protected]@[email protected]")elseif(WIN32)    SET(APIEXTRACTOR_LIBRARY "@[email protected]/bin/@[email protected]@[email protected]@[email protected]@[email protected]")else()    SET(APIEXTRACTOR_LIBRARY "@[email protected]/@[email protected]@[email protected]@[email protected]@[email protected]")endif()

Corresponding command (variable definition skipped)

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ApiExtractorConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ApiExtractorConfig.cmake" @ONLY)
<Name> configversion. cmake

Check whether apiextractorconfigversion. cmake. In matches the version:

set(PACKAGE_VERSION @[email protected])if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )   set(PACKAGE_VERSION_COMPATIBLE FALSE)else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )   set(PACKAGE_VERSION_COMPATIBLE TRUE)   if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")      set(PACKAGE_VERSION_EXACT TRUE)   endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )

Set the following variables.

Package_version

Complete version string

Package_version_exact

If the exact match is true

Package_version_compatible

If compatibility is true

Package_version_unsuitable

If not

Find_package based on these settings

<Package> _ version

Full provided version string

<Package> _ version_major

Major version if provided, else 0

<Package> _ version_minor

Minor version if provided, else 0

<Package> _ version_patch

Patch version if provided, else 0

<Package> _ version_tweak

Tweak version if provided, else 0

Reference
  • Http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package

  • Http://www.cmake.org/Wiki/CMake/Tutorials/Packaging

  • Http://www.cmake.org/Wiki/CMake:How_to_create_a_ProjectConfig.cmake_file

From: http://blog.csdn.net/dbzhang800/article/details/6341029

Cmake Study Notes (5)

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.