CMake build fails if samples enabled but webready disabled, due to conntest sample dependency
ferdnyc opened this issue · 6 comments
Describe the bug
At least in the CMake build, samples/CMakeLists.txt
configures building of the conntest
application unconditionally when the EXIV2_BUILD_SAMPLES
option is enabled. But if EXIV2_ENABLE_WEBREADY
is OFF
, there will be no Exiv2::http
class in the library (heck, exiv2.hpp
won't even include exiv2/http.hpp
), and the conntest
code requires Exiv2::http
.
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/Exiv2/exiv2
cd exiv2
cmake -B _build -S . -DEXIV2_BUILD_SAMPLES=1 \
-DEXIV2_ENABLE_WEBREADY=0
cmake --build _build -j6
Full compile output
[ 1%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/ExpatAdapter.cpp.o
[ 1%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/MD5.cpp.o
[ 2%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/cr2header_int.cpp.o
[ 2%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/crwimage_int.cpp.o
[ 2%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/canonmn_int.cpp.o
[ 3%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/casiomn_int.cpp.o
[ 4%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/fujimn_int.cpp.o
[ 5%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/ParseRDF.cpp.o
[ 6%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/helper_functions.cpp.o
[ 6%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/UnicodeConversions.cpp.o
[ 7%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/WXMPIterator.cpp.o
[ 7%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/image_int.cpp.o
[ 8%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/jp2image_int.cpp.o
[ 8%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/makernote_int.cpp.o
[ 9%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/WXMPMeta.cpp.o
[ 10%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/minoltamn_int.cpp.o
[ 10%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/WXMPUtils.cpp.o
[ 11%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/nikonmn_int.cpp.o
[ 11%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/olympusmn_int.cpp.o
[ 12%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XML_Node.cpp.o
[ 13%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/orfimage_int.cpp.o
[ 14%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/panasonicmn_int.cpp.o
[ 14%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/pentaxmn_int.cpp.o
[ 14%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPCore_Impl.cpp.o
[ 15%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPIterator.cpp.o
[ 16%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/rw2image_int.cpp.o
[ 17%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPMeta-GetSet.cpp.o
[ 17%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/samsungmn_int.cpp.o
[ 17%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPMeta-Parse.cpp.o
[ 18%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/sigmamn_int.cpp.o
[ 19%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/sonymn_int.cpp.o
[ 19%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/tags_int.cpp.o
[ 20%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/tiffcomposite_int.cpp.o
[ 21%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPMeta-Serialize.cpp.o
[ 21%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/tiffimage_int.cpp.o
[ 22%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/tiffvisitor_int.cpp.o
[ 23%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/utils.cpp.o
[ 23%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPMeta.cpp.o
[ 24%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPUtils-FileInfo.cpp.o
[ 25%] Building CXX object xmpsdk/CMakeFiles/exiv2-xmp.dir/src/XMPUtils.cpp.o
[ 25%] Building CXX object src/CMakeFiles/exiv2lib_int.dir/pngchunk_int.cpp.o
.../exiv2/xmpsdk/src/XMPUtils.cpp: In static member function ‘static XMP_Int64 XMPUtils::ConvertToInt64(XMP_StringPtr)’:
.../exiv2/xmpsdk/src/XMPUtils.cpp:1221:48: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 3 has type ‘XMP_Int64*’ {aka ‘long int*’} [-Wformat=]
1221 | count = sscanf ( strValue, "%lld%c", &result, &nextCh );
| ~~~^ ~~~~~~~
| | |
| | XMP_Int64* {aka long int*}
| long long int*
| %ld
.../exiv2/xmpsdk/src/XMPUtils.cpp:1223:48: warning: format ‘%llx’ expects argument of type ‘long long unsigned int*’, but argument 3 has type ‘XMP_Int64*’ {aka ‘long int*’} [-Wformat=]
1223 | count = sscanf ( strValue, "%llx%c", &result, &nextCh );
| ~~~^ ~~~~~~~
| | |
| | XMP_Int64* {aka long int*}
| long long unsigned int*
| %lx
.../exiv2/xmpsdk/src/XMPMeta.cpp: In function ‘XMP_Status DumpNodeOptions(XMP_OptionBits, XMP_TextOutputProc, void*)’:
.../exiv2/xmpsdk/src/XMPMeta.cpp:90:70: warning: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘XMP_OptionBits’ {aka ‘unsigned int’} [-Wformat=]
90 | #define OutProcHexInt(num) { snprintf ( buffer, sizeof(buffer), "%lX", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
| ^~~~~ ~~~~~
.../exiv2/xmpsdk/src/XMPMeta.cpp:241:17: note: in expansion of macro ‘OutProcHexInt’
241 | OutProcHexInt ( options );
| ^~~~~~~~~~~~~
.../exiv2/xmpsdk/src/XMPMeta.cpp:90:73: note: format string is defined here
90 | #define OutProcHexInt(num) { snprintf ( buffer, sizeof(buffer), "%lX", (num) ); /* AUDIT: Using sizeof for snprintf length is safe */ \
| ~~^
| |
| long unsigned int
| %X
[ 25%] Built target exiv2-xmp
[ 25%] Built target exiv2lib_int
[ 26%] Building CXX object src/CMakeFiles/exiv2lib.dir/bmffimage.cpp.o
[ 26%] Building CXX object src/CMakeFiles/exiv2lib.dir/asfvideo.cpp.o
[ 27%] Building CXX object src/CMakeFiles/exiv2lib.dir/basicio.cpp.o
[ 27%] Building CXX object src/CMakeFiles/exiv2lib.dir/bmpimage.cpp.o
[ 28%] Building CXX object src/CMakeFiles/exiv2lib.dir/convert.cpp.o
[ 28%] Building CXX object src/CMakeFiles/exiv2lib.dir/cr2image.cpp.o
[ 29%] Building CXX object src/CMakeFiles/exiv2lib.dir/crwimage.cpp.o
[ 30%] Building CXX object src/CMakeFiles/exiv2lib.dir/datasets.cpp.o
[ 30%] Building CXX object src/CMakeFiles/exiv2lib.dir/easyaccess.cpp.o
[ 31%] Building CXX object src/CMakeFiles/exiv2lib.dir/epsimage.cpp.o
[ 32%] Building CXX object src/CMakeFiles/exiv2lib.dir/error.cpp.o
[ 32%] Building CXX object src/CMakeFiles/exiv2lib.dir/exif.cpp.o
[ 33%] Building CXX object src/CMakeFiles/exiv2lib.dir/futils.cpp.o
[ 33%] Building CXX object src/CMakeFiles/exiv2lib.dir/gifimage.cpp.o
[ 34%] Building CXX object src/CMakeFiles/exiv2lib.dir/image.cpp.o
[ 35%] Building CXX object src/CMakeFiles/exiv2lib.dir/iptc.cpp.o
[ 35%] Building CXX object src/CMakeFiles/exiv2lib.dir/jp2image.cpp.o
[ 36%] Building CXX object src/CMakeFiles/exiv2lib.dir/jpgimage.cpp.o
[ 37%] Building CXX object src/CMakeFiles/exiv2lib.dir/metadatum.cpp.o
[ 37%] Building CXX object src/CMakeFiles/exiv2lib.dir/mrwimage.cpp.o
[ 38%] Building CXX object src/CMakeFiles/exiv2lib.dir/orfimage.cpp.o
[ 38%] Building CXX object src/CMakeFiles/exiv2lib.dir/pgfimage.cpp.o
[ 39%] Building CXX object src/CMakeFiles/exiv2lib.dir/photoshop.cpp.o
[ 40%] Building CXX object src/CMakeFiles/exiv2lib.dir/preview.cpp.o
[ 40%] Building CXX object src/CMakeFiles/exiv2lib.dir/properties.cpp.o
[ 41%] Building CXX object src/CMakeFiles/exiv2lib.dir/psdimage.cpp.o
[ 41%] Building CXX object src/CMakeFiles/exiv2lib.dir/rafimage.cpp.o
[ 42%] Building CXX object src/CMakeFiles/exiv2lib.dir/rw2image.cpp.o
[ 43%] Building CXX object src/CMakeFiles/exiv2lib.dir/tags.cpp.o
[ 43%] Building CXX object src/CMakeFiles/exiv2lib.dir/tgaimage.cpp.o
[ 44%] Building CXX object src/CMakeFiles/exiv2lib.dir/tiffimage.cpp.o
[ 45%] Building CXX object src/CMakeFiles/exiv2lib.dir/types.cpp.o
[ 45%] Building CXX object src/CMakeFiles/exiv2lib.dir/value.cpp.o
[ 46%] Building CXX object src/CMakeFiles/exiv2lib.dir/version.cpp.o
[ 46%] Building CXX object src/CMakeFiles/exiv2lib.dir/webpimage.cpp.o
[ 47%] Building CXX object src/CMakeFiles/exiv2lib.dir/xmp.cpp.o
[ 48%] Building CXX object src/CMakeFiles/exiv2lib.dir/xmpsidecar.cpp.o
[ 48%] Building CXX object src/CMakeFiles/exiv2lib.dir/pngimage.cpp.o
[ 49%] Building CXX object src/CMakeFiles/exiv2lib.dir/matroskavideo.cpp.o
[ 50%] Building CXX object src/CMakeFiles/exiv2lib.dir/quicktimevideo.cpp.o
[ 50%] Building CXX object src/CMakeFiles/exiv2lib.dir/riffvideo.cpp.o
[ 51%] Linking CXX shared library ../lib/libexiv2.so
[ 51%] Built target exiv2lib
[ 52%] Building CXX object samples/CMakeFiles/convert-test.dir/convert-test.cpp.o
[ 52%] Building CXX object app/CMakeFiles/exiv2.dir/exiv2.cpp.o
[ 53%] Building CXX object samples/CMakeFiles/exifdata-test.dir/exifdata-test.cpp.o
[ 54%] Building CXX object samples/CMakeFiles/exifcomment.dir/exifcomment.cpp.o
[ 55%] Building CXX object samples/CMakeFiles/addmoddel.dir/addmoddel.cpp.o
[ 55%] Building CXX object samples/CMakeFiles/easyaccess-test.dir/easyaccess-test.cpp.o
[ 56%] Linking CXX executable ../bin/exifcomment
[ 56%] Built target exifcomment
[ 57%] Building CXX object app/CMakeFiles/exiv2.dir/actions.cpp.o
[ 57%] Linking CXX executable ../bin/convert-test
[ 57%] Built target convert-test
[ 57%] Building CXX object samples/CMakeFiles/exifdata.dir/exifdata.cpp.o
[ 57%] Linking CXX executable ../bin/easyaccess-test
[ 57%] Built target easyaccess-test
[ 58%] Building CXX object app/CMakeFiles/exiv2.dir/getopt.cpp.o
[ 59%] Linking CXX executable ../bin/addmoddel
[ 59%] Linking CXX executable ../bin/exifdata-test
[ 59%] Built target addmoddel
[ 60%] Building CXX object samples/CMakeFiles/exifprint.dir/exifprint.cpp.o
[ 60%] Built target exifdata-test
[ 60%] Building CXX object app/CMakeFiles/exiv2.dir/app_utils.cpp.o
[ 61%] Building CXX object samples/CMakeFiles/exifvalue.dir/exifvalue.cpp.o
[ 62%] Building CXX object samples/CMakeFiles/ini-test.dir/ini-test.cpp.o
[ 63%] Linking CXX executable ../bin/exifdata
[ 63%] Built target exifdata
[ 63%] Building CXX object samples/CMakeFiles/iotest.dir/iotest.cpp.o
[ 64%] Linking CXX executable ../bin/exifvalue
[ 64%] Linking CXX executable ../bin/exifprint
[ 64%] Built target exifvalue
[ 65%] Linking CXX executable ../bin/ini-test
[ 66%] Building CXX object samples/CMakeFiles/iptceasy.dir/iptceasy.cpp.o
[ 66%] Built target exifprint
[ 66%] Built target ini-test
[ 67%] Building CXX object samples/CMakeFiles/iptcprint.dir/iptcprint.cpp.o
[ 68%] Building CXX object samples/CMakeFiles/iptctest.dir/iptctest.cpp.o
[ 69%] Linking CXX executable ../bin/iotest
[ 69%] Linking CXX executable ../bin/iptcprint
[ 69%] Linking CXX executable ../bin/iptceasy
[ 69%] Built target iotest
[ 69%] Building CXX object samples/CMakeFiles/jpegparsetest.dir/jpegparsetest.cpp.o
[ 69%] Built target iptceasy
[ 69%] Built target iptcprint
[ 70%] Building CXX object samples/CMakeFiles/key-test.dir/key-test.cpp.o
[ 71%] Building CXX object samples/CMakeFiles/largeiptc-test.dir/largeiptc-test.cpp.o
[ 72%] Linking CXX executable ../bin/iptctest
[ 72%] Built target iptctest
[ 73%] Building CXX object samples/CMakeFiles/mmap-test.dir/mmap-test.cpp.o
[ 74%] Building CXX object samples/CMakeFiles/mrwthumb.dir/mrwthumb.cpp.o
[ 75%] Linking CXX executable ../bin/jpegparsetest
[ 75%] Linking CXX executable ../bin/key-test
[ 75%] Built target jpegparsetest
[ 75%] Building CXX object samples/CMakeFiles/prevtest.dir/prevtest.cpp.o
[ 75%] Built target key-test
[ 76%] Linking CXX executable ../bin/exiv2
[ 77%] Building CXX object samples/CMakeFiles/stringto-test.dir/stringto-test.cpp.o
[ 77%] Built target exiv2
[ 78%] Building CXX object samples/CMakeFiles/taglist.dir/taglist.cpp.o
[ 78%] Linking CXX executable ../bin/largeiptc-test
[ 78%] Built target largeiptc-test
[ 78%] Building CXX object samples/CMakeFiles/tiff-test.dir/tiff-test.cpp.o
[ 78%] Linking CXX executable ../bin/mmap-test
[ 79%] Linking CXX executable ../bin/mrwthumb
[ 79%] Built target mmap-test
[ 79%] Building CXX object samples/CMakeFiles/write-test.dir/write-test.cpp.o
[ 79%] Built target mrwthumb
[ 80%] Building CXX object samples/CMakeFiles/write2-test.dir/write2-test.cpp.o
[ 80%] Linking CXX executable ../bin/stringto-test
[ 80%] Built target stringto-test
[ 81%] Linking CXX executable ../bin/taglist
[ 81%] Building CXX object samples/CMakeFiles/xmpparse.dir/xmpparse.cpp.o
[ 81%] Built target taglist
[ 81%] Building CXX object samples/CMakeFiles/xmpparser-test.dir/xmpparser-test.cpp.o
[ 82%] Linking CXX executable ../bin/prevtest
[ 82%] Built target prevtest
[ 83%] Building CXX object samples/CMakeFiles/xmpprint.dir/xmpprint.cpp.o
[ 84%] Linking CXX executable ../bin/tiff-test
[ 84%] Built target tiff-test
[ 85%] Building CXX object samples/CMakeFiles/xmpsample.dir/xmpsample.cpp.o
[ 85%] Linking CXX executable ../bin/write2-test
[ 86%] Linking CXX executable ../bin/write-test
[ 86%] Built target write2-test
[ 86%] Built target write-test
[ 87%] Building CXX object samples/CMakeFiles/xmpdump.dir/xmpdump.cpp.o
[ 87%] Building CXX object samples/CMakeFiles/getopt-test.dir/getopt-test.cpp.o
[ 88%] Linking CXX executable ../bin/xmpparse
[ 88%] Linking CXX executable ../bin/xmpprint
[ 88%] Built target xmpparse
[ 89%] Building CXX object samples/CMakeFiles/getopt-test.dir/__/app/getopt.cpp.o
[ 89%] Built target xmpprint
[ 90%] Building CXX object samples/CMakeFiles/metacopy.dir/__/app/getopt.cpp.o
[ 91%] Building CXX object samples/CMakeFiles/metacopy.dir/metacopy.cpp.o
[ 91%] Building CXX object samples/CMakeFiles/path-test.dir/path-test.cpp.o
[ 92%] Linking CXX executable ../bin/xmpparser-test
[ 92%] Built target xmpparser-test
[ 93%] Building CXX object samples/CMakeFiles/geotag.dir/geotag.cpp.o
[ 94%] Linking CXX executable ../bin/xmpsample
[ 94%] Linking CXX executable ../bin/getopt-test
[ 95%] Linking CXX executable ../bin/xmpdump
[ 95%] Built target xmpsample
[ 96%] Building CXX object samples/CMakeFiles/path-test.dir/__/app/getopt.cpp.o
[ 96%] Building CXX object samples/CMakeFiles/conntest.dir/conntest.cpp.o
[ 96%] Built target xmpdump
[ 96%] Built target getopt-test
[ 96%] Building CXX object samples/CMakeFiles/remotetest.dir/remotetest.cpp.o
[ 96%] Linking CXX executable ../bin/metacopy
[ 96%] Built target metacopy
[ 97%] Linking CXX executable ../bin/path-test
[ 97%] Built target path-test
.../exiv2/samples/conntest.cpp: In function ‘void httpcon(const std::string&, bool)’:
.../exiv2/samples/conntest.cpp:25:27: error: ‘http’ is not a member of ‘Exiv2’
25 | int serverCode = Exiv2::http(request, response, errors);
| ^~~~
gmake[2]: *** [samples/CMakeFiles/conntest.dir/build.make:76: samples/CMakeFiles/conntest.dir/conntest.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1996: samples/CMakeFiles/conntest.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
Relevant compile error:
[ 96%] Building CXX object samples/CMakeFiles/conntest.dir/conntest.cpp.o
.../exiv2/samples/conntest.cpp: In function ‘void httpcon(const std::string&, bool)’:
.../exiv2/samples/conntest.cpp:25:27: error: ‘http’ is not a member of ‘Exiv2’
25 | int serverCode = Exiv2::http(request, response, errors);
| ^~~~
gmake[2]: *** [samples/CMakeFiles/conntest.dir/build.make:76: samples/CMakeFiles/conntest.dir/conntest.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1996: samples/CMakeFiles/conntest.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
Expected behavior
The conntest
sample isn't built, because the library lacks HTTP support.
Desktop (please complete the following information):
- OS and version: Fedora Linux 39
- Exiv2 version and source: repo
main
branch - Compiler and version:
gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7)
- Compilation mode and/or compiler flags: CMake-config defaults
Additional context
This change to samples/CMakeLists.txt
enabled the build to complete:
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt
index 3e990fbdd..bc948a1ad 100644
--- a/samples/CMakeLists.txt
+++ b/samples/CMakeLists.txt
@@ -92,10 +92,9 @@ endif()
# ******************************************************************************
# connection test application
-add_executable(conntest conntest.cpp)
-list(APPEND APPLICATIONS conntest)
-
if(EXIV2_ENABLE_WEBREADY)
+ add_executable(conntest conntest.cpp)
+ list(APPEND APPLICATIONS conntest)
if(EXIV2_ENABLE_CURL)
target_include_directories(conntest SYSTEM PRIVATE ${CURL_INCLUDE_DIR})
target_link_libraries(conntest PRIVATE ${CURL_LIBRARIES})
Meson doesn't have the same issue, because the fake curl_dep
is configured as a disabler
when get_option('webready')
is false
. So, setting it as a dependency of conntest
automatically removes it from the list of executables to be compiled.
Lines 70 to 74 in 41959b4
Lines 158 to 165 in 41959b4
Lines 192 to 194 in 41959b4
Thank you for the report and the suggested fix. Are you able to submit a PR directly perhaps?
...Actually, that Meson code seems strange to me — curl_dep
is also set as a disabler when get_option('webready')
is true
, but it's also set required
. (The first branch of the conditional is a bit odd there, as we already know get_option('webready')
is true
if we're on that branch.)
But dependency(..., disabler: true, required: true)
seems like a nonsensical combination of options. In fact I'll be a bit surprised if Meson doesn't grumble about it, if the build is configured that way.
The net effect of all that is that curl is required when building a webready
exiv2, which isn't the case in the CMake configuration. There, it's permissible to build with -DEXIV2_ENABLE_WEBREADY=1 -DEXIV2_ENABLE_CURL=0
, and conntest
does build and work (supporting http://
URLs only) even without curl.
Thank you for the report and the suggested fix. Are you able to submit a PR directly perhaps?
Sure, will do.
(The first branch of the conditional is a bit odd there, as we already know
get_option('webready')
istrue
if we're on that branch.)But
dependency(..., disabler: true, required: true)
seems like a nonsensical combination of options. In fact I'll be a bit surprised if Meson doesn't grumble about it, if the build is configured that way.
Nope, I read that wrong. I had it in my head that the code was,
if get_option('webready')
curl_dep = dependency(
'libcurl', disabler: true, required: get_option('webready'))
But it's not, it's
curl_dep = dependency(
'libcurl', disabler: true, required: get_option('curl'))
My mistake, sorry.
But the curl-is-effectively-required thing is still somewhat the case. (It will only affect conntest
, though, since curl_dep
isn't set as a library dependency unless curl_dep.found()
is true
. That way it will never disable the library build.)
But a disabler curl_dep
will prevent the build of conntest
when libcurl isn't available. In CMake, conntest
— like libexiv2
itself — can be built "webready" with limited, HTTP-only support, even if it's not linked to curl.