Skip to content

Commit

Permalink
Set conditional HTTP depending on EXIV2_ENABLE_WEBREADY
Browse files Browse the repository at this point in the history
(cherry picked from commit 9f90144)
  • Loading branch information
enen92 authored and kmilos committed May 17, 2024
1 parent 0630d09 commit 7603d33
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/exiv2/exiv2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "exiv2/exif.hpp"
#include "exiv2/futils.hpp"
#include "exiv2/gifimage.hpp"
#ifdef EXV_ENABLE_WEBREADY
#include "exiv2/http.hpp"
#endif
#include "exiv2/image.hpp"
#include "exiv2/iptc.hpp"
#include "exiv2/jp2image.hpp"
Expand Down
5 changes: 4 additions & 1 deletion include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ headers = files(
'exiv2/exiv2.hpp',
'exiv2/futils.hpp',
'exiv2/gifimage.hpp',
'exiv2/http.hpp',
'exiv2/image.hpp',
'exiv2/image_types.hpp',
'exiv2/iptc.hpp',
Expand Down Expand Up @@ -47,6 +46,10 @@ if get_option('video')
headers += files('exiv2/asfvideo.hpp', 'exiv2/matroskavideo.hpp', 'exiv2/quicktimevideo.hpp', 'exiv2/riffvideo.hpp')
endif

if get_option('webready')
headers += files('exiv2/http.hpp')
endif

if zlib_dep.found()
headers += files('exiv2/pngimage.hpp')
endif
Expand Down
9 changes: 7 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ if brotli_dep.found()
deps += brotli_dep
endif

curl_dep = dependency('libcurl', disabler: true, required: get_option('curl'))
if get_option('webready')
curl_dep = dependency('libcurl', disabler: true, required: get_option('curl'))
else
curl_dep = dependency('', disabler: true, required: false)
endif

if curl_dep.found()
deps += curl_dep
endif
Expand Down Expand Up @@ -113,9 +118,9 @@ cdata.set('EXV_HAVE_XMP_TOOLKIT', expat_dep.found())
cdata.set('EXV_HAVE_BROTLI', brotli_dep.found())
cdata.set('EXV_HAVE_ICONV', iconv_dep.found())
cdata.set('EXV_HAVE_LIBZ', zlib_dep.found())
cdata.set('EXV_ENABLE_WEBREADY', get_option('webready'))
cdata.set('EXV_USE_CURL', curl_dep.found())
cdata.set('EXV_ENABLE_NLS', intl_dep.found())
cdata.set('EXV_ENABLE_WEBREADY', curl_dep.found())

cfile = configure_file(
input: 'cmake/config.h.cmake',
Expand Down
5 changes: 5 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ option('xmp', type : 'feature',
option('unitTests', type : 'feature',
description : 'Build and run unit tests',
)

option('webready', type : 'boolean',
value: true,
description : 'Build with support for webready',
)
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ set(PUBLIC_HEADERS
../include/exiv2/exiv2.hpp
../include/exiv2/futils.hpp
../include/exiv2/gifimage.hpp
../include/exiv2/http.hpp
../include/exiv2/image.hpp
../include/exiv2/image_types.hpp
../include/exiv2/iptc.hpp
Expand Down Expand Up @@ -92,7 +91,6 @@ add_library( exiv2lib
futils.cpp
fff.h
gifimage.cpp
http.cpp
image.cpp
iptc.cpp
jp2image.cpp
Expand Down Expand Up @@ -129,6 +127,10 @@ generate_export_header(exiv2lib

# Conditional addition of sources to library targets
# ---------------------------------------------------------
if(EXIV2_ENABLE_WEBREADY)
set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ../include/exiv2/http.hpp)
target_sources(exiv2lib PRIVATE http.cpp ../include/exiv2/http.hpp)
endif()

if( EXIV2_ENABLE_PNG )
set(PUBLIC_HEADERS ${PUBLIC_HEADERS} ../include/exiv2/pngimage.hpp)
Expand Down
2 changes: 2 additions & 0 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ void RemoteIo::populateFakeData() {
}
}

#ifdef EXV_ENABLE_WEBREADY
//! Internal Pimpl structure of class HttpIo.
class HttpIo::HttpImpl : public Impl {
public:
Expand Down Expand Up @@ -1524,6 +1525,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s
HttpIo::HttpIo(const std::string& url, size_t blockSize) {
p_ = std::make_unique<HttpImpl>(url, blockSize);
}
#endif

#ifdef EXV_USE_CURL
//! Internal Pimpl structure of class RemoteIo.
Expand Down
2 changes: 2 additions & 0 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,10 @@ BasicIo::UniquePtr ImageFactory::createIo(const std::string& path, bool useCurl)
}
#endif

#ifdef EXV_ENABLE_WEBREADY
if (fProt == pHttp)
return std::make_unique<HttpIo>(path); // may throw
#endif
if (fProt == pFileUri)
return std::make_unique<FileIo>(pathOfFileUrl(path));
if (fProt == pStdin || fProt == pDataUri)
Expand Down

0 comments on commit 7603d33

Please sign in to comment.