Skip to content

Commit

Permalink
Merge pull request #3119 from Shatur95/modernize-cmake-config
Browse files Browse the repository at this point in the history
Modernize CMake Config files
  • Loading branch information
zdenop authored Oct 10, 2020
2 parents e5d6e90 + a0f43ca commit ec01b51
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 46 deletions.
23 changes: 14 additions & 9 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 Expand Up @@ -652,13 +657,13 @@ if (SW_BUILD)
org.sw.demo.libarchive.libarchive
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_CURRENT_BINARY_DIR}/cppan.cmake)\n")
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake NAMESPACE Tesseract::)
else()
target_link_libraries (libtesseract PUBLIC
${Leptonica_LIBRARIES}
${LibArchive_LIBRARIES}
)
export(TARGETS libtesseract FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
export(TARGETS libtesseract FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake NAMESPACE Tesseract::)
endif()

if (WIN32 AND CLANG AND OPENMP_BUILD)
Expand Down Expand Up @@ -703,7 +708,7 @@ configure_file(tesseract.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc @ONLY
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc DESTINATION lib/pkgconfig)
install(TARGETS tesseract RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(TARGETS libtesseract EXPORT TesseractTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT TesseractTargets DESTINATION lib/tesseract)
install(EXPORT TesseractTargets NAMESPACE Tesseract:: DESTINATION lib/cmake/tesseract)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cmake DESTINATION lib)

install(FILES
Expand Down
14 changes: 0 additions & 14 deletions cmake/templates/TesseractConfig-version.cmake.in

This file was deleted.

28 changes: 5 additions & 23 deletions cmake/templates/TesseractConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,21 @@
# 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::libtesseract)
#
# 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:
# ======================================================

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@)

# ====================================================================
# Link libraries:
# ====================================================================
@PACKAGE_INIT@

set_and_check(Tesseract_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR@")
set(Tesseract_LIBRARIES libtesseract)

check_required_components(Tesseract)

0 comments on commit ec01b51

Please sign in to comment.