Ask Your Question

Revision history [back]

The solution to this question is quite simple as suggested in the comments, be resolved by reading the CMake manual follows the summary of what I learned on the subject:

Just replace "EXTRA_" to "CMAKE_" in the name of the variable that parameterize the cmake command:

CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE

He does not use these post-fixed variables "_Release" or even "_DEBUG" the joint compilation, unless the variable CMAKE_BUILD_TYPE is used to determine the type of compilation to be done, selecting the appropriate setting for each use.

So the solution to pass extra parameters to compile OpenCV is using the variables:

CMAKE_CXX_FLAGS

    CMAKE_C_FLAGS

In addition it may be required for additional parameters to the linking process to use that variable:

CMAKE_EXE_LINKER_FLAGS

More information can be found at:

  • https://cmake.org/cmake/help/v3.0/variable/CMAKE_EXE_LINKER_FLAGS.html
  • https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html