@@ -7,6 +7,12 @@ option(WITH_CUDA "Enable CUDA support" OFF)
7
7
option (WITH_MPS "Enable MPS support" OFF )
8
8
option (WITH_PNG "Enable features requiring LibPNG." ON )
9
9
option (WITH_JPEG "Enable features requiring LibJPEG." ON )
10
+ # Libwebp is disabled by default, which means enabling it from cmake is largely
11
+ # untested. Since building from cmake is very low pri anyway, this is OK. If
12
+ # you're a user and you need this, please open an issue (and a PR!).
13
+ option (WITH_WEBP "Enable features requiring LibWEBP." OFF )
14
+ # Same here
15
+ option (WITH_AVIF "Enable features requiring LibAVIF." OFF )
10
16
11
17
if (WITH_CUDA)
12
18
enable_language (CUDA)
@@ -32,6 +38,16 @@ if (WITH_JPEG)
32
38
find_package (JPEG REQUIRED)
33
39
endif ()
34
40
41
+ if (WITH_WEBP)
42
+ add_definitions (-DWEBP_FOUND)
43
+ find_package (WEBP REQUIRED)
44
+ endif ()
45
+
46
+ if (WITH_AVIF)
47
+ add_definitions (-DAVIF_FOUND)
48
+ find_package (AVIF REQUIRED)
49
+ endif ()
50
+
35
51
function (CUDA_CONVERT_FLAGS EXISTING_TARGET)
36
52
get_property (old_flags TARGET ${EXISTING_TARGET} PROPERTY INTERFACE_COMPILE_OPTIONS)
37
53
if (NOT "${old_flags} " STREQUAL "" )
@@ -104,6 +120,14 @@ if (WITH_JPEG)
104
120
target_link_libraries (${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES} )
105
121
endif ()
106
122
123
+ if (WITH_WEBP)
124
+ target_link_libraries (${PROJECT_NAME} PRIVATE ${WEBP_LIBRARIES} )
125
+ endif ()
126
+
127
+ if (WITH_AVIF)
128
+ target_link_libraries (${PROJECT_NAME} PRIVATE ${AVIF_LIBRARIES} )
129
+ endif ()
130
+
107
131
set_target_properties (${PROJECT_NAME} PROPERTIES
108
132
EXPORT_NAME TorchVision
109
133
INSTALL_RPATH ${TORCH_INSTALL_PREFIX} /lib)
@@ -118,6 +142,14 @@ if (WITH_JPEG)
118
142
include_directories (${JPEG_INCLUDE_DIRS} )
119
143
endif ()
120
144
145
+ if (WITH_WEBP)
146
+ include_directories (${WEBP_INCLUDE_DIRS} )
147
+ endif ()
148
+
149
+ if (WITH_AVIF)
150
+ include_directories (${AVIF_INCLUDE_DIRS} )
151
+ endif ()
152
+
121
153
set (TORCHVISION_CMAKECONFIG_INSTALL_DIR "share/cmake/TorchVision" CACHE STRING "install path for TorchVisionConfig.cmake" )
122
154
123
155
configure_package_config_file(cmake/TorchVisionConfig.cmake.in
0 commit comments