Skip to content

install utilities: added cth_pkg_add_find_modules - #8

Merged
codethinki merged 1 commit into
mainfrom
feat/package-find-modules
Oct 21, 2026
Merged

codethinki merged 1 commit into
mainfrom
feat/package-find-modules

Conversation

@codethinki

Copy link
Copy Markdown
Owner

Dependencies that install no CMake package (for example gtl, headers only) need a Find<Package>.cmake. Until now a package built with cth_cmake could find such a module during its own build, but the generated Config.cmake could not: find_dependency(<Package> MODULE) failed for every consumer of the installed package unless the consumer provided the module itself.

cth_pkg_add_find_modules(<files>...):

  • registers the find modules and adds their directories to CMAKE_MODULE_PATH of the calling directory, so a following cth_pkg_target_find_package(<target> <Package> MODULE ...) finds them in the build
  • cth_create_package() installs them next to the generated Config.cmake
  • the generated Config.cmake appends its own directory to CMAKE_MODULE_PATH before the find_dependency blocks (a consumer's own module wins) and restores the consumer's module path at its end
  • packages without find modules generate the same config as before

Tested locally with a producer that packages a target depending on a header only dummy library through Finddummy.cmake, and a consumer of the installed package: the consumer finds the dependency, builds and runs, and its CMAKE_MODULE_PATH is unchanged after find_package. Without the installed module the consumer fails with "dependency missing: find_package(dummy MODULE REQUIRED) failed". The CI examples do not install or consume packages, so this is not covered there.

Needed for gtl as a dependency of cth.

@codethinki
codethinki merged commit 79a6191 into main Oct 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant