Skip to content

Commit

Permalink
Modernize CMake config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 7, 2020
1 parent bd6c2e5 commit c8a164b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 42 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,17 @@ configure_file(
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/libtesseract.rc.in
${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfig-version.cmake @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfig.cmake @ONLY)

include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/templates/TesseractConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfig.cmake
INSTALL_DESTINATION lib/tesseract/cmake
PATH_VARS INCLUDE_DIR)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion)

# show summary of configuration
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
Expand Down
14 changes: 0 additions & 14 deletions cmake/templates/TesseractConfig-version.cmake.in

This file was deleted.

34 changes: 12 additions & 22 deletions cmake/templates/TesseractConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,29 @@
# In your CMakeLists.txt, add these lines:
#
# find_package(Tesseract REQUIRED)
# include_directories(${Tesseract_INCLUDE_DIRS})
# target_link_libraries(MY_TARGET_NAME ${Tesseract_LIBRARIES})
# target_link_libraries(MY_TARGET_NAME Tesseract::Tesseract)
#
# This file will define the following variables:
# - Tesseract_LIBRARIES : The list of all imported targets for OpenCV modules.
# - Tesseract_INCLUDE_DIRS : The Tesseract include directories.
# - Tesseract_VERSION : The version of this Tesseract build: "@VERSION_PLAIN@"
# - Tesseract_VERSION_MAJOR : Major version part of Tesseract_VERSION: "@VERSION_MAJOR@"
# - Tesseract_VERSION_MINOR : Minor version part of Tesseract_VERSION: "@VERSION_MINOR@"
#
# ===================================================================================

include(${CMAKE_CURRENT_LIST_DIR}/TesseractTargets.cmake)

find_package(Leptonica REQUIRED)

# ======================================================
# Version variables:
# ======================================================
@PACKAGE_INIT@

SET(Tesseract_VERSION @VERSION_PLAIN@)
SET(Tesseract_VERSION_MAJOR @VERSION_MAJOR@)
SET(Tesseract_VERSION_MINOR @VERSION_MINOR@)

# ======================================================
# Include directories to add to the user project:
# ======================================================

# Provide the include directories to the caller
set(Tesseract_INCLUDE_DIRS @INCLUDE_DIR@)
set_and_check(Tesseract_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR@")
set(Tesseract_LIBRARIES libtesseract)

# ====================================================================
# Link libraries:
# ====================================================================
if(Tesseract_FOUND AND NOT TARGET Tesseract::Tesseract)
add_library(Tesseract::Tesseract UNKNOWN IMPORTED)
set_target_properties(Tesseract::Tesseract PROPERTIES
IMPORTED_LOCATION ${Tesseract_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES "${Tesseract_INCLUDE_DIR}"
)
endif()

set(Tesseract_LIBRARIES libtesseract)
check_required_components(Tesseract)

0 comments on commit c8a164b

Please sign in to comment.