tesseract: CMake install is broken
Environment
- Tesseract Version: master branch (cloned today)
- Commit Number: c6539e21a04aa2a9e89c91e48f67f7dc28d0a44f
- Platform:
Linux hostname 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Current Behavior:
I run the following commands to build Tesseract and install it into a local directory:
$ git clone git@github.com:tesseract-ocr/tesseract.git
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S tesseract -B tesseract-build
$ cmake --build tesseract-build
$ cmake --install tesseract-build --prefix tesseract-install
Then I create the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(test)
find_package(Tesseract 5 REQUIRED)
in the directory test. I then try to build it:
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$(readlink -f tesseract-install) -DLeptonica_DIR=$(readlink -f leptonica-install/lib/cmake) -S test -B test-build
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /path/to/tesseract-install/lib/cmake/tesseract/TesseractConfig.cmake:33 (message):
File or directory
/path/to/tesseract-install/include;/path/to/tesseract-install/include/tesseract
referenced by variable Tesseract_INCLUDE_DIRS does not exist !
Call Stack (most recent call first):
/path/to/tesseract-install/lib/cmake/tesseract/TesseractConfig.cmake:49 (set_and_check)
CMakeLists.txt:4 (find_package)
Looking in /path/to/tesseract-install/lib/cmake/tesseract/TesseractConfig.cmake, I see:
set_and_check(Tesseract_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include;${PACKAGE_PREFIX_DIR}/include/tesseract")
Which is obviously wrong (contains a ;).
Expected Behavior:
For find_package to succeed.
Suggested Fix:
Do not use CMakePackageConfigHelpers’s set_and_check macro. It only works with one path, not several. Here, INCLUDE_DIR is set to a list of two directories:
Here it is passed to configure_package_config_file. The option NO_SET_AND_CHECK_MACRO should be given here.
And here it is passed to set_and_check. This should just be replaced with normal set or custom checking logic should be implemented.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (9 by maintainers)
I wrote find modules for Tesseract and Leptonica (find modules are needed because other distributions usually use Autotools to build these projects):
https://github.com/crow-translate/crow-translate/blob/master/cmake/FindTesseract.cmake https://github.com/crow-translate/crow-translate/blob/master/cmake/FindLeptonica.cmake
See https://github.com/tesseract-ocr/tesseract/actions/runs/522034896/workflow
for cmake builds which work.
On Sat, Jan 30, 2021, 22:29 Alex Reinking notifications@github.com wrote: