title: How can I pass specific arguments (example: opencv_dir) to CMake through gradle externaNativeTool?
body: <p>I am trying to execute a CMake script in Android studio as an externalNativeBuildTool which it has OpenCV dependency. </p>
  
  <p>I know that I can define statically in the script where the OpenCV and  I wouldn't like to use OpenCV manager or plugin to the android studio. I want jus to pass Opencv_dir parameter to avoid to copy all headers and libraries to the project. </p>
  
  <p>So, in conclusion, I have this error: </p>
  
  <pre><code> Could not find a package configuration file provided by "OpenCV" with   any  of the following names:
      OpenCVConfig.cmake
      opencv-config.cmake
  </code></pre>
  
  <p>I' ve looking for a solution like: </p>
  
  <p><a href="https://developer.android.com/ndk/guides/cmake.html#build-command" rel="noreferrer">https://developer.android.com/ndk/guides/cmake.html#build-command</a>. </p>
  
  <p>But these arguments are not satisfied, And I tried to put the Opencv_dir like this: </p>
  
  <pre><code>externalNativeBuild {
              cmake {
                  cppFlags "-std=c++11 -fno-rtti -fexceptions "
                  arguments "-DANDROID_ARM_NEON=ON -DANDROID_PLATFORM=18 
                 -DOpenCV_DIR="+getOpenCVDir().toString()
  
              }
          }
  def getOpenCVDir() {
      Properties properties = new Properties()
      properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())
      def externalModuleDir = properties.getProperty('opencv.dir', null)
      if (externalModuleDir == null) {
          throw new GradleException(
                  "OpenCV location not found. Define location with opencv.dir in the local.properties file!")
      }
      return externalModuleDir
  }
  </code></pre>
  
  <p>where the opencvdir is defined on local properties</p>
  
  <p><em>opencv.dir={my_sdk_path}/OpenCV-android-sdk/sdk/native/jni</em></p>
  
  <p>So is there any way to pass custom arguments to cmake through gradle?</p>
  
  <p>Thanks in advance.</p>