kmpkg_cmake_config_fixup
Merge and correct Release and Debug CMake targets and configs to support multiconfig generators.
Usage
kmpkg_cmake_config_fixup(
[PACKAGE_NAME <name>]
[CONFIG_PATH <config-directory>]
[TOOLS_PATH <tools/${PORT}>]
[DO_NOT_DELETE_PARENT_CONFIG_PATH]
[NO_PREFIX_CORRECTION]
)
To use this function, you must depend on the helper port kmpkg-cmake-config:
"dependencies": [
{
"name": "kmpkg-cmake-config",
"host": true
}
]
Additionally corrects common issues with targets, such as absolute paths and incorrectly placed binaries.
For many ports, kmpkg_cmake_config_fixup() on its own should work,
as PACKAGE_NAME defaults to ${PORT} and CONFIG_PATH defaults to share/${PACKAGE_NAME}.
For ports where the package name passed to find_package is distinct from the port name,
PACKAGE_NAME should be changed to be that name instead.
For ports where the directory of the *config.cmake files cannot be set,
use the CONFIG_PATH to change the directory where the files come from.
By default the parent directory of CONFIG_PATH is removed if it is named "cmake".
Passing the DO_NOT_DELETE_PARENT_CONFIG_PATH option disables such behavior,
as it is convenient for ports that install
more than one CMake package configuration file.
The NO_PREFIX_CORRECTION option disables the correction of _IMPORT_PREFIX
done by kmpkg due to moving the config files.
Currently the correction does not take into account how the files are moved,
and applies a rather simply correction which in some cases will yield the wrong results.
How it works
- Moves
/debug/<CONFIG_PATH>/*targets-debug.cmaketo/share/${PACKAGE_NAME}. - Transforms all references matching
/bin/*.exeto/${TOOLS_PATH}/*.exeon Windows. - Transforms all references matching
/bin/*to/${TOOLS_PATH}/*on other platforms. - Fixes
${_IMPORT_PREFIX}in auto generated targets. - Replaces
${CURRENT_INSTALLED_DIR}with${_IMPORT_PREFIX}in configs. - Merges
INTERFACE_LINK_LIBRARIESof release and debug configurations. - Replaces
${CURRENT_INSTALLED_DIR}with${KMPKG_IMPORT_PREFIX}in targets. - Removes
/debug/<CONFIG_PATH>/*config.cmake.