-
Notifications
You must be signed in to change notification settings - Fork 394
/
CMakeLists.txt
99 lines (87 loc) · 3.61 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# leptonica
#
################################################################################
########################################
# SHARED LIBRARY leptonica
########################################
file(GLOB hdr "*.h")
file(GLOB src "*.c")
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
add_library (leptonica ${src} ${hdr})
set_target_properties (leptonica PROPERTIES VERSION 6.0.0)
set_target_properties (leptonica PROPERTIES SOVERSION 6)
set_target_properties (leptonica PROPERTIES OUTPUT_NAME leptonica$<$<BOOL:${MSVC}>:-${PROJECT_VERSION}$<$<CONFIG:DEBUG>:d>>)
if (BUILD_SHARED_LIBS)
target_compile_definitions (leptonica PRIVATE -DLIBLEPT_EXPORTS)
endif()
if (GIF_LIBRARIES)
target_include_directories (leptonica PRIVATE ${GIF_INCLUDE_DIR})
target_link_libraries (leptonica PRIVATE ${GIF_LIBRARIES})
endif()
if (JPEG_LIBRARIES)
target_include_directories (leptonica PRIVATE ${JPEG_INCLUDE_DIR})
target_link_libraries (leptonica PRIVATE ${JPEG_LIBRARIES})
endif()
if (OPENJPEG_LIBRARIES)
# openjp2 < 2.5.0 does not sets the INTERFACE_INCLUDE_DIRECTORIES property
target_include_directories (leptonica PRIVATE ${OPENJPEG_INCLUDE_DIRS})
target_link_libraries (leptonica PRIVATE openjp2)
endif()
if (PNG_LIBRARIES)
target_include_directories (leptonica PRIVATE ${PNG_INCLUDE_DIRS})
target_link_libraries (leptonica PRIVATE ${PNG_LIBRARIES})
endif()
if (TIFF_LIBRARIES)
target_include_directories (leptonica PRIVATE ${TIFF_INCLUDE_DIR})
target_link_libraries (leptonica PRIVATE ${TIFF_LIBRARIES})
endif()
if (WebP_LIBRARIES)
if(TARGET WebP::webp)
target_link_libraries (leptonica PRIVATE WebP::webp WebP::libwebpmux)
else()
target_link_libraries (leptonica PRIVATE ${WebP_LIBRARIES})
target_include_directories(leptonica PRIVATE ${WebP_INCLUDE_DIR})
endif()
endif()
if (ZLIB_LIBRARIES)
target_include_directories (leptonica PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries (leptonica PRIVATE ${ZLIB_LIBRARIES})
endif()
if (UNIX)
target_link_libraries (leptonica PRIVATE m)
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX})
set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(old_target ${lib}lept${dll})
if (SYM_LINK)
add_custom_target(lept ALL
${CMAKE_COMMAND} -E create_symlink "$<TARGET_FILE:leptonica>" ${old_target}
DEPENDS ${PROJECT_NAME}
COMMENT "Creating lept symlink")
install(FILES ${CMAKE_BINARY_DIR}/src/${old_target} DESTINATION lib)
endif(SYM_LINK)
endif()
if (MSVC)
target_link_libraries (leptonica PRIVATE user32.lib gdi32.lib)
endif()
if (NOT SW_BUILD)
export(TARGETS leptonica FILE ${CMAKE_BINARY_DIR}/LeptonicaTargets.cmake)
else()
target_link_libraries (leptonica PRIVATE
org.sw.demo.gif
org.sw.demo.jpeg
org.sw.demo.glennrp.png
org.sw.demo.tiff
org.sw.demo.webmproject.webp
org.sw.demo.uclouvain.openjpeg.openjp2
)
file(WRITE ${CMAKE_BINARY_DIR}/LeptonicaTargets.cmake "include(${CMAKE_BINARY_DIR}/cppan.cmake)\n")
export(TARGETS leptonica APPEND FILE ${CMAKE_BINARY_DIR}/LeptonicaTargets.cmake)
endif()
install(TARGETS leptonica EXPORT LeptonicaTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT LeptonicaTargets DESTINATION ${leptonica_INSTALL_CMAKE_DIR})
install(FILES
${hdr}
${CMAKE_BINARY_DIR}/src/endianness.h
DESTINATION include/leptonica)
################################################################################