-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake install is broken #3269
Comments
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 ***@***.***> wrote:
Environment
- *Tesseract Version*: master branch (cloned today)
- *Commit Number*: c6539e2
<c6539e2>
- *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 ***@***.***: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:
Fix the set_and_check macro to loop over its arguments:
function (set_and_check var files)
foreach (file IN LISTS files)
if (NOT EXISTS "${file}")
message(FATAL_ERROR "File or directory ${file} referenced by variable ${var} does not exist!")
endif ()
endforeach ()
set(${var} "${files}" PARENT_SCOPE)
endfunction ()
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3269>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABG37I2TITKRP76LQ7YYHFTS4Q3FTANCNFSM4W2PDJYQ>
.
|
Those builds do not attempt to |
I updated my original post with the exact problem spelled out in full detail. This problem was introduced recently, in #3119. I suggest you add some basic CMake package testing to GHA. Even something as simple as checking that |
I think we just need to use simple |
Sort of --
|
Could you provide used |
Yes, it's this: cmake_minimum_required(VERSION 3.19)
project(test)
find_package(Tesseract 5 REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE Tesseract::libtesseract) The file #include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
int main()
{
char *outText;
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
// Initialize tesseract-ocr with English, without specifying tessdata path
if (api->Init(NULL, "eng")) {
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
}
// Open input image with leptonica library
Pix *image = pixRead("/usr/src/tesseract/testing/phototest.tif");
api->SetImage(image);
// Get OCR result
outText = api->GetUTF8Text();
printf("OCR output:\n%s", outText);
// Destroy used object and release memory
api->End();
delete api;
delete [] outText;
pixDestroy(&image);
return 0;
} |
Thanks! Could you also provide the generated Tesseract cmake config file (from install prefix)? |
Here are the contents of the And here is the verbose build output so you can see the actual commands (with local paths again redacted):
|
@alexreinking, thanks, can reproduce. Did this work before my PR? |
I do not know, but I will try. Give me a couple minutes. |
No because the install is broken in too many other ways. Can't find |
Could you try to specify |
You mean in addition to |
No, only the |
I was not able to make it work with the commit prior to #3119 |
Do you mean that you are getting a link error or that it didn't work at all prior to #3119? |
I think that there is another link issue that not caused by my changes. @alexreinking could you open a separate issue about it? |
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 |
Environment
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:
Then I create the following CMakeLists.txt:
in the directory
test
. I then try to build it:Looking in
/path/to/tesseract-install/lib/cmake/tesseract/TesseractConfig.cmake
, I see:Which is obviously wrong (contains a
;
).Expected Behavior:
For
find_package
to succeed.Suggested Fix:
Do not use
CMakePackageConfigHelpers
'sset_and_check
macro. It only works with one path, not several. Here,INCLUDE_DIR
is set to a list of two directories:tesseract/CMakeLists.txt
Line 364 in c6539e2
Here it is passed to
configure_package_config_file
. The optionNO_SET_AND_CHECK_MACRO
should be given here.tesseract/CMakeLists.txt
Lines 372 to 376 in c6539e2
And here it is passed to
set_and_check
. This should just be replaced with normalset
or custom checking logic should be implemented.tesseract/cmake/templates/TesseractConfig.cmake.in
Line 25 in c6539e2
The text was updated successfully, but these errors were encountered: