Browse Source

Merge pull request #12747 from neheb/tess

tesseract/leptonica: switch to CMake
lilik-openwrt-22.03
Rosen Penev 4 years ago
committed by GitHub
parent
commit
0f25c979b2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 16 deletions
  1. +9
    -8
      libs/leptonica/Makefile
  2. +10
    -8
      utils/tesseract/Makefile
  3. +44
    -0
      utils/tesseract/patches/010-cmake.patch

+ 9
- 8
libs/leptonica/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=leptonica PKG_NAME:=leptonica
PKG_VERSION:=1.78.0 PKG_VERSION:=1.78.0
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.leptonica.org/source/ PKG_SOURCE_URL:=http://www.leptonica.org/source/
@ -20,10 +20,10 @@ PKG_LICENSE:=BSD-2-Clause
PKG_LICENSE_FILES:=leptonica-license.txt PKG_LICENSE_FILES:=leptonica-license.txt
PKG_BUILD_PARALLEL:=1 PKG_BUILD_PARALLEL:=1
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
CMAKE_BINARY_SUBDIR:=openwrt-build
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/libleptonica define Package/libleptonica
SECTION:=libs SECTION:=libs
@ -34,20 +34,21 @@ define Package/libleptonica
endef endef
TARGET_CFLAGS:=$(filter-out -O%,$(TARGET_CFLAGS)) -O3 TARGET_CFLAGS:=$(filter-out -O%,$(TARGET_CFLAGS)) -O3
TARGET_LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib
define Build/InstallDev define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/leptonica $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/include/leptonica
$(CP) $(PKG_INSTALL_DIR)/usr/include/leptonica/*.h $(1)/usr/include/leptonica/
$(INSTALL_DIR) $(1)/usr/lib $(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblept.{a,so*} $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libleptonica.so* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/cmake
$(CP) $(PKG_INSTALL_DIR)/usr/cmake/*.cmake $(1)/usr/lib/cmake/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lept.pc $(1)/usr/lib/pkgconfig/ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lept.pc $(1)/usr/lib/pkgconfig/
endef endef
define Package/libleptonica/install define Package/libleptonica/install
$(INSTALL_DIR) $(1)/usr/lib $(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblept.so.* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libleptonica.so.* $(1)/usr/lib/
endef endef
$(eval $(call BuildPackage,libleptonica)) $(eval $(call BuildPackage,libleptonica))

+ 10
- 8
utils/tesseract/Makefile View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=tesseract PKG_NAME:=tesseract
PKG_VERSION:=4.0.0 PKG_VERSION:=4.0.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/tesseract-ocr/tesseract/tar.gz/$(PKG_VERSION)? PKG_SOURCE_URL:=https://codeload.github.com/tesseract-ocr/tesseract/tar.gz/$(PKG_VERSION)?
@ -19,12 +19,10 @@ PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_PARALLEL:=1 PKG_BUILD_PARALLEL:=1
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
CMAKE_BINARY_SUBDIR:=openwrt-build
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
TARGET_LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib
include $(INCLUDE_DIR)/cmake.mk
define Package/tesseract define Package/tesseract
MENU:=1 MENU:=1
@ -36,11 +34,17 @@ define Package/tesseract
endef endef
TARGET_CFLAGS:=$(filter-out -O%,$(TARGET_CFLAGS)) -O3 TARGET_CFLAGS:=$(filter-out -O%,$(TARGET_CFLAGS)) -O3
CMAKE_OPTIONS += \
-DBUILD_TRAINING_TOOLS=OFF
define Build/InstallDev define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include $(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/tesseract $(1)/usr/include/ $(CP) $(PKG_INSTALL_DIR)/usr/include/tesseract $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib $(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libtesseract.{a,so*} $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libtesseract.so* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/cmake
$(CP) $(PKG_INSTALL_DIR)/usr/cmake/*.cmake $(1)/usr/lib/cmake/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/tesseract.pc $(1)/usr/lib/pkgconfig/ $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/tesseract.pc $(1)/usr/lib/pkgconfig/
endef endef
@ -50,8 +54,6 @@ define Package/tesseract/install
$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/ $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/lib $(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/ $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/share
$(CP) $(PKG_INSTALL_DIR)/usr/share/* $(1)/usr/share/
endef endef
$(eval $(call BuildPackage,tesseract)) $(eval $(call BuildPackage,tesseract))

+ 44
- 0
utils/tesseract/patches/010-cmake.patch View File

@ -0,0 +1,44 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,41 +224,6 @@ set(tesseract_src ${tesseract_src}
src/api/pdfrenderer.cpp
)
-if (WIN32)
- if (MSVC)
- include_directories(src/vs2010/tesseract)
- set(tesseract_hdr
- ${tesseract_hdr}
- ${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/resource.h)
- set(tesseract_rsc ${CMAKE_BINARY_DIR}/vs2010/tesseract/libtesseract.rc)
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductsse.cpp
- PROPERTIES COMPILE_DEFINITIONS __SSE4_1__)
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixsse.cpp
- PROPERTIES COMPILE_DEFINITIONS __SSE4_1__)
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductavx.cpp
- PROPERTIES COMPILE_FLAGS "/arch:AVX")
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixavx2.cpp
- PROPERTIES COMPILE_FLAGS "/arch:AVX2")
- endif()
-else()
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductsse.cpp
- PROPERTIES COMPILE_FLAGS "-msse4.1")
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixsse.cpp
- PROPERTIES COMPILE_FLAGS "-msse4.1")
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductavx.cpp
- PROPERTIES COMPILE_FLAGS "-mavx")
- set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/arch/intsimdmatrixavx2.cpp
- PROPERTIES COMPILE_FLAGS "-mavx2")
-endif()
-
add_library (libtesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr}
${tesseract_rsc}
)

Loading…
Cancel
Save