From a0f43ca03cc6e7fc57dc7808452382a46945ff4b Mon Sep 17 00:00:00 2001 From: Shatur95 Date: Thu, 8 Oct 2020 01:16:01 +0300 Subject: [PATCH] Generate imported target automatically --- CMakeLists.txt | 6 +++--- cmake/templates/TesseractConfig.cmake.in | 10 +--------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c84dd82ad..43628ec815 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -657,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) @@ -708,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 diff --git a/cmake/templates/TesseractConfig.cmake.in b/cmake/templates/TesseractConfig.cmake.in index d83f538743..2d930391c4 100644 --- a/cmake/templates/TesseractConfig.cmake.in +++ b/cmake/templates/TesseractConfig.cmake.in @@ -7,7 +7,7 @@ # In your CMakeLists.txt, add these lines: # # find_package(Tesseract REQUIRED) -# target_link_libraries(MY_TARGET_NAME Tesseract::Tesseract) +# 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. @@ -24,12 +24,4 @@ find_package(Leptonica REQUIRED) set_and_check(Tesseract_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR@") set(Tesseract_LIBRARIES libtesseract) -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() - check_required_components(Tesseract)