Skip to main content

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

  1. Moves /debug/<CONFIG_PATH>/*targets-debug.cmake to /share/${PACKAGE_NAME}.
  2. Transforms all references matching /bin/*.exe to /${TOOLS_PATH}/*.exe on Windows.
  3. Transforms all references matching /bin/* to /${TOOLS_PATH}/* on other platforms.
  4. Fixes ${_IMPORT_PREFIX} in auto generated targets.
  5. Replaces ${CURRENT_INSTALLED_DIR} with ${_IMPORT_PREFIX} in configs.
  6. Merges INTERFACE_LINK_LIBRARIES of release and debug configurations.
  7. Replaces ${CURRENT_INSTALLED_DIR} with ${KMPKG_IMPORT_PREFIX} in targets.
  8. Removes /debug/<CONFIG_PATH>/*config.cmake.

Examples

Source

ports/kmpkg-cmake-config/kmpkg_cmake_config_fixup.cmake