Skip to content
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

Add GoogleTest infrastructure #1051

Merged
merged 3 commits into from
Aug 18, 2017
Merged

Conversation

stweil
Copy link
Member

@stweil stweil commented Jul 24, 2017

Instructions (run in Tesseract source directory):

git submodule update --init googletest
mkdir demo && cd demo
cmake ..
make
bin/tesseract_test

stweil added 3 commits July 24, 2017 19:45
Signed-off-by: Stefan Weil <[email protected]>
The submodule is build automatically as soon as it exists.

Signed-off-by: Stefan Weil <[email protected]>
@stweil
Copy link
Member Author

stweil commented Jul 24, 2017

Still missing:

  • Update documentation.
  • Add to Travis CI.
  • Support for autotools (is this needed?).

That can be done as soon as there are real tests. Maybe there are also different opinions about the best location for the googletest submodule or the name of the test executable (currently tesseract_test).

configure / make is currently not used for CI tests, so maybe it is sufficient to support cmake for GoogleTest and don't implement autotools support.

@jbarlow83
Copy link

Is there a reason to have both cmake and autotools in the first place?

The homebrew build script for Tesseract uses autotools right now, so people are building with autotools. Logically one should be able to test any configuration that gets built.

I'd be tempted to deprecate/eliminate autotools so we don't have to worry about setting up test for it, if possible.

@stweil
Copy link
Member Author

stweil commented Jul 27, 2017

I personally also use mostly autotools, for example when building the installer for Windows. As far as I know it is also used by Debian based distributions when building Tesseract packages.

For the tests, having cmake in the first place seems to be sufficient for me because CI is based on that.

I'd decide later how easy or difficult it is to maintain testing with autotools.

@Shreeshrii
Copy link
Collaborator

Shreeshrii commented Jul 27, 2017

I had built it locally with autotools, making changes in the makefiles etc. I think once setup the only changes will be in the makefile in the directory where the tests/test cases/test fixtures are kept. So it should not be too difficult.

https://github.com/tesseract-ocr/tesseract/blob/0f2500287a30d2b09e8c853b39913a5eb9b03ca2/unittest/Makefile

@amitdo
Copy link
Collaborator

amitdo commented Jul 27, 2017

Is there a reason to have both cmake and autotools in the first place?
...
I'd be tempted to deprecate/eliminate autotools so we don't have to worry about setting up test for it, if possible.

The autotools build works fine on Posix environments.

See also:
#595 (comment)

@amitdo
Copy link
Collaborator

amitdo commented Aug 3, 2017

2fbcba62e5e

@Shreeshrii
Copy link
Collaborator

Please see #1059

pull request with makefile etc

@jbreiden
Copy link
Contributor

jbreiden commented Aug 3, 2017

You are right Debian packaging builds Tesseract with autotools, but it would be pretty easy to switch that over to cmake if needed.

@theraysmith theraysmith merged commit 6f13d75 into tesseract-ocr:master Aug 18, 2017
@theraysmith
Copy link
Contributor

So I tried building a test using just github, and I get stuck before I can even try it.
The code doesn't build under cmake, where it does under autotools.
Since this is my first attempt at using cmake I'm probably doing something wrong, but it seems less reliable/portable than autotools so far:

~/opensrc/git/tesseract/demo$ make
[ 97%] Built target libtesseract
Linking CXX executable bin/tesseract
liblibtesseract.so.4.0.0: undefined reference to l_generateCIDataForPdf' liblibtesseract.so.4.0.0: undefined reference to l_CIDataDestroy'
liblibtesseract.so.4.0.0: undefined reference to pixReadFromMultipageTiff' liblibtesseract.so.4.0.0: undefined reference to pixReadMemFromMultipageTiff'
collect2: error: ld returned 1 exit status

It looks to me like it is picking up the wrong version of leptonica. I think these are new functions in the latest version. I built and installed the latest leptonica earlier today.
So how do I make it build under cmake? cmake fans speak up before I get turned off it completely!

@amitdo
Copy link
Collaborator

amitdo commented Aug 18, 2017

You should also build leptonica with CMake.

@stweil stweil deleted the googletest branch August 18, 2017 07:41
@stweil
Copy link
Member Author

stweil commented Aug 18, 2017

I noticed for the first time that cmake builds a liblibtesseract.so. That looks like a bug, because it should be libtesseract.so.

@stweil
Copy link
Member Author

stweil commented Aug 18, 2017

You should also build leptonica with CMake.

That's not strictly necessary. As long as I install it to the standard location (/usr/lib/x86_64-linux-gnu/liblept.so.5 for my Debian installation), the Leptonica library works both with CMake and autotools.

Ray, I‌ assume that your latest Leptonica was installed in /usr/local. Then CMake probably won't find it by default.

@jbarlow83
Copy link

I think the above is a case in point for my earlier comment that we should get rid of either Autotools or CMake. When there's two equivalent tools and people prefer one or the other, maintenance of one of them falls behind.

@amitdo
Copy link
Collaborator

amitdo commented Aug 18, 2017

Basically, CMake is for Windows&MSVC and autotools is for all other environments.
I'm talking only about this project, not about other projects' build tool usage.

Related: DanBloomberg/leptonica#253

@theraysmith
Copy link
Contributor

theraysmith commented Aug 18, 2017 via email

@amitdo
Copy link
Collaborator

amitdo commented Aug 18, 2017

I suggest to let @egorpugin (maintainer of CMake build for both Leptonica and Tesseract) some time to response before giving up on CMake for the unit-testing.

@egorpugin
Copy link
Contributor

egorpugin commented Aug 18, 2017

CMake does not work properly on linux. Please, use autotools for some time.
Or is it hard to integrate tests with autotools?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants