summaryrefslogtreecommitdiff
path: root/png/CMakeLists.txt
blob: 3994dfd7be4bc1e8612d3dcfe4330937884213b0 (plain)
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
#
# PNG library CMake configuration for the Fast Light Toolkit (FLTK).
#
# Copyright 1998-2022 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file.  If this
# file is missing or damaged, see the license at:
#
#     https://www.fltk.org/COPYING.php
#
# Please see the following page on how to report bugs and issues:
#
#     https://www.fltk.org/bugs.php
#

# source files for png
set(PNG_SRCS
  png.c
  pngerror.c
  pngget.c
  pngmem.c
  pngpread.c
  pngread.c
  pngrio.c
  pngrtran.c
  pngrutil.c
  pngset.c
  pngtrans.c
  pngwio.c
  pngwrite.c
  pngwtran.c
  pngwutil.c
)

#######################################################################
# Build some files on ARM (e.g. Apple M1 systems)
#######################################################################

# We can only determine the target architecture if it is set
# in CMAKE_OSX_ARCHITECTURES, otherwise we *assume* it is true and
# compile these files even if this results in some warnings.
# This includes all non-macOS platforms.

if (CMAKE_OSX_ARCHITECTURES)
  string(REGEX MATCH "arm64" is_arm "${CMAKE_OSX_ARCHITECTURES}")
else ()
  set (is_arm TRUE)
endif ()

if (is_arm)
  LIST (APPEND PNG_SRCS
    arm/arm_init.c
    arm/filter_neon_intrinsics.c
    arm/palette_neon_intrinsics.c
  )
endif ()

unset (is_arm)

#######################################################################
# Build the static library
#######################################################################

FL_ADD_LIBRARY (fltk_png STATIC "${PNG_SRCS}")
target_link_libraries (fltk_png ${FLTK_ZLIB_LIBRARIES})

#######################################################################
# Build the shared library (optional)
#######################################################################

if (OPTION_BUILD_SHARED_LIBS)

  FL_ADD_LIBRARY (fltk_png SHARED "${PNG_SRCS}")

  if (FLTK_USE_BUILTIN_ZLIB)
    target_link_libraries (fltk_png_SHARED fltk_z_SHARED)
  else()
    target_link_libraries (fltk_png_SHARED ${FLTK_ZLIB_LIBRARIES})
  endif ()

endif ()

#######################################################################
# Install the library headers
#######################################################################

install (FILES png.h pngconf.h pnglibconf.h pngprefix.h
         DESTINATION ${FLTK_INCLUDEDIR}/FL/images
)