问题描述
我需要在VS2015中为32位和64位构建OpenCV.
I need to build OpenCV for both 32-bit and 64-bit in VS2015.
我知道每个生成器都需要一个单独的构建树.
I'm aware that I need a separate build tree for each generator.
OpenCV的CMake配置大约有300个用户可配置的变量,我终于对它们感到满意.现在,我要使用完全相同的一组决定来构建64位版本.
OpenCV's CMake configuration has approximately 300 user-configurable variables, which I have finally got set to my satisfaction. Now I want to use the exact same set of decisions to build the 64-bit version.
是否可以将代表我的决策的变量值传输到新的构建树? (除了并排打开两个CMake-GUI并检查所有〜300个值都对应.)
Is there a way to transfer the variable values that represent my decisions to the new build tree? (Other than opening two CMake-GUIs side by side and checking that all ~300 values correspond.)
顺便说一句,如果更改了生成器,则必须根据CMake邮件列表[ http://cmake.3232098.n2.nabble.com/Changing-the-the-the-current-generator-in-CMake-GUI -td7587876.html ].手动编辑它具有很大的风险,并可能导致不确定的行为.
BTW, if the generator is changed, CMakeCache.txt must be deleted, according to the CMake mailing list [ http://cmake.3232098.n2.nabble.com/Changing-the-the-current-generator-in-CMake-GUI-td7587876.html ]. Manually editing it is very risky and will likely lead to undefined behaviour.
谢谢
推荐答案
将我的评论变成答案
您可以在新目录中使用部分CMakeCache.txt
(CMake只会预加载其中的值,然后重新评估其余值).
You can use a partial CMakeCache.txt
in the new directory (CMake will just pre-load the values that are there and reevaluate the rest).
因此,您可以使用类似grep的方法并进行
So you can use a grep like approach and do
findstr "OpenCV_" CMakeCache.txt > \My\New\Path\CMakeCache.txt
只需对其进行测试,就可以按预期工作.
Just tested it and seems to work as expected.
参考
这篇关于如何通过新生成器重用现有的CMake变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!