1

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'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.

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.)

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.

Thanks

Roofus
  • 584
  • 6
  • 17
  • Possible duplicate of [How to backup the generator cache/settings for cmake gui on windows?](http://stackoverflow.com/questions/22039113/how-to-backup-the-generator-cache-settings-for-cmake-gui-on-windows) – Florian Mar 29 '17 at 11:14
  • Not the same. It recommends re-using CMakeCache.txt to repeat the exact same build. If the generator is changed, CMakeCache.txt should be deleted, as it is almost impossible to ensure everything stored in it is consistent with the new generator. [Reference: http://cmake.3232098.n2.nabble.com/Changing-the-the-current-generator-in-CMake-GUI-td7587876.html ] – Roofus Mar 31 '17 at 06:01
  • I understand your point. But a partial `CMakeCache.txt` is also allowed (CMake will just pre-load the values that are there and reevaluate the rest). 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. – Florian Apr 03 '17 at 19:41

1 Answers1

1

Turning my comment into an answer

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).

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.

Reference

Florian
  • 39,996
  • 9
  • 133
  • 149