In package-Config.cmake, if I do find_package instead of find_dependency, what would be the effect on my application? In what scenarios it will break?
According to documentation, find_dependency
is just a wrapper around find_package
:
It is designed to be used in a Package Configuration File (
<package>Config.cmake
).find_dependency
forwards the correct parameters for QUIET and REQUIRED which were passed to the originalfind_package()
call. Any additional arguments specified are forwarded tofind_package()
.If the dependency could not be found it sets an informative diagnostic message and calls
return()
to end processing of the calling package configuration file and return to thefind_package()
command that loaded it.
If you would use, e.g., find_package(REQUIRED)
instead of find_dependency
, and the package won't be found, then it will be difficult for user to understand, that the error is related with outer package, not only with the inner one. Also, if outer call of find_package
doesn't use REQUIRE option, it is inconsistent to perform inner call with that option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With