From 57605d99e9c631de3d6e3963b6e473fcd4937047 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Thu, 30 Jun 2016 00:29:55 +0300 Subject: [PATCH] Implement CPPAN support for easy Windows building. --- .gitignore | 1 + CMakeLists.txt | 23 +++++++++++++++++------ cppan.yml | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 cppan.yml diff --git a/.gitignore b/.gitignore index cbf9cfeef9..6fa0865df7 100644 --- a/.gitignore +++ b/.gitignore @@ -73,4 +73,5 @@ kernel*.bin # build dirs /build* +/cppan /win* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b1528fba8..659e11a8e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,11 +46,15 @@ set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR}) set(MINIMUM_LEPTONICA_VERSION 1.71) -if (NOT Leptonica_DIR AND NOT MSVC) -find_package(PkgConfig REQUIRED) -pkg_check_modules(Leptonica REQUIRED lept) +if(NOT EXISTS ${PROJECT_SOURCE_DIR}/cppan) + if (NOT Leptonica_DIR AND NOT MSVC) + find_package(PkgConfig REQUIRED) + pkg_check_modules(Leptonica REQUIRED lept) + else() + find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG) + endif() else() -find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG) + add_subdirectory(cppan) endif() find_package(OpenCL QUIET) @@ -201,15 +205,22 @@ add_library (tesseract ${LIBRARY_TYPE} ${tesseract_src} ${te if (NOT STATIC) target_compile_definitions (tesseract PUBLIC -DTESS_EXPORTS) endif() -target_link_libraries (tesseract ${Leptonica_LIBRARIES} ${LIB_Ws2_32} ${LIB_pthread}) +target_link_libraries (tesseract ${LIB_Ws2_32} ${LIB_pthread}) set_target_properties (tesseract PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1}) set_target_properties (tesseract PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1}) if (WIN32) set_target_properties (tesseract PROPERTIES OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}) set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d) endif() -export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) +if (NOT USES_CPPAN) + target_link_libraries (tesseract ${Leptonica_LIBRARIES}) + export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) +else() + target_link_libraries (tesseract cppan) + file(WRITE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_BINARY_DIR}/cppan.cmake)\n") + export(TARGETS tesseract APPEND FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) +endif() ######################################## # EXECUTABLE tesseractmain diff --git a/cppan.yml b/cppan.yml new file mode 100644 index 0000000000..e41cb03be9 --- /dev/null +++ b/cppan.yml @@ -0,0 +1,2 @@ +dependencies: + pvt.cppan.demo.leptonica: master \ No newline at end of file