← All tasks
cpptesseract-ocr/tesseract #3269Not a task: not reproduced

CMake install is broken

envgap__tesseract-ocr__tesseract-3269

01 / FAILURE SIGNATURE

As reported upstream

File or directory
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
c6539e21a04aa2a9e89c91e48f67f7dc28d0a44f
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

tesseract-ocr/tesseract #3269 · read the original issue
### 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:



https://github.com/tesseract-ocr/tesseract/blob/c6539e21a04aa2a9e89c91e48f67f7dc28d0a44f/CMakeLists.txt#L364



Here it is passed to `configure_package_config_file`. The option `NO_SET_AND_CHECK_MACRO` should be given here.



https://github.com/tesseract-ocr/tesseract/blob/c6539e21a04aa2a9e89c91e48f67f7dc28d0a44f/CMakeLists.txt#L372-L376



And here it is passed to `set_and_check`. This should just be replaced with normal `set` or custom checking logic should be implemented.



https://github.com/tesseract-ocr/tesseract/blob/c6539e21a04aa2a9e89c91e48f67f7dc28d0a44f/cmake/templates/TesseractConfig.cmake.in#L25
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]