-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
178 lines (165 loc) · 5.59 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
cmake_minimum_required (VERSION 3.8 FATAL_ERROR)
project(asciiart CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-Wall -Wextra)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
find_package(cxxopts REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(libavif QUIET)
if(libavif_FOUND)
message(STATUS "Found libavif version ${libavif_VERSION}") # TODO: is there a cleaner way to do this?
set(AVIF_FOUND ${libavif_FOUND})
endif()
find_package(GIF QUIET)
find_package(JPEG QUIET)
find_package(PNG QUIET)
find_package(TIFF QUIET)
find_package(ZLIB QUIET)
pkg_check_modules(EXIF libexif)
pkg_check_modules(HEIF libheif)
pkg_check_modules(JP2 libopenjp2)
pkg_check_modules(JXL libjxl)
pkg_check_modules(MNG libmng)
pkg_check_modules(OpenEXR OpenEXR)
pkg_check_modules(SVG librsvg-2.0)
pkg_check_modules(WEBP libwebp)
pkg_check_modules(XPM xpm)
include(CheckIncludeFiles)
check_include_files(signal.h HAS_SIGNAL)
check_include_files(sys/ioctl.h HAS_IOCTL)
check_include_files(sys/select.h HAS_SELECT)
check_include_files(termios.h HAS_TERMIOS)
check_include_files(unistd.h HAS_UNISTD)
if(WIN32)
check_include_files(windows.h HAS_WINDOWS)
endif()
check_include_files(libbpg.h BPG_FOUND)
check_include_files(flif.h FLIF_ENC_FOUND)
check_include_files(flif_dec.h FLIF_DEC_FOUND)
add_executable(asciiart
animate.cpp
args.cpp
display.cpp
font.cpp
main.cpp
codecs/image.cpp
codecs/sub_args.cpp
codecs/ani.cpp
codecs/bmp.cpp
codecs/bmp_common.cpp
codecs/ico.cpp
codecs/motologo.cpp
codecs/pcx.cpp
codecs/pkmn_gen1.cpp
codecs/pkmn_gen2.cpp
codecs/pnm.cpp
codecs/sif.cpp
codecs/srf.cpp
codecs/tga.cpp
)
target_include_directories(asciiart PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
find_package(Freetype QUIET)
if(FREETYPE_FOUND)
pkg_check_modules(FONTCONFIG fontconfig)
if(FONTCONFIG_FOUND)
target_include_directories(asciiart PRIVATE
${FREETYPE_INCLUDE_DIRS}
${FONTCONFIG_INCLUDE_DIRS}
)
target_link_libraries(asciiart
${FREETYPE_LIBRARIES}
${FONTCONFIG_LIBRARIES}
)
endif()
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
if(AVIF_FOUND)
target_sources(asciiart PRIVATE codecs/avif.cpp)
target_link_libraries(asciiart avif)
endif()
if(BPG_FOUND)
target_sources(asciiart PRIVATE codecs/bpg.cpp)
target_link_libraries(asciiart bpg)
endif()
if(EXIF_FOUND)
target_sources(asciiart PRIVATE codecs/exif.cpp)
target_include_directories(asciiart PRIVATE ${EXIF_INCLUDE_DIRS})
target_link_libraries(asciiart ${EXIF_LIBRARIES})
endif()
if(FLIF_ENC_FOUND OR FLIF_DEC_FOUND)
target_sources(asciiart PRIVATE codecs/flif.cpp)
if(FLIF_ENC_FOUND)
target_link_libraries(asciiart flif)
else()
target_link_libraries(asciiart flif_dec)
endif()
endif()
if(GIF_FOUND)
target_sources(asciiart PRIVATE codecs/gif.cpp)
target_include_directories(asciiart PRIVATE ${GIF_INCLUDE_DIRS})
target_link_libraries(asciiart ${GIF_LIBRARIES})
endif()
if(HEIF_FOUND)
target_sources(asciiart PRIVATE codecs/heif.cpp)
target_include_directories(asciiart PRIVATE ${HEIF_INCLUDE_DIRS})
target_link_libraries(asciiart ${HEIF_LIBRARIES})
endif()
if(JP2_FOUND)
target_sources(asciiart PRIVATE codecs/jp2.cpp codecs/jp2_color.cpp)
target_include_directories(asciiart PRIVATE ${JP2_INCLUDE_DIRS})
target_link_libraries(asciiart ${JP2_LIBRARIES})
endif()
if(JPEG_FOUND)
target_sources(asciiart PRIVATE codecs/jpeg.cpp)
target_include_directories(asciiart PRIVATE ${JPEG_INCLUDE_DIRS})
target_link_libraries(asciiart ${JPEG_LIBRARIES})
endif()
if(JXL_FOUND)
target_sources(asciiart PRIVATE codecs/jxl.cpp)
target_include_directories(asciiart PRIVATE ${JXL_INCLUDE_DIRS})
target_link_libraries(asciiart ${JXL_LIBRARIES})
endif()
if(MNG_FOUND)
target_sources(asciiart PRIVATE codecs/mng.cpp)
target_include_directories(asciiart PRIVATE ${MNG_INCLUDE_DIRS})
target_link_libraries(asciiart ${MNG_LIBRARIES})
endif()
if(OpenEXR_FOUND)
target_sources(asciiart PRIVATE codecs/openexr.cpp)
target_include_directories(asciiart SYSTEM PRIVATE ${OpenEXR_INCLUDE_DIRS}) # SYSTEM to suppress a bunch of warnings
target_link_libraries(asciiart ${OpenEXR_LIBRARIES})
endif()
if(PNG_FOUND)
target_sources(asciiart PRIVATE codecs/png.cpp)
target_include_directories(asciiart PRIVATE ${PNG_INCLUDE_DIRS})
target_link_libraries(asciiart ${PNG_LIBRARIES})
endif()
if(SVG_FOUND)
target_sources(asciiart PRIVATE codecs/svg.cpp)
target_include_directories(asciiart PRIVATE ${SVG_INCLUDE_DIRS})
target_link_libraries(asciiart ${SVG_LIBRARIES})
endif()
if(TIFF_FOUND)
target_sources(asciiart PRIVATE codecs/tiff.cpp)
target_include_directories(asciiart PRIVATE ${TIFF_INCLUDE_DIRS})
target_link_libraries(asciiart ${TIFF_LIBRARIES})
endif()
if(WEBP_FOUND)
target_sources(asciiart PRIVATE codecs/webp.cpp)
target_include_directories(asciiart PRIVATE ${WEBP_INCLUDE_DIRS})
target_link_libraries(asciiart ${WEBP_LIBRARIES})
endif()
if(XPM_FOUND)
target_sources(asciiart PRIVATE codecs/xpm.cpp)
target_include_directories(asciiart PRIVATE ${XPM_INCLUDE_DIRS})
target_link_libraries(asciiart ${XPM_LIBRARIES})
endif()
if(ZLIB_FOUND)
target_sources(asciiart PRIVATE codecs/mcmap.cpp)
target_include_directories(asciiart PRIVATE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(asciiart ${ZLIB_LIBRARIES})
endif()