gpt4 book ai didi

CMake 测试我是否处于脚本模式

转载 作者:行者123 更新时间:2023-12-04 16:44:34 24 4
gpt4 key购买 nike

我想使用相同的 cmake 文件作为脚本和包含文件

do_something.cmake:

function(do_something)
# do something
endfunction

if(CMAKE_IS_SCRIPTING_MODE) # this variable does not exist!
do_something()
endif

这样我就可以轻松地从 CMake 项目和 shell 调用我的脚本。如何做到这一点?

最佳答案

我想你在找CMAKE_SCRIPT_MODE_FILE

When run in cmake(1) -P script mode, CMake sets this variable to the full path of the script file. When run to configure a CMakeLists.txt file, this variable is not set.

关于CMake 测试我是否处于脚本模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51427538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com