forked from jasper-software/jasper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
583 lines (513 loc) · 19.8 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
cmake_minimum_required(VERSION 3.12)
################################################################################
# Specify software and shared library version information.
################################################################################
# The major, minor, and micro version numbers of the project.
set(JAS_VERSION_MAJOR 3)
set(JAS_VERSION_MINOR 0)
set(JAS_VERSION_PATCH 0)
# The shared library versioning information.
# Guidelines on how to change this information can be found below.
set(JAS_SO_VERSION 7)
set(JAS_SO_MINOR 0)
set(JAS_SO_RELEASE 0)
# Guidelines for Updating the Shared Library Versioning Information
# =================================================================
#
# If the code did not change (e.g., only documentation was updated):
# do not change the shared library versioning information.
# If the code changed and the binary interface for the library did not change
# from the previous release (e.g., most bug fixes):
# increment JAS_SO_RELEASE.
# If the binary interface changed, but remains compatible with the previous
# release (e.g., only new functions were added):
# - increment JAS_SO_MINOR; and
# - set JAS_SO_RELEASE to 0.
# If the binary interface changed in a way that breaks compatibility with the
# previous release (e.g., a function was deleted):
# - increment JAS_SO_VERSION; and
# - set both JAS_SO_MINOR and JAS_SO_RELEASE to 0.
# Generate the project version.
set(JAS_VERSION
"${JAS_VERSION_MAJOR}.${JAS_VERSION_MINOR}.${JAS_VERSION_PATCH}")
# Generate the shared library build version.
set(JAS_SO_NAME "${JAS_SO_VERSION}.${JAS_SO_MINOR}.${JAS_SO_RELEASE}")
message("Software version: ${JAS_VERSION}")
message("Shared library ABI version: ${JAS_SO_VERSION}")
message("Shared library build version: ${JAS_SO_NAME}")
project(JasPer VERSION ${JAS_VERSION} LANGUAGES C)
################################################################################
# Include modules and set policies.
################################################################################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/build/cmake/modules)
# This include should be placed as early as possible.
include(InSourceBuild)
include(CheckCCompilerFlag)
include(EnableAssertions)
# Adhere to GNU filesystem layout conventions.
include(GNUInstallDirs)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CTest)
include(Sanitizers)
include(GenerateExportHeader)
################################################################################
# Define options.
################################################################################
if(DEFINED BUILD_SHARED_LIBS)
option(JAS_ENABLE_SHARED "Enable building of shared library"
${BUILD_SHARED_LIBS})
else()
option(JAS_ENABLE_SHARED "Enable building of shared library" ON)
endif()
option(JAS_ENABLE_HIDDEN "Hide internal symbols" ON)
option(JAS_ENABLE_32BIT "Use 32 bit integers on 64 bit CPUs" OFF)
option(JAS_ENABLE_LIBJPEG "Enable the use of the JPEG Library" ON)
option(JAS_ENABLE_LIBHEIF "Enable the use of the HEIF Library" ON)
option(JAS_ENABLE_OPENGL "Enable the use of the OpenGL/GLUT Library" ON)
option(JAS_ENABLE_AUTOMATIC_DEPENDENCIES "Enable automatic dependencies" ON)
option(JAS_ENABLE_DOC "Enable building of the documentation" ON)
option(JAS_ENABLE_PROGRAMS "Enable building of the programs" ON)
option(JAS_ENABLE_MULTITHREADING_SUPPORT "Enable multithreading support" ON)
option(JAS_PREFER_PTHREAD
"Prefer POSIX Threading Library (over C11) for threading support" OFF)
option(JAS_STRICT "Treat compiler warnings as errors" OFF)
option(JAS_INCLUDE_BMP_CODEC "Include BMP codec support" ON)
option(JAS_INCLUDE_JP2_CODEC "Include JP2 codec support" ON)
option(JAS_INCLUDE_JPC_CODEC "Include JPC codec support" ON)
option(JAS_INCLUDE_JPG_CODEC "Include JPG codec support" ON)
option(JAS_INCLUDE_HEIC_CODEC "Include experimental HEIC codec support" ON)
option(JAS_INCLUDE_MIF_CODEC "Include MIF codec support" ON)
option(JAS_INCLUDE_PGX_CODEC "Include PGX codec support" ON)
option(JAS_INCLUDE_PNM_CODEC "Include PNM codec support" ON)
option(JAS_INCLUDE_RAS_CODEC "Include RAS codec support" ON)
set(JAS_DEFAULT_MAX_MEM_USAGE
"1073741824"
CACHE STRING
"Set memory usage limit in bytes"
)
# The following options are for testing/debugging and should normally only
# be changed by the developers of JasPer.
option(JAS_USE_JAS_INIT
"Use jas_init instead of jas_init_custom for initialization (should be false, except for testing)"
OFF)
option(JAS_ENABLE_NON_THREAD_SAFE_DEBUGGING
"Enable non-thread safe debug code" OFF)
if(JAS_USE_JAS_INIT)
add_compile_definitions(JAS_USE_JAS_INIT)
endif()
# WARNING: THE FOLLOWING OPTION SHOULD ONLY BE ENABLED BY THE JASPER SOFTWARE
# DEVELOPMENT TEAM. IT IS NECESSARY FOR INTERNAL TESTING PURPOSES AND POSES
# SIGNIFICANT SECURITY RISKS IF ENABLED.
option(JAS_ENABLE_DANGEROUS_INTERNAL_TESTING_MODE
"DO NOT ENABLE FOR SECURITY REASONS! (For internal use by JasPer development team only"
OFF)
################################################################################
#
################################################################################
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
# Prefer C11 (if available) but do not require it.
set(CMAKE_C_STANDARD 11)
if(APPLE AND CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(MACOS TRUE)
else()
set(MACOS FALSE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX TRUE)
else()
set(LINUX FALSE)
endif()
if((CMAKE_GENERATOR MATCHES "Xcode") OR
(CMAKE_GENERATOR MATCHES "Visual Studio") OR
(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config"))
set(JAS_MULTICONFIGURATION_GENERATOR TRUE)
message("JAS_MULTICONFIGURATION_GENERATOR ${JAS_MULTICONFIGURATION_GENERATOR}")
else()
set(JAS_MULTICONFIGURATION_GENERATOR FALSE)
endif()
message("JAS_MULTICONFIGURATION_GENERATOR ${JAS_MULTICONFIGURATION_GENERATOR}")
if(JAS_ENABLE_AUTOMATIC_DEPENDENCIES)
if(LINUX)
message(WARNING
"If this software is being built as a package for a "
"Linux distribution, you should probably set "
"JAS_ENABLE_AUTOMATIC_DEPENDENCIES to false.")
endif()
set(JAS_REQUIRED "")
else()
set(JAS_REQUIRED REQUIRED)
endif()
if(JAS_ENABLE_SHARED AND MACOS)
set(CMAKE_MACOSX_RPATH TRUE)
endif()
# If a multiconfiguration generator is used, ensure that various output
# files are not placed in subdirectories (such as Debug and Release)
# as this will cause the CTest test suite to fail.
if(JAS_MULTICONFIGURATION_GENERATOR)
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_DEBUG_POSTFIX d)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY .)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY .)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY .)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${config}" config)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} .)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${config} .)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${config} .)
endforeach()
endif()
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${JAS_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "JasPer Image Processing Tool Kit")
set(CPACK_PACKAGE_VENDOR "Michael Adams")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${JAS_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${JAS_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${JAS_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY
"CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_GENERATOR "TGZ")
include(CPack)
if(CMAKE_BUILD_TYPE)
message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
elseif(CMAKE_CONFIGURATION_TYPES)
message("CMAKE_CONFIGURATION_TYPES: ${CMAKE_CONFIGURATION_TYPES}")
endif()
message("CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message("CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message("CMAKE_LINKER: ${CMAKE_LINKER}")
# Customize the compiler flags for warning messages.
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
check_c_compiler_flag("-Wno-stringop-truncation"
JAS_GCC_WARN_NO_STRINGOP_TRUNCATION)
add_compile_options(-Wall)
add_compile_options(-pedantic)
add_compile_options(-W)
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wformat)
add_compile_options(-Wmissing-prototypes)
add_compile_options(-Wstrict-prototypes)
if(JAS_GCC_WARN_NO_STRINGOP_TRUNCATION)
add_compile_options(-Wno-stringop-truncation)
endif()
add_compile_options(-Wmissing-declarations)
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-unused-command-line-argument)
endif()
if(JAS_STRICT)
# Treat all compiler warnings as errors.
add_compile_options(-pedantic-errors)
endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
# possibly lossy conversion
add_compile_options(/wd4244)
# different const qualifiers
add_compile_options(/wd4090)
# signed/unsigned mismatch
add_compile_options(/wd4018)
# function may be unsafe (e.g., sprintf, strncat)
add_compile_options(/wd4996)
if(JAS_STRICT)
# Treat all compiler warnings as errors.
add_compile_options(/WX)
endif()
endif()
if(JAS_ENABLE_HIDDEN)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
if(NOT (CMAKE_BUILD_TYPE MATCHES "Debug"))
if(LINUX)
check_c_compiler_flag("-ffunction-sections" HAVE_FUNCTION_SECTIONS)
check_c_compiler_flag("-fdata-sections" HAVE_DATA_SECTIONS)
check_c_compiler_flag("-Wl,--gc-sections" HAVE_GC_SECTIONS)
if(HAVE_FUNCTION_SECTIONS AND HAVE_DATA_SECTIONS AND
HAVE_GC_SECTIONS)
add_compile_options(-ffunction-sections)
add_compile_options(-fdata-sections)
add_compile_options(-Wl,--gc-sections)
endif()
endif()
endif()
endif()
message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message("CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
message("CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
################################################################################
# Check for the OpenGL and GLUT libraries.
################################################################################
if(JAS_ENABLE_OPENGL)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL ${JAS_REQUIRED})
message("OpenGL library found: ${OPENGL_FOUND}")
else()
set(OPENGL_FOUND false)
endif()
if(JAS_ENABLE_OPENGL AND OPENGL_FOUND)
set(JAS_HAVE_OPENGL 0)
message("OpenGL include directory: ${OPENGL_INCLUDE_DIR}")
message("OpenGL libraries: ${OPENGL_LIBRARIES}")
find_package(GLUT ${JAS_REQUIRED})
message("GLUT library found: ${GLUT_FOUND}")
if(GLUT_FOUND)
message("GLUT include directory: ${GLUT_INCLUDE_DIR}")
message("GLUT libraries: ${GLUT_LIBRARIES}")
set(CMAKE_REQUIRED_INCLUDES ${GLUT_INCLUDE_DIR})
check_include_files(GL/glut.h JAS_HAVE_GL_GLUT_H)
check_include_files(glut.h JAS_HAVE_GLUT_H)
if(JAS_HAVE_GL_GLUT_H OR JAS_HAVE_GLUT_H)
set(JAS_HAVE_OPENGL 1)
include_directories(${GLUT_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
else()
message(WARNING "The header files GL/glut.h and glut.h both appear to be missing.")
message(WARNING "Disabling OpenGL.")
endif()
endif()
# On some systems (e.g., Fedora 21), there is a bug in the cmake code
# that detects GLUT libraries. The following ugliness is a workaround for
# this problem.
if(NOT GLUT_Xmu_LIBRARY OR NOT GLUT_Xmi_LIBRARY)
if(NOT GLUT_Xmu_LIBRARY)
set(GLUT_Xmu_LIBRARY "")
message(WARNING "Clearing bogus value for GLUT_Xmu_LIBRARY.")
message(WARNING "Your version of CMake may be buggy.")
endif()
if(NOT GLUT_Xmi_LIBRARY)
set(GLUT_Xmi_LIBRARY "")
message(WARNING "Clearing bogus value for GLUT_Xmi_LIBRARY.")
message(WARNING "Your version of CMake may be buggy.")
endif()
set(GLUT_LIBRARIES "${GLUT_glut_LIBRARY}")
endif()
else()
set(JAS_HAVE_OPENGL 0)
set(OPENGL_INCLUDE_DIR "")
set(OPENGL_LIBRARIES "")
set(GLUT_INCLUDE_DIR "")
set(GLUT_LIBRARIES "")
endif()
if(JAS_HAVE_OPENGL AND MACOS)
add_compile_definitions(GL_SILENCE_DEPRECATION)
endif()
################################################################################
# Perform platform checks.
################################################################################
find_program(BASH_PROGRAM bash)
check_include_files(fcntl.h JAS_HAVE_FCNTL_H)
check_include_files(io.h JAS_HAVE_IO_H)
check_include_files(unistd.h JAS_HAVE_UNISTD_H)
check_include_files(sys/time.h JAS_HAVE_SYS_TIME_H)
check_include_files(sys/types.h JAS_HAVE_SYS_TYPES_H)
check_type_size(max_align_t MAX_ALIGN_T)
if(HAVE_MAX_ALIGN_T)
set(JAS_HAVE_MAX_ALIGN_T 1 CACHE INTERNAL "Test JAS_HAVE_MAX_ALIGN_T")
else()
set(JAS_HAVE_MAX_ALIGN_T 0 CACHE INTERNAL "Test JAS_HAVE_MAX_ALIGN_T")
endif()
message("JAS_HAVE_MAX_ALIGN_T: ${JAS_HAVE_MAX_ALIGN_T}")
check_type_size(ssize_t SSIZE_T)
if(HAVE_SSIZE_T)
set(JAS_HAVE_SSIZE_T 1 CACHE INTERNAL "Test JAS_HAVE_SSIZE_T")
else()
set(JAS_HAVE_SSIZE_T 0 CACHE INTERNAL "Test JAS_HAVE_SSIZE_T")
endif()
message("JAS_HAVE_SSIZE_T: ${JAS_HAVE_SSIZE_T}")
check_function_exists(gettimeofday JAS_HAVE_GETTIMEOFDAY)
check_function_exists(getrusage JAS_HAVE_GETRUSAGE)
check_function_exists(mkostemp JAS_HAVE_MKOSTEMP)
if(MSVC)
check_symbol_exists(snprintf stdio.h JAS_HAVE_SNPRINTF)
else()
check_function_exists(snprintf JAS_HAVE_SNPRINTF)
endif()
################################################################################
# Check for invalid codec combinations.
################################################################################
if(JAS_INCLUDE_JP2_CODEC AND NOT JAS_INCLUDE_JPC_CODEC)
message(FATAL_ERROR
"The JPC codec must be included in order to include the JP2 codec.")
endif()
################################################################################
# Configure threading support
################################################################################
set(JAS_THREADS FALSE)
set(JAS_THREADS_C11 FALSE)
set(JAS_THREADS_PTHREAD FALSE)
set(JAS_THREADS_WIN32 FALSE)
if(JAS_ENABLE_MULTITHREADING_SUPPORT)
check_c_source_compiles("
#include <threads.h>
int main() {
thrd_t thread;
mtx_t mutex;
tss_t tss;
}
" JAS_TRY_COMPILE_C11_THREADS)
check_include_files(pthread.h JAS_HAVE_PTHREAD_H)
# Check for support for various threading libraries.
if(MACOS)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
else()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads)
endif()
if(Threads_FOUND)
if(CMAKE_USE_PTHREADS_INIT AND JAS_HAVE_PTHREAD_H)
set(JAS_HAVE_PTHREAD_THREADS TRUE)
endif()
if(CMAKE_USE_WIN32_THREADS_INIT)
set(JAS_HAVE_WIN32_THREADS TRUE)
endif()
set(THREAD_LIBRARY "${CMAKE_THREAD_LIBS_INIT}")
if(JAS_TRY_COMPILE_C11_THREADS)
set(JAS_HAVE_C11_THREADS TRUE)
endif()
endif()
# Apply preferences to select one particular threading library.
if(JAS_HAVE_PTHREAD_THREADS AND JAS_PREFER_PTHREAD)
set(JAS_THREADS_PTHREAD TRUE)
elseif(JAS_HAVE_C11_THREADS)
set(JAS_THREADS_C11 TRUE)
elseif(JAS_HAVE_WIN32_THREADS)
set(JAS_THREADS_WIN32 TRUE)
endif()
if(JAS_THREADS_C11 OR JAS_THREADS_PTHREAD OR JAS_THREADS_WIN32)
set(JAS_THREADS TRUE)
message("Threading support enabled.")
else()
message(ERROR "No threading support found.")
endif()
message("Prefer POSIX threading support: ${JAS_PREFER_PTHREAD}")
message("Threading support found: ${JAS_THREADS}")
message("C11 threading support detected: ${JAS_HAVE_C11_THREADS}")
message("POSIX threading support detected: ${JAS_HAVE_PTHREAD_THREADS}")
message("WIN32 threading support detected: ${JAS_HAVE_WIN32_THREADS}")
message("C11 threading support selected: ${JAS_THREADS_C11}")
message("POSIX threading support selected: ${JAS_THREADS_PTHREAD}")
message("Win32 threading support selected: ${JAS_THREADS_WIN32}")
message("Threading library: ${THREAD_LIBRARY}")
else()
message("Threading support has been disabled.")
endif()
################################################################################
# Check for the JPEG library.
################################################################################
# The following is needed to prevent the incorrect version of the JPEG library
# from being found.
if(MACOS)
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
if(JAS_ENABLE_LIBJPEG)
find_package(JPEG ${JAS_LIBJPEG_REQUIRED})
message("JPEG library found: ${JPEG_FOUND}")
else()
set(JPEG_FOUND FALSE)
endif()
set(JAS_HAVE_LIBJPEG 0)
if(JAS_ENABLE_LIBJPEG AND JPEG_FOUND)
message("JPEG include directory: ${JPEG_INCLUDE_DIR}")
message("JPEG libraries: ${JPEG_LIBRARIES}")
# In some versions of the JPEG library, the header file jpeglib.h
# does not include some of the header files upon which it depends
# (e.g., stdio.h and stdint.h). So, we cannot reliably use
# check_include_file here.
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIR})
check_c_source_compiles("
#include <stdio.h>
#include <stdint.h>
#include <jpeglib.h>
int main() {}
" JAS_HAVE_JPEGLIB_H)
if(JAS_HAVE_JPEGLIB_H)
set(JAS_HAVE_LIBJPEG 1)
include_directories(${JPEG_INCLUDE_DIR})
else()
message(WARNING "The header file jpeglib.h appears to be missing.")
message(WARNING "Disabling LIBJPEG.")
set(JPEG_FOUND FALSE)
set(JPEG_LIBRARIES "")
set(JPEG_INCLUDE_DIR "")
set(JAS_ENABLE_LIBJPEG 0)
endif()
else()
set(JPEG_INCLUDE_DIR "")
set(JPEG_LIBRARIES "")
endif()
if(NOT JAS_HAVE_LIBJPEG)
set(JAS_INCLUDE_JPG_CODEC 0)
endif()
################################################################################
# Check for the HEIF library.
################################################################################
set(JAS_HAVE_LIBHEIF 0)
if(JAS_ENABLE_LIBHEIF)
find_library(HEIF_LIBRARY heif)
check_include_files(libheif/heif.h JAS_HAVE_HEIF_H)
endif()
if(HEIF_LIBRARY AND JAS_HAVE_HEIF_H)
set(JAS_HAVE_LIBHEIF 1)
set(HEIF_LIBRARIES "${HEIF_LIBRARY}")
endif()
if(NOT JAS_HAVE_LIBHEIF)
set(JAS_INCLUDE_HEIC_CODEC 0)
endif()
message("LIBHEIF ${JAS_HAVE_LIBHEIF}")
################################################################################
# Check for the Math library.
################################################################################
find_library(MATH_LIBRARY m)
if(NOT MATH_LIBRARY)
set(MATH_LIBRARY "")
endif()
################################################################################
# Perform shared library setup.
################################################################################
if(JAS_ENABLE_SHARED)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# The RPATH to be used when installing, but only if it's not a
# system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if(isSystemDir EQUAL -1)
set(CMAKE_INSTALL_RPATH
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
################################################################################
# Miscellany.
################################################################################
add_subdirectory(src/libjasper)
if(JAS_ENABLE_PROGRAMS)
add_subdirectory(src/appl)
endif()
if(JAS_ENABLE_DOC)
add_subdirectory(doc)
endif()
# The package configuation (pc) file should be installed in
# ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build/jasper.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/build/jasper.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/build/jasper.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES "README" DESTINATION "${CMAKE_INSTALL_DOCDIR}")