![](/img/trans.png)
[英]CMake, when use FindFoo.cmake or FooConfig.cmake (and other clarifications)
[英]How to display CMake variables from FooConfig.cmake file in CMake GUI?
我最近開始使用現代 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)
提前致謝。
CMake GUI 僅顯示緩存的變量,這些變量是用 CACHE 選項定義的。 由於您的FooConfig.cmake
未將變量設置為緩存,因此它們不會出現在 GUI 中。
實際上,將這些變量定義為 CACHE 變量是有一定意義的:CACHE 變量旨在可由用戶修改,而您的情況並非如此。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.