How do I introduce find_dependency calls into my generated foo-config.cmake file?

﹥>﹥吖頭↗ 提交于 2021-01-28 13:41:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!