leptonica
leptonica copied to clipboard
Missing LeptonicaTargets.cmake when importing library
I'm trying to include Leptonica via CMake on OS X 10.14, and I get the following error on build:
[build] CMake Error at /usr/local/lib/cmake/LeptonicaConfig.cmake:23 (include):
[build] include could not find requested file:
[build]
[build] /usr/local/lib/cmake/LeptonicaTargets.cmake
Googling for the problem, I found issue #410 , which has the configuration print out at some point
Old export file "/usr/local/cmake/LeptonicaTargets.cmake" will be replaced. Removing files [/usr/local/cmake/LeptonicaTargets-noconfig.cmake].
Is the reference to LeptonicaTargets.cmake
outdated, should it be removed?
For reference, I simply have the line
find_package( Leptonica REQUIRED )
in my CMakeLists.txt
, which triggers the error.
Can you post content of /usr/local/lib/cmake/LeptonicaConfig.cmake
+ information how did you installed leptonica?
LeptonicaConfig.cmake:
# ===================================================================================
# The Leptonica CMake configuration file
#
# ** File generated automatically, do not modify **
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# find_package(Leptonica REQUIRED)
# include_directories(${Leptonica_INCLUDE_DIRS})
# target_link_libraries(MY_TARGET_NAME ${Leptonica_LIBRARIES})
#
# This file will define the following variables:
# - Leptonica_LIBRARIES : The list of all imported targets for OpenCV modules.
# - Leptonica_INCLUDE_DIRS : The Leptonica include directories.
# - Leptonica_VERSION : The version of this Leptonica build: "1.82.0"
# - Leptonica_VERSION_MAJOR : Major version part of Leptonica_VERSION: "1"
# - Leptonica_VERSION_MINOR : Minor version part of Leptonica_VERSION: "82"
# - Leptonica_VERSION_PATCH : Patch version part of Leptonica_VERSION: "0"
#
# ===================================================================================
include(${CMAKE_CURRENT_LIST_DIR}/LeptonicaTargets.cmake)
# ======================================================
# Version variables:
# ======================================================
SET(Leptonica_VERSION 1.82.0)
SET(Leptonica_VERSION_MAJOR 1)
SET(Leptonica_VERSION_MINOR 82)
SET(Leptonica_VERSION_PATCH 0)
# ======================================================
# Include directories to add to the user project:
# ======================================================
# Provide the include directories to the caller
set(Leptonica_INCLUDE_DIRS "/usr/local/Cellar/leptonica/1.82.0/include/leptonica")
# ====================================================================
# Link libraries:
# ====================================================================
set(Leptonica_LIBRARIES @leptonica_NAME@)
Leptonica was installed with brew install leptonica
Build leptonica from source with cmake. Seems like brew install installation is autotools build, which is not able to create correctly cmake files.
I do not have OSX, but on windows file looks like this:
# ===================================================================================
# The Leptonica CMake configuration file
#
# ** File generated automatically, do not modify **
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# find_package(Leptonica REQUIRED)
# include_directories(${Leptonica_INCLUDE_DIRS})
# target_link_libraries(MY_TARGET_NAME ${Leptonica_LIBRARIES})
#
# This file will define the following variables:
# - Leptonica_LIBRARIES : The list of all imported targets for OpenCV modules.
# - Leptonica_INCLUDE_DIRS : The Leptonica include directories.
# - Leptonica_VERSION : The version of this Leptonica build: "1.83.0"
# - Leptonica_VERSION_MAJOR : Major version part of Leptonica_VERSION: "1"
# - Leptonica_VERSION_MINOR : Minor version part of Leptonica_VERSION: "83"
# - Leptonica_VERSION_PATCH : Patch version part of Leptonica_VERSION: "0"
#
# ===================================================================================
include(${CMAKE_CURRENT_LIST_DIR}/LeptonicaTargets.cmake)
# ======================================================
# Version variables:
# ======================================================
SET(Leptonica_VERSION 1.83.0)
SET(Leptonica_VERSION_MAJOR 1)
SET(Leptonica_VERSION_MINOR 83)
SET(Leptonica_VERSION_PATCH 0)
# ======================================================
# Include directories to add to the user project:
# ======================================================
# Provide the include directories to the caller
set(Leptonica_INCLUDE_DIRS "F:/win64/include;F:/win64/include/leptonica")
set(Leptonica_LIBRARY_DIRS "@leptonica_LIBRARY_DIRS@")
# ====================================================================
# Link libraries:
# ====================================================================
set(Leptonica_LIBRARIES leptonica)
Okay, thanks! I actually sidestepped the issue already, since I was using Leptonica as part of Tesseract, and using pkgfind in the build which links in Tesseract seems to also find Leptonica correctly. But I'll keep this in mind in case I have to go back to using find_package for any reason.
same problem with package in arch repository, building from source solved the problem.