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

Distribute cmake install files with autotools #1973

Open
zdenop opened this issue Oct 9, 2018 · 1 comment
Open

Distribute cmake install files with autotools #1973

zdenop opened this issue Oct 9, 2018 · 1 comment
Assignees

Comments

@zdenop
Copy link
Contributor

zdenop commented Oct 9, 2018

Regardless tesseract is installed with autotool, project should also install tesseract cmake file for easy integration of tesseract to cmake tool-chain.

At the moment cmake install 4 "cmake files":

-- Installing: /usr/local/cmake/TesseractTargets.cmake
-- Installing: /usr/local/cmake/TesseractTargets-noconfig.cmake
-- Installing: /usr/local/cmake/TesseractConfig.cmake
-- Installing: /usr/local/cmake/TesseractConfig-version.cmake

Last two are created from templates, so it is easy to create and install them with autotools (patch is bellow). First to seems to be created on the fly. Is it possible to modify them so they are created from template too, for easy including to autotools?

Also I found that cmake configuration use different variable names for the same feature. Would be great to unify naming (instead of VERSION_PLAIN to use PACKAGE_VERSION...)

diff --git a/Makefile.am b/Makefile.am
index de6af2eb..d315c916 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,9 @@ SUBDIRS += src/ccmain src/api . tessdata doc unittest
 
 EXTRA_DIST = README.md\
 	aclocal.m4 config configure.ac autogen.sh contrib \
-	tesseract.pc.in $(TRAINING_SUBDIR) java doc langtests unlvtests
+	tesseract.pc.in $(TRAINING_SUBDIR) java doc langtests unlvtests \
+	cmake/templates/TesseractConfig.cmake.in \
+        cmake/templates/TesseractConfig-version.cmake.in
 
 DIST_SUBDIRS = $(SUBDIRS) $(TRAINING_SUBDIR)
 
@@ -65,3 +67,5 @@ doc-clean:
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = tesseract.pc
+cmakeconfigdir = $(libdir)/cmake
+cmakeconfig_DATA = $(TESSERACT_CMAKE_CONFIG_FILES)
diff --git a/configure.ac b/configure.ac
index 51c86884..40ef324f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -457,12 +457,27 @@ else
 fi
 
 
+AC_DEFUN([TESSERACT_CMAKE_CONFIG_FILES], [ \
+  cmake/templates/TesseractConfig.cmake \
+  cmake/templates/TesseractConfig-version.cmake \
+])
+[TESSERACT_CMAKE_CONFIG_FILES]="TESSERACT_CMAKE_CONFIG_FILES"
+# TesseractConfig.cmake.in and TesseractConfig-version.cmake.in needs
+# these output variables.
+AC_SUBST([TESSERACT_CMAKE_CONFIG_FILES])
+AC_SUBST(VERSION_PLAIN, ${PACKAGE_VERSION})
+AC_SUBST(VERSION_MAJOR, ${GENERIC_MAJOR_VERSION})
+AC_SUBST(VERSION_MINOR, ${GENERIC_MINOR_VERSION})
+INCLUDE_DIR=`eval echo $includedir`
+INCLUDE_DIR="$INCLUDE_DIR; $INCLUDE_DIR/tesseract"
+AC_SUBST([INCLUDE_DIR])
+
 # ----------------------------------------
 # Final Tasks and Output
 # ----------------------------------------
 
 # Output files
-AC_CONFIG_FILES([Makefile tesseract.pc])
+AC_CONFIG_FILES([Makefile tesseract.pc] TESSERACT_CMAKE_CONFIG_FILES)
 AC_CONFIG_FILES([langtests/Makefile])
 AC_CONFIG_FILES([src/api/Makefile])
 AC_CONFIG_FILES([src/api/tess_version.h]) 
@egorpugin
Copy link
Contributor

Is it possible to modify them so they are created from template too, for easy including to autotools?

Not sure. I did not use those export files since implementing.


Actually I consider them obsolete because of dependency hell there.
Cppan is the main way for me.

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

No branches or pull requests

2 participants