Skip to content

Commit 9de5634

Browse files
ruslorbsheth
authored andcommitted
CMake: Use Hunter to manage dependencies
1 parent aac927e commit 9de5634

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

cmake/WebPConfig.cmake.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,26 @@ set(WEBP_VERSION ${WebP_VERSION})
33

44
@PACKAGE_INIT@
55

6+
find_package(PNG CONFIG REQUIRED)
7+
find_package(JPEG CONFIG REQUIRED)
8+
if(NOT MSYS)
9+
# See 'cmake/deps.cmake'
10+
find_package(TIFF CONFIG REQUIRED)
11+
endif()
12+
if(NOT MINGW AND NOT MSYS)
13+
# See 'cmake/deps.cmake'
14+
find_package(giflib CONFIG REQUIRED)
15+
endif()
16+
17+
check_required_components("@PROJECT_NAME@")
18+
619
include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
720

21+
if(0)
22+
823
set(WebP_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
924
set(WEBP_INCLUDE_DIRS ${WebP_INCLUDE_DIRS})
1025
set(WebP_LIBRARIES "@INSTALLED_LIBRARIES@")
1126
set(WEBP_LIBRARIES "${WebP_LIBRARIES}")
27+
28+
endif()

cmake/deps.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,46 @@ if(NOT HAVE_MATH_LIBRARY)
7070
list(APPEND WEBP_DEP_LIBRARIES m)
7171
endif()
7272

73+
if(HUNTER_ENABLED)
74+
hunter_add_package(PNG)
75+
find_package(PNG CONFIG REQUIRED)
76+
list(APPEND WEBP_DEP_IMG_LIBRARIES PNG::png)
77+
set(WEBP_HAVE_PNG 1)
78+
set(PNG_FOUND 1)
79+
80+
hunter_add_package(Jpeg)
81+
find_package(JPEG CONFIG REQUIRED)
82+
list(APPEND WEBP_DEP_IMG_LIBRARIES JPEG::jpeg)
83+
set(WEBP_HAVE_JPEG 1)
84+
set(JPEG_FOUND 1)
85+
86+
if(MSYS)
87+
# TIFF is currently not supported by Hunter on MSYS:
88+
# - https://github.com/ingenue/hunter/blob/8e37b969b18ff75857d2b75c8acdf1e9caca2549/appveyor.yml#L31-L34
89+
set(WEBP_HAVE_TIFF 0)
90+
set(TIFF_FOUND 0)
91+
else()
92+
hunter_add_package(TIFF)
93+
find_package(TIFF CONFIG REQUIRED)
94+
list(APPEND WEBP_DEP_IMG_LIBRARIES TIFF::libtiff)
95+
set(WEBP_HAVE_TIFF 1)
96+
set(TIFF_FOUND 1)
97+
endif()
98+
99+
if(MINGW OR MSYS)
100+
# giflib is currently not supported by Hunter on MinGW and MSYS:
101+
# - https://github.com/ingenue/hunter/blob/ab5a2b7507427b2e1110717c35c29a78815394c6/appveyor.yml#L27-L37
102+
set(WEBP_HAVE_GIF 0)
103+
set(GIF_FOUND 0)
104+
else()
105+
hunter_add_package(giflib)
106+
find_package(giflib CONFIG REQUIRED)
107+
list(APPEND WEBP_DEP_GIF_LIBRARIES giflib::giflib)
108+
set(WEBP_HAVE_GIF 1)
109+
set(GIF_FOUND 1)
110+
endif()
111+
else()
112+
73113
# Find the standard image libraries.
74114
set(WEBP_DEP_IMG_LIBRARIES)
75115
set(WEBP_DEP_IMG_INCLUDE_DIRS)
@@ -116,6 +156,8 @@ if(GIF_FOUND)
116156
endif()
117157
endif()
118158

159+
endif()
160+
119161
# Check for specific headers.
120162
include(CheckIncludeFiles)
121163
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)

0 commit comments

Comments
 (0)