These helpers offer a way to embed external packages in a CMake based project. They allow to find these packages that are not CMake aware to build during the generation of the build environment.
find_package(<package_name> [<version>] REQUIRED
[NO_COMPONENTS|[WITH_COMPONENTS] <components>]
[FLAGS <flags>]
)
NO_COMPONENTSindicates only package's headers are required. NO components should be compiled when this flag is setWITH_COMPONENTSmust be followed with a list of all additional components to build
Note
Both
NO_COMPONENTSandWITH_COMPONENTScannot be used at the same time.
FLAGScan be followed by any of the flags below:
Note
Some additional flags may be available for package. Please refer to specific documentations for complete list of flags.
STATIC: Flag to request static version of librariesRUNTIME_STATIC: Flag to request libraries linkable to platforms' static runtime librarySOURCE_DIR<path>: The absolute path to the package's source tree
In order to allow the use of this script, several points must be done first:
This module must be enabled in the project wishing to use the
Find<package_name>.cmake helper.
Please, refer to this CMakeBuildSystem's help for more information about how to enable this module.
The package's source tree must be available from the project's source tree.
If no SOURCE_DIR path is provided from the
find_package(...) call, the script will automatically search the source tree
in the following prioritized paths:
${<PACKAGE_NAME>_ROOT_DIR}${CMAKE_SOURCE_DIR}/third_party${PROJECT_SOURCE_DIR}/third_party${CMAKE_CURRENT_SOURCE_DIR}/third_party
Note
The name of the root directory that contains the package's source tree should be written in lower case. Otherwise, that name must match the name provided on
find_package(...)call.
For specific reasons it may be needed to force the location where the packages' binary will be created or where the packages' source tree should be expanded.
This can be achieved through the following variables:
EXTERNALS_BINARY_DIR: If set, this variable forces the location where all packages' binaries must be created.EXTERNALS_EXPAND_DIR: If set, this variable forces the location where all packages' source archive must be expanded.EXTERNALS_USE_RELATIVE_DIR: If set, this variable indicates that binaries' and expanded archives' location must use a sub path matching the caller CMakeLists.txt's one.