microsoft/onnxruntime-extensions

Public

mirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/document-operator-contracts

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/ext_imgcodecs.cmake

174lines · modecode

1# Copyright (c) Microsoft Corporation. All rights reserved.
2# Licensed under the MIT License.
3
4set(_IMGCODEC_ROOT_DIR ${dlib_SOURCE_DIR}/dlib/external)
5
6# ----------------------------------------------------------------------------
7# project libpng
8#
9# ----------------------------------------------------------------------------
10set (PNG_LIBRARY "libpng_static_c")
11
12if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|ppc64le")
13 message(STATUS "Using upstream libpng for PowerPC")
14 include(FetchContent)
15 FetchContent_Declare(
16 libpng_external
17 GIT_REPOSITORY https://github.com/pnggroup/libpng.git
18 GIT_TAG v1.6.56 # latest version
19 )
20
21 FetchContent_MakeAvailable(libpng_external)
22
23 set(libPNG_SOURCE_DIR ${libpng_external_SOURCE_DIR})
24
25else()
26 # default (dlib bundled)
27 set(libPNG_SOURCE_DIR ${_IMGCODEC_ROOT_DIR}/libpng)
28endif()
29
30set (zlib_SOURCE_DIR ${_IMGCODEC_ROOT_DIR}/zlib)
31
32if(NOT WIN32)
33 find_library(M_LIBRARY
34 NAMES m
35 PATHS /usr/lib /usr/local/lib
36 )
37 if(NOT M_LIBRARY)
38 message(STATUS "math lib 'libm' not found; floating point support disabled")
39 endif()
40else()
41 # not needed on windows
42 set(M_LIBRARY "")
43endif()
44
45# Add architecture-specific PNG optimizations
46set(lib_srcs)
47
48# PowerPC VSX optimizations
49if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|ppc64le")
50 list(APPEND lib_srcs
51 ${libPNG_SOURCE_DIR}/powerpc/powerpc_init.c
52 ${libPNG_SOURCE_DIR}/powerpc/filter_vsx_intrinsics.c
53 )
54
55else()
56 list(APPEND lib_srcs
57 ${libPNG_SOURCE_DIR}/arm/arm_init.c
58 ${libPNG_SOURCE_DIR}/arm/filter_neon_intrinsics.c
59 ${libPNG_SOURCE_DIR}/arm/palette_neon_intrinsics.c
60 )
61endif()
62
63# Common PNG sources
64list(APPEND lib_srcs
65 ${libPNG_SOURCE_DIR}//png.c
66 ${libPNG_SOURCE_DIR}//pngerror.c
67 ${libPNG_SOURCE_DIR}//pngget.c
68 ${libPNG_SOURCE_DIR}//pngmem.c
69 ${libPNG_SOURCE_DIR}//pngpread.c
70 ${libPNG_SOURCE_DIR}//pngread.c
71 ${libPNG_SOURCE_DIR}//pngrio.c
72 ${libPNG_SOURCE_DIR}//pngrtran.c
73 ${libPNG_SOURCE_DIR}//pngrutil.c
74 ${libPNG_SOURCE_DIR}//pngset.c
75 ${libPNG_SOURCE_DIR}//pngtrans.c
76 ${libPNG_SOURCE_DIR}//pngwio.c
77 ${libPNG_SOURCE_DIR}//pngwrite.c
78 ${libPNG_SOURCE_DIR}//pngwtran.c
79 ${libPNG_SOURCE_DIR}//pngwutil.c
80 ${zlib_SOURCE_DIR}/adler32.c
81 ${zlib_SOURCE_DIR}/compress.c
82 ${zlib_SOURCE_DIR}/crc32.c
83 ${zlib_SOURCE_DIR}/deflate.c
84 ${zlib_SOURCE_DIR}/gzclose.c
85 ${zlib_SOURCE_DIR}/gzlib.c
86 ${zlib_SOURCE_DIR}/gzread.c
87 ${zlib_SOURCE_DIR}/gzwrite.c
88 ${zlib_SOURCE_DIR}/infback.c
89 ${zlib_SOURCE_DIR}/inffast.c
90 ${zlib_SOURCE_DIR}/inflate.c
91 ${zlib_SOURCE_DIR}/inftrees.c
92 ${zlib_SOURCE_DIR}/trees.c
93 ${zlib_SOURCE_DIR}/uncompr.c
94 ${zlib_SOURCE_DIR}/zutil.c
95)
96
97add_library(${PNG_LIBRARY} STATIC EXCLUDE_FROM_ALL ${lib_srcs})
98target_include_directories(${PNG_LIBRARY} BEFORE PUBLIC ${zlib_SOURCE_DIR})
99
100if(MSVC)
101 target_compile_definitions(${PNG_LIBRARY} PRIVATE -D_CRT_SECURE_NO_DEPRECATE)
102else()
103 target_compile_options(${PNG_LIBRARY} PRIVATE -Wno-deprecated-non-prototype)
104endif()
105
106set_target_properties(${PNG_LIBRARY}
107 PROPERTIES
108 POSITION_INDEPENDENT_CODE ON
109 FOLDER externals)
110
111# ----------------------------------------------------------------------------
112# project libjpeg
113#
114# ----------------------------------------------------------------------------
115set(JPEG_LIBRARY "libjpeg_static_c")
116set(libJPEG_SOURCE_DIR ${_IMGCODEC_ROOT_DIR}/libjpeg)
117
118set(lib_srcs
119 ${libJPEG_SOURCE_DIR}/jaricom.c
120 ${libJPEG_SOURCE_DIR}/jcapimin.c
121 ${libJPEG_SOURCE_DIR}/jcapistd.c
122 ${libJPEG_SOURCE_DIR}/jcarith.c
123 ${libJPEG_SOURCE_DIR}/jccoefct.c
124 ${libJPEG_SOURCE_DIR}/jccolor.c
125 ${libJPEG_SOURCE_DIR}/jcdctmgr.c
126 ${libJPEG_SOURCE_DIR}/jchuff.c
127 ${libJPEG_SOURCE_DIR}/jcinit.c
128 ${libJPEG_SOURCE_DIR}/jcmainct.c
129 ${libJPEG_SOURCE_DIR}/jcmarker.c
130 ${libJPEG_SOURCE_DIR}/jcmaster.c
131 ${libJPEG_SOURCE_DIR}/jcomapi.c
132 ${libJPEG_SOURCE_DIR}/jcparam.c
133 ${libJPEG_SOURCE_DIR}/jcprepct.c
134 ${libJPEG_SOURCE_DIR}/jcsample.c
135 ${libJPEG_SOURCE_DIR}/jdapimin.c
136 ${libJPEG_SOURCE_DIR}/jdapistd.c
137 ${libJPEG_SOURCE_DIR}/jdarith.c
138 ${libJPEG_SOURCE_DIR}/jdatadst.c
139 ${libJPEG_SOURCE_DIR}/jdatasrc.c
140 ${libJPEG_SOURCE_DIR}/jdcoefct.c
141 ${libJPEG_SOURCE_DIR}/jdcolor.c
142 ${libJPEG_SOURCE_DIR}/jddctmgr.c
143 ${libJPEG_SOURCE_DIR}/jdhuff.c
144 ${libJPEG_SOURCE_DIR}/jdinput.c
145 ${libJPEG_SOURCE_DIR}/jdmainct.c
146 ${libJPEG_SOURCE_DIR}/jdmarker.c
147 ${libJPEG_SOURCE_DIR}/jdmaster.c
148 ${libJPEG_SOURCE_DIR}/jdmerge.c
149 ${libJPEG_SOURCE_DIR}/jdpostct.c
150 ${libJPEG_SOURCE_DIR}/jdsample.c
151 ${libJPEG_SOURCE_DIR}/jerror.c
152 ${libJPEG_SOURCE_DIR}/jfdctflt.c
153 ${libJPEG_SOURCE_DIR}/jfdctfst.c
154 ${libJPEG_SOURCE_DIR}/jfdctint.c
155 ${libJPEG_SOURCE_DIR}/jidctflt.c
156 ${libJPEG_SOURCE_DIR}/jidctfst.c
157 ${libJPEG_SOURCE_DIR}/jidctint.c
158 ${libJPEG_SOURCE_DIR}/jmemmgr.c
159 ${libJPEG_SOURCE_DIR}/jmemnobs.c
160 ${libJPEG_SOURCE_DIR}/jquant1.c
161 ${libJPEG_SOURCE_DIR}/jquant2.c
162 ${libJPEG_SOURCE_DIR}/jutils.c
163 )
164file(GLOB lib_hdrs ${libJPEG_SOURCE_DIR}/*.h)
165add_library(${JPEG_LIBRARY} STATIC EXCLUDE_FROM_ALL ${lib_srcs} ${lib_hdrs})
166
167if(NOT MSVC)
168 set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
169endif()
170target_compile_definitions(${JPEG_LIBRARY} PRIVATE -DNO_MKTEMP)
171set_target_properties(${JPEG_LIBRARY}
172 PROPERTIES
173 POSITION_INDEPENDENT_CODE ON
174 FOLDER externals)