Overview
In a previous post, we announced the availability of OpenCV libs for Modern Windows. At that time, I also demonstrated how to use a batch file to automate CMake. Today, I wish to shift focus towards on CMake usage for OpenCV.
CMake 3.1 can now create Windows Store and Windows Phone project files directly, so you no longer need to apply arcane Voodoo magic to make binaries for these platforms J
Only a few steps are now required to build OpenCV for these platforms:
· Set up CMake with the correct parameters (see below)
· Configure, generate and build projects
CMake Set Up
Download CMake GUI and open it.
Set the build paths
1. Where is the source code: path to opencv
2. Where to build the binaries: path to opencv/<your-custom-folder>, usually opencv/bin
Before configuring your project use "Add Entry" button
o add the following parameters for Windows Phone or for Windows Store build:
- WinowsPhone
- CMAKE_SYSTEM_NAME - WindowsPhone
- CMAKE_SYSTEM_VERSION - 8.1 or 8.0
- Winows Store
- CMAKE_SYSTEM_NAME - WindowsStore
- CMAKE_SYSTEM_VERSION - 8.1
For example for Windows Phone 8.1
Note that only a single platform may be configured at a time. To build for different platforms, you must go through these steps and set values for each distinct platform.
Once this process is complete, the setup will look like this:
Proceed to Configure, Generate and Build!
Click on "Configure". You’ll see that the popup window requests the compiler toolchain to be used to build the project based on the files you wish to generate.
Choose Visual Studio 12 2013 option. Depending on your further plans, you may wish to target ARM, x84 or x64 platforms.
The resulting setup will look like this
Afterward, select ONLY from the following BUILD options:
Select "Configure", and then "Generate"
This will generate all of the files needed to build open_cv projects for the selected platform in ```opencv\bin```. Open the opencv\bin directory and open the OpenCV.sln. Build each of the projects.
Check the build log for errors and verify that the following items are present for Windows Phone and Windows Store builds respectively:
Windows Phone
Windows Store
We hope this information will help you understand how to use CMake to build OpenCV libraries. Let us know how it goes!
A bientot,
Eric