简体   繁体   English

是否可以在 cmake 中扩展 `include(foo.cmake)` 的内容?

[英]Is it possible to expand `include(foo.cmake)`'s content in cmake?

I would like to get the "expanded CMakeLists.txt" that replace each include(foo.cmake) with corresponding content.我想获得用相应内容替换每个include(foo.cmake)的“扩展 CMakeLists.txt”。 Don't know if it is possible.不知道有没有可能。

For example, I have CMakeLists.txt with contents:例如,我有CMakeLists.txt的内容:

cmake_minimum_required(VERSION 3.20)
project(hello)
include(hello.cmake)
message(STATUS "***** hello_str is ${hello_str}")

and hello.cmake with contents:hello.cmake内容:

set(hello_str "Hello, World")

I would get an expaned CMakeLists.txt with contents (yeah, just like C/C++'s preprocess)我会得到一个扩展的 CMakeLists.txt 内容(是的,就像 C/C++ 的预处理)

cmake_minimum_required(VERSION 3.20)
project(hello)
set(hello_str "Hello, World") ##!!
message(STATUS "***** hello_str is ${hello_str}")

Is that possible?那可能吗? And how?如何?

Is that possible?那可能吗?

No. CMake 3.22 (the current at time of writing) and below do not provide this feature.编号 CMake 3.22(撰写本文时的电流)及以下版本不提供此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM