【发布时间】:2025-12-02 17:50:01
【问题描述】:
我最近开始使用现代 CMake 原则并在我的项目中包含配置文件。
尽管我可以使用我的一个项目,比如说 Foo,作为另一个项目的依赖项,比如说 Bar,但在构建项目 Bar 时,我看不到工具中的 foo 项目变量作为 CMake GUI。
但是,可以正确找到路径并且正确构建依赖项目。有人知道我想念什么吗?
这是 FooConfig.cmake.in 文件的示例:
# - Config file for the foo package
# It defines the following variables
# Foo_INCLUDE_DIRS - include directories for Foo
# Foo_LIBRARY_DIRS - library directories for Foo (normally not used!)
# Foo_LIBRARIES - libraries to link against
@PACKAGE_INIT@
# Tell the user project where to find our headers and libraries
set_and_check(Foo_INCLUDE_DIRS "@Foo_INSTALL_INCLUDEDIR@")
set_and_check(Foo_LIBRARY_DIRS "@Foo_INSTALL_LIBDIR@")
include_directories (${Foo_INCLUDE_DIRS})
include("${CMAKE_CURRENT_LIST_DIR}/FooTargets.cmake")
check_required_components("Foo")
set(foo_LIBRARIES Foo)
提前致谢。
【问题讨论】: