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:
If the finder is not found, the config mode is started:
<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)