Implement CPPAN support for easy Windows building.

This commit is contained in:
Egor Pugin 2016-06-30 00:29:55 +03:00
parent 1958b3bfc3
commit 57605d99e9
3 changed files with 20 additions and 6 deletions

1
.gitignore vendored
View File

@ -73,4 +73,5 @@ kernel*.bin
# build dirs
/build*
/cppan
/win*

View File

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

2
cppan.yml Normal file
View File

@ -0,0 +1,2 @@
dependencies:
pvt.cppan.demo.leptonica: master