问题
I have a CMake project named foo
. In its CMakeLists.txt
, and among other commands, I have:
install(
EXPORT foo_export
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/foo"
NAMESPACE "foo::"
FILE foo-config.cmake
)
(and also a write_basic_package_version_file()
call later on.)
Now, I want foo-config.cmake
to also check for a dependency bar
of foo
, with find_dependency()
. How do I do that, other than by replacing the .cmake
file generation with something manual?
Notes:
- I'm interested both in the case of
bar
being a requried dependency and the case of it being optional. - I would rather not write a
foo-config.in
unless it's the only option.
来源:https://stackoverflow.com/questions/61815038/how-do-i-introduce-find-dependency-calls-into-my-generated-foo-config-cmake-file