title: Use Tesseract in CMAKE project
body: <p>I am trying to compile a cmake project that requires Tesseract and OpenCV. Everything is being done in Ubuntu 20.04.
  But I have been struggling to get it compiled.
  I compiled Tesseract from source and have been going through several SO posts and whatever article I find online, but still no luck. I noticed that Tesseract doesn't export a <code>.cmake</code> file under <code>/usr/local/lib/cmake/</code>, so you cannot do <code>find_package(Tesseract x.x.x REQUIRED)</code>.</p>
  <p>Looking around, I see that people recommend doing it this way:</p>
  <pre class="lang-cmake prettyprint-override"><code>find_package(PkgConfig REQUIRED)
  pkg_search_module(TESSERACT REQUIRED tesseract)
  pkg_search_module(LEPTONICA REQUIRED lept)
  include_directories(${TESSERACT_INCLUDE_DIRS})
  include_directories(${LEPTONICA_INCLUDE_DIRS})
  link_directories( ${TESSERACT_LIBRARY_DIRS} )
  link_directories( ${LEPTONICA_LIBRARY_DIRS} )
  </code></pre>
  <p>Which seems to find something. After doing <code>pkg_search_module(TESSERACT REQUIRED tesseract)</code>, I can see that <code>TESSERACT_INCLUDE_DIRS</code> is populated with this list: <code>/usr/local/include;/usr/include/leptonica</code>. This is despite the fact that Tesseract header files are located under <code>/usr/local/include/tesseract/</code>. Anyways, running <code>cmake</code> goes through without an error.</p>
  <p>However, running <code>make</code> afterwards simply adds strange errors of</p>
  <pre><code>error: 'l_int32' does not name a type; did you mean 'u_int32_t'?
     54 |     l_int32        num;       /*!&lt; number of unknowns                     */
        |     ^~~~~~~
  </code></pre>
  <p>to my project. Even though I have not even included any header files of Tesseract or Leptonica.</p>
  <p><a href="https://stackoverflow.com/questions/38128260/cmake-and-tesseract-how-to-link-using-cmake">This</a> post is the only one that seems to be close to a solution.</p>
  <p>I have also tried the following without success:</p>
  <ul>
  <li>Add the path to Tesseract and Leptonica header files directly using</li>
  </ul>
  <pre class="lang-cmake prettyprint-override"><code>include_directories(/usr/local/include/tesseract/)
  include_directories(/usr/local/include/leptonica/)
  </code></pre>
  <ul>
  <li>Also tried to make my own <code>.cmake</code> file so that I can use <code>find_package(Tesseract 4.1.1 REQUIRED)</code> directly.</li>
  <li>I even tried to compile Leptonica library from source, but that doesn't help.</li>
  <li>Reading through the <a href="https://github.com/tesseract-ocr/tesseract/blob/master/CMakeLists.txt" rel="nofollow noreferrer">cmake file</a> of the Tesseract project itself also didn't shed a light on this.</li>
  </ul>