Skip to content

Commit

Permalink
Implement CPPAN support for easy Windows building.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Jun 29, 2016
1 parent 1958b3b commit 57605d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -73,4 +73,5 @@ kernel*.bin

# build dirs
/build*
/cppan
/win*
23 changes: 17 additions & 6 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cppan.yml
@@ -0,0 +1,2 @@
dependencies:
pvt.cppan.demo.leptonica: master

0 comments on commit 57605d9

Please sign in to comment.