Merge pull request #3119 from Shatur95/modernize-cmake-config

Modernize CMake Config files
This commit is contained in:
zdenop 2020-10-10 12:52:53 +02:00 committed by GitHub
commit ec01b51a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 46 deletions

View File

@ -370,12 +370,17 @@ configure_file(
configure_file( configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/libtesseract.rc.in ${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/libtesseract.rc.in
${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig-version.cmake.in include(CMakePackageConfigHelpers)
${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfig-version.cmake @ONLY) configure_package_config_file(
configure_file( cmake/templates/TesseractConfig.cmake.in
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/TesseractConfig.cmake @ONLY) 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 # show summary of configuration
if(${CMAKE_BUILD_TYPE} MATCHES Debug) if(${CMAKE_BUILD_TYPE} MATCHES Debug)
@ -652,13 +657,13 @@ if (SW_BUILD)
org.sw.demo.libarchive.libarchive org.sw.demo.libarchive.libarchive
) )
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_CURRENT_BINARY_DIR}/cppan.cmake)\n") 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() else()
target_link_libraries (libtesseract PUBLIC target_link_libraries (libtesseract PUBLIC
${Leptonica_LIBRARIES} ${Leptonica_LIBRARIES}
${LibArchive_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() endif()
if (WIN32 AND CLANG AND OPENMP_BUILD) if (WIN32 AND CLANG AND OPENMP_BUILD)
@ -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(FILES ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc DESTINATION lib/pkgconfig)
install(TARGETS tesseract RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) 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(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(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cmake DESTINATION lib)
install(FILES install(FILES

View File

@ -1,14 +0,0 @@
set(Tesseract_VERSION @VERSION_PLAIN@)
set(PACKAGE_VERSION ${Tesseract_VERSION})
set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT True)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()

View File

@ -7,15 +7,11 @@
# In your CMakeLists.txt, add these lines: # In your CMakeLists.txt, add these lines:
# #
# find_package(Tesseract REQUIRED) # find_package(Tesseract REQUIRED)
# include_directories(${Tesseract_INCLUDE_DIRS}) # target_link_libraries(MY_TARGET_NAME Tesseract::libtesseract)
# target_link_libraries(MY_TARGET_NAME ${Tesseract_LIBRARIES})
# #
# This file will define the following variables: # This file will define the following variables:
# - Tesseract_LIBRARIES : The list of all imported targets for OpenCV modules. # - Tesseract_LIBRARIES : The list of all imported targets for OpenCV modules.
# - Tesseract_INCLUDE_DIRS : The Tesseract include directories. # - 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@"
# #
# =================================================================================== # ===================================================================================
@ -23,23 +19,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/TesseractTargets.cmake)
find_package(Leptonica REQUIRED) find_package(Leptonica REQUIRED)
# ====================================================== @PACKAGE_INIT@
# 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:
# ====================================================================
set_and_check(Tesseract_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR@")
set(Tesseract_LIBRARIES libtesseract) set(Tesseract_LIBRARIES libtesseract)
check_required_components(Tesseract)