• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_minimum_required(VERSION 3.16.5)
2
3set(LibjpegSrc "${PROJECT_SOURCE_DIR}/third_party/libjpeg")
4
5include_directories(${LibjpegSrc})
6
7include(CheckIncludeFile)
8include(CheckSymbolExists)
9include(CheckCSourceCompiles)
10
11check_include_file(stddef.h HAVE_STDDEF_H)
12check_include_file(stdlib.h HAVE_STDLIB_H)
13check_include_file(string.h HAVE_STRING_H)
14check_symbol_exists(size_t stddef.h stdlib.h stdio.h HAVE_ANSI_SIZE_T)
15check_symbol_exists(setmode io.h USE_SETMODE)
16check_c_source_compiles(
17"
18void f()
19{
20    char x[ (char)0xff ]; /* x[-1] if signed */
21}
22"
23CHAR_IS_UNSIGNED)
24
25check_c_source_compiles(
26"
27void f()
28{
29    char x[ ((signed char)0xff) >> 1 ]; /* x[-1] if signed */
30}
31"
32RIGHT_SHIFT_IS_UNSIGNED)
33
34if(NOT HAVE_STRING_H)
35    set(NEED_BSD_STRINGS TRUE)
36else()
37    set(NEED_BSD_STRINGS FALSE)
38endif()
39
40if(NOT HAVE_ANSI_SIZE_T)
41    set(NEED_SYS_TYPES_H TRUE)
42else()
43    set(NEED_SYS_TYPES_H FALSE)
44endif()
45
46configure_file(${LibjpegSrc}/jconfig.txt ${LibjpegSrc}/jconfig.h)
47
48add_library(libjpeg STATIC
49    ${LibjpegSrc}/cdjpeg.c
50    ${LibjpegSrc}/jaricom.c
51    ${LibjpegSrc}/jcapimin.c
52    ${LibjpegSrc}/jcapistd.c
53    ${LibjpegSrc}/jcarith.c
54    ${LibjpegSrc}/jccoefct.c
55    ${LibjpegSrc}/jccolor.c
56    ${LibjpegSrc}/jcdctmgr.c
57    ${LibjpegSrc}/jchuff.c
58    ${LibjpegSrc}/jcinit.c
59    ${LibjpegSrc}/jcmainct.c
60    ${LibjpegSrc}/jcmarker.c
61    ${LibjpegSrc}/jcmaster.c
62    ${LibjpegSrc}/jcomapi.c
63    ${LibjpegSrc}/jcparam.c
64    ${LibjpegSrc}/jcprepct.c
65    ${LibjpegSrc}/jcsample.c
66    ${LibjpegSrc}/jctrans.c
67    ${LibjpegSrc}/jdapimin.c
68    ${LibjpegSrc}/jdapistd.c
69    ${LibjpegSrc}/jdarith.c
70    ${LibjpegSrc}/jdatadst.c
71    ${LibjpegSrc}/jdatasrc.c
72    ${LibjpegSrc}/jdcoefct.c
73    ${LibjpegSrc}/jdcolor.c
74    ${LibjpegSrc}/jddctmgr.c
75    ${LibjpegSrc}/jdhuff.c
76    ${LibjpegSrc}/jdinput.c
77    ${LibjpegSrc}/jdmainct.c
78    ${LibjpegSrc}/jdmarker.c
79    ${LibjpegSrc}/jdmaster.c
80    ${LibjpegSrc}/jdmerge.c
81    ${LibjpegSrc}/jdpostct.c
82    ${LibjpegSrc}/jdsample.c
83    ${LibjpegSrc}/jdtrans.c
84    ${LibjpegSrc}/jerror.c
85    ${LibjpegSrc}/jfdctflt.c
86    ${LibjpegSrc}/jfdctfst.c
87    ${LibjpegSrc}/jfdctint.c
88    ${LibjpegSrc}/jidctflt.c
89    ${LibjpegSrc}/jidctfst.c
90    ${LibjpegSrc}/jidctint.c
91    ${LibjpegSrc}/jmemansi.c
92    ${LibjpegSrc}/jmemmgr.c
93    ${LibjpegSrc}/jquant1.c
94    ${LibjpegSrc}/jquant2.c
95    ${LibjpegSrc}/jutils.c
96    ${LibjpegSrc}/rdbmp.c
97    ${LibjpegSrc}/rdcolmap.c
98    ${LibjpegSrc}/rdgif.c
99    ${LibjpegSrc}/rdppm.c
100    ${LibjpegSrc}/rdrle.c
101    ${LibjpegSrc}/rdswitch.c
102    ${LibjpegSrc}/rdtarga.c
103    ${LibjpegSrc}/transupp.c
104    )
105
106target_include_directories(libjpeg PUBLIC ${LibjpegSrc})
107