为什么需要FORCE覆盖CMake选项? [英] Why do I need FORCE to override a CMake option?

查看:730
本文介绍了为什么需要FORCE覆盖CMake选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想覆盖一个选项,该选项以前设置为OFF。我正在使用

I want to override an option, which formely was set to OFF. I am using

SET(USE_OPTION ON CACHE BOOL "Override option" FORCE)

出于好奇:为什么我需要 FORCE(没有它,set()无效)

Just for my curiosity: Why do I need 'FORCE' (without it, the set() does not work)

推荐答案

来自 docs


如果存在CACHE,则将
放入缓存中,除非它已经在缓存中

If CACHE is present, then the is put in the cache instead, unless it is already in the cache

我认为以前的选项也是 CACHE

I assume the previous option was also CACHE.


如果指定了FORCE,则设置缓存变量的值,如果变量已经在缓存中,则设置

If FORCE is specified, the value of the cache variable is set, even if the variable is already in the cache.

因此,如果您未指定 FORCE ,则不会按照上述方式添加到缓存中。

So, if you don't specify FORCE it doesn't get added to the cache as per above.

这篇关于为什么需要FORCE覆盖CMake选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆