exiv2 icon indicating copy to clipboard operation
exiv2 copied to clipboard

meson: add tests and app options

Open neheb opened this issue 8 months ago • 10 comments

Fixes: https://github.com/Exiv2/exiv2/issues/3015

ping @heitbaum

neheb avatar Apr 28 '25 22:04 neheb

Using the following build, the app and tests are now excluded as expected. There are 3 .cmake files missing, testing to see if that impacts application builds.

PKG_MESON_OPTS_TARGET="-Ddefault_library=static \
                       -Dwebready=false \
                       -Dxmp=disabled \
                       -Dcurl=disabled \
                       -Dnls=disabled \
                       -Dtests=false \
                       -DunitTests=disabled \
                       -Dvideo=false \
                       -Dbmff=false \
                       -Dbrotli=disabled \
                       -Dinih=disabled \
                       -Dapp=false"

versus

PKG_CMAKE_OPTS_TARGET="-DBUILD_SHARED_LIBS=OFF \
                       -DEXIV2_ENABLE_WEBREADY=OFF \
                       -DEXIV2_ENABLE_XMP=OFF \
                       -DEXIV2_ENABLE_CURL=OFF \
                       -DEXIV2_ENABLE_NLS=OFF \
                       -DEXIV2_BUILD_SAMPLES=OFF \
                       -DEXIV2_BUILD_UNIT_TESTS=OFF \
                       -DEXIV2_ENABLE_VIDEO=OFF \
                       -DEXIV2_ENABLE_BMFF=OFF \
                       -DEXIV2_ENABLE_BROTLI=OFF \
                       -DEXIV2_ENABLE_INIH=OFF \
                       -DEXIV2_ENABLE_FILESYSTEM_ACCESS=OFF \
                       -DEXIV2_BUILD_EXIV2_COMMAND=OFF \
                       -DBUILD_WITH_CCACHE=ON"
diff -Nu cmake-build meson-build
--- cmake-build  2025-04-29 09:31:33.557166548 +0000
+++ meson-build 2025-04-29 09:35:38.592136776 +0000
@@ -4,9 +4,6 @@
 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib
 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/cmake
 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/cmake/exiv2
-build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/cmake/exiv2/exiv2Config.cmake
-build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/cmake/exiv2/exiv2Targets.cmake
-build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/cmake/exiv2/exiv2Targets-release.cmake
 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/cmake/exiv2/exiv2ConfigVersion.cmake
 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/pkgconfig
 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/pkgconfig/exiv2.pc

heitbaum avatar Apr 29 '25 09:04 heitbaum

I was able to build Kodi without the “missing cmake files” but only if I used the cmake generated headers (using the meson .a file - I did not run test this). Using the meson generate headers failed to allow Kodi to build.

Further build testing has isolated the error to exiv2lib_export.h being empty in the meson build. I’m not sure what the #define EXV_ENABLE_FILESYSTEM in exv_conf.h does (in the meson build versus the cmake build.)


diff -ru e-c/usr/include/exiv2/exiv2lib_export.h e-m/usr/include/exiv2/exiv2lib_export.h
--- e-c/usr/include/exiv2/exiv2lib_export.h     2025-04-29 09:53:38.000000000 +0000
+++ e-m/usr/include/exiv2/exiv2lib_export.h     2025-04-29 09:51:03.748150418 +0000
@@ -1,43 +1,7 @@
+/*
+ * Autogenerated by the Meson build system.
+ * Do not edit, your changes will be lost.
+ */
 
-#ifndef EXIV2API_H
-#define EXIV2API_H
+#pragma once
 
-#ifdef exiv2lib_STATIC
-#  define EXIV2API
-#  define EXIV2LIB_NO_EXPORT
-#else
-#  ifndef EXIV2API
-#    ifdef exiv2lib_EXPORTS
-        /* We are building this library */
-#      define EXIV2API 
-#    else
-        /* We are using this library */
-#      define EXIV2API 
-#    endif
-#  endif
-
-#  ifndef EXIV2LIB_NO_EXPORT
-#    define EXIV2LIB_NO_EXPORT 
-#  endif
-#endif
-
-#ifndef EXIV2LIB_DEPRECATED
-#  define EXIV2LIB_DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-#ifndef EXIV2LIB_DEPRECATED_EXPORT
-#  define EXIV2LIB_DEPRECATED_EXPORT EXIV2API EXIV2LIB_DEPRECATED
-#endif
-
-#ifndef EXIV2LIB_DEPRECATED_NO_EXPORT
-#  define EXIV2LIB_DEPRECATED_NO_EXPORT EXIV2LIB_NO_EXPORT EXIV2LIB_DEPRECATED
-#endif
-
-/* NOLINTNEXTLINE(readability-avoid-unconditional-preprocessor-if) */
-#if 0 /* DEFINE_NO_DEPRECATED */
-#  ifndef EXIV2LIB_NO_DEPRECATED
-#    define EXIV2LIB_NO_DEPRECATED
-#  endif
-#endif
-
-#endif /* EXIV2API_H */
diff -ru e-c/usr/include/exiv2/exv_conf.h e-m/usr/include/exiv2/exv_conf.h
--- e-c/usr/include/exiv2/exv_conf.h    2025-04-29 09:53:38.000000000 +0000
+++ e-m/usr/include/exiv2/exv_conf.h    2025-04-29 09:51:04.821244132 +0000
@@ -7,7 +7,7 @@
 /* #undef EXV_USE_CURL */
 
 // Define to 1 if you want to enable filesystem access
-/* #undef EXV_ENABLE_FILESYSTEM */
+#define EXV_ENABLE_FILESYSTEM
 
 // Define if you require webready support.
 /* #undef EXV_ENABLE_WEBREADY */
@@ -61,15 +61,15 @@
 #define EXV_PACKAGE_NAME "exiv2"
 
 /* Define to the full name and version of this package. */
-#define EXV_PACKAGE_STRING "exiv2 0.28.5"
+#define EXV_PACKAGE_STRING "exiv2 1.0.0.9"
 
 /* Define to the version of this package. */
-#define EXV_PACKAGE_VERSION "0.28.5"
+#define EXV_PACKAGE_VERSION "1.0.0.9"
 
-#define EXIV2_MAJOR_VERSION (0U)
-#define EXIV2_MINOR_VERSION (28U)
-#define EXIV2_PATCH_VERSION (5U)
-#define EXIV2_TWEAK_VERSION (U)
+#define EXIV2_MAJOR_VERSION (1U)
+#define EXIV2_MINOR_VERSION (0U)
+#define EXIV2_PATCH_VERSION (0U)
+#define EXIV2_TWEAK_VERSION (9U)
 
 // Definition to enable translation of Nikon lens names.
 #define EXV_HAVE_LENSDATA
Only in e-c/usr/lib/cmake/exiv2: exiv2Config.cmake
diff -ru e-c/usr/lib/cmake/exiv2/exiv2ConfigVersion.cmake e-m/usr/lib/cmake/exiv2/exiv2ConfigVersion.cmake
--- e-c/usr/lib/cmake/exiv2/exiv2ConfigVersion.cmake    2025-04-29 09:53:38.000000000 +0000
+++ e-m/usr/lib/cmake/exiv2/exiv2ConfigVersion.cmake    2025-04-29 09:51:04.998859649 +0000
@@ -4,80 +4,29 @@
 #
 # The created file sets PACKAGE_VERSION_EXACT if the current version string and
 # the requested version string are exactly the same and it sets
-# PACKAGE_VERSION_COMPATIBLE if the current version is equal to the requested version.
-# The tweak version component is ignored.
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
 # The variable CVF_VERSION must be set before calling configure_file().
 
+set(PACKAGE_VERSION "1.0.0")
 
 if (PACKAGE_FIND_VERSION_RANGE)
-  message(AUTHOR_WARNING
-    "`find_package()` specify a version range but the version strategy "
-    "(ExactVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible "
-    "with this request. Only the lower endpoint of the range will be used.")
-endif()
-
-set(PACKAGE_VERSION "0.28.5")
-
-if("0.28.5" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
-  set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
-  set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
-  set(CVF_VERSION_PATCH "${CMAKE_MATCH_3}")
-
-  if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
-    string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
-  endif()
-  if(NOT CVF_VERSION_MINOR VERSION_EQUAL 0)
-    string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}")
-  endif()
-  if(NOT CVF_VERSION_PATCH VERSION_EQUAL 0)
-    string(REGEX REPLACE "^0+" "" CVF_VERSION_PATCH "${CVF_VERSION_PATCH}")
+  # Package version must be in the requested version range
+  if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
+      OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
+        OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
+    set(PACKAGE_VERSION_COMPATIBLE FALSE)
+  else()
+    set(PACKAGE_VERSION_COMPATIBLE TRUE)
   endif()
-
-  set(CVF_VERSION_NO_TWEAK "${CVF_VERSION_MAJOR}.${CVF_VERSION_MINOR}.${CVF_VERSION_PATCH}")
 else()
-  set(CVF_VERSION_NO_TWEAK "0.28.5")
-endif()
-
-if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
-  set(REQUESTED_VERSION_MAJOR "${CMAKE_MATCH_1}")
-  set(REQUESTED_VERSION_MINOR "${CMAKE_MATCH_2}")
-  set(REQUESTED_VERSION_PATCH "${CMAKE_MATCH_3}")
-
-  if(NOT REQUESTED_VERSION_MAJOR VERSION_EQUAL 0)
-    string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MAJOR "${REQUESTED_VERSION_MAJOR}")
-  endif()
-  if(NOT REQUESTED_VERSION_MINOR VERSION_EQUAL 0)
-    string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MINOR "${REQUESTED_VERSION_MINOR}")
+  if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+    set(PACKAGE_VERSION_COMPATIBLE FALSE)
+  else()
+    set(PACKAGE_VERSION_COMPATIBLE TRUE)
+    if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+      set(PACKAGE_VERSION_EXACT TRUE)
+    endif()
   endif()
-  if(NOT REQUESTED_VERSION_PATCH VERSION_EQUAL 0)
-    string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_PATCH "${REQUESTED_VERSION_PATCH}")
-  endif()
-
-  set(REQUESTED_VERSION_NO_TWEAK
-      "${REQUESTED_VERSION_MAJOR}.${REQUESTED_VERSION_MINOR}.${REQUESTED_VERSION_PATCH}")
-else()
-  set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
 endif()
 
-if(REQUESTED_VERSION_NO_TWEAK STREQUAL CVF_VERSION_NO_TWEAK)
-  set(PACKAGE_VERSION_COMPATIBLE TRUE)
-else()
-  set(PACKAGE_VERSION_COMPATIBLE FALSE)
-endif()
 
-if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
-  set(PACKAGE_VERSION_EXACT TRUE)
-endif()
-
-
-# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
-if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
-  return()
-endif()
-
-# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
-if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
-  math(EXPR installedBits "8 * 8")
-  set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
-  set(PACKAGE_VERSION_UNSUITABLE TRUE)
-endif()
Only in e-c/usr/lib/cmake/exiv2: exiv2Targets.cmake
Only in e-c/usr/lib/cmake/exiv2: exiv2Targets-release.cmake
Binary files e-c/usr/lib/libexiv2.a and e-m/usr/lib/libexiv2.a differ
diff -ru e-c/usr/lib/pkgconfig/exiv2.pc e-m/usr/lib/pkgconfig/exiv2.pc
--- e-c/usr/lib/pkgconfig/exiv2.pc      2025-04-29 09:53:38.000000000 +0000
+++ e-m/usr/lib/pkgconfig/exiv2.pc      2025-04-29 09:51:05.000720176 +0000
@@ -1,13 +1,11 @@
 prefix=/usr
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
 includedir=${prefix}/include
+libdir=${prefix}/lib
 
 Name: exiv2
 Description: Exif/IPTC/Xmp C++ metadata library and tools plus ICC Profiles, Previews and more.
-Version: 0.28.5
 URL: https://exiv2.org
-Requires.private: zlib
+Version: 1.0.0
+Requires: zlib
 Libs: -L${libdir} -lexiv2
-Libs.private: 
 Cflags: -I${includedir}

heitbaum avatar Apr 29 '25 10:04 heitbaum

Testing the builds of shared libraries results in the following differences:

Cmake
lrwxrwxrwx 1 docker docker      14 Apr 29 10:34 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so -> libexiv2.so.28
-rw-r--r-- 1 docker docker 3382624 Apr 29 10:34 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so.0.28.5
lrwxrwxrwx 1 docker docker      18 Apr 29 10:34 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so.28 -> libexiv2.so.0.28.5

meson
ls build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so* -l
lrwxrwxrwx 1 docker docker      14 Apr 29 10:31 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so -> libexiv2.so.30
-rwxr-xr-x 1 docker docker 3560704 Apr 29 10:31 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so.1.0.0
lrwxrwxrwx 1 docker docker      17 Apr 29 10:31 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so.30 -> libexiv2.so.1.0.0

meson with version fix
lrwxrwxrwx 1 docker docker      14 Apr 29 10:38 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so -> libexiv2.so.28
-rwxr-xr-x 1 docker docker 3560704 Apr 29 10:38 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so.0.28.5
lrwxrwxrwx 1 docker docker      18 Apr 29 10:38 build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/lib/libexiv2.so.28 -> libexiv2.so.0.28.5

required fix is: (this also fixes the versioning anomalies in the pkg-config and header files.)

--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
 project(
   'exiv2',
   'cpp',
-  version: '1.0.0',
+  version: '0.28.5',
   meson_version: '>=0.54.1',
   default_options: ['warning_level=0', 'cpp_std=c++20'],
 )

heitbaum avatar Apr 29 '25 10:04 heitbaum

Lastly - not sure this was / should be set to 9? Assume this should be 0 or blank?

https://github.com/Exiv2/exiv2/blob/a76838475f30f9eef02aa664e5196920bb676202/meson.build#L40

heitbaum avatar Apr 29 '25 10:04 heitbaum

The size difference of the libraries is mainly to do with buildtype not being set. Use -Dbuildtype=release

Lack of CMake files should not be an issue.

As for exiv2lib_export.h , I'm handling this differently in meson. Besides various dllimport warnings on windows, it should be fine.

edit: nvm this is all correct as long as the _dep is consumed in meson.

btw why disable EXV_ENABLE_FILESYSTEM ? I would think that would be needed for Kodi.

neheb avatar Apr 29 '25 20:04 neheb

The size difference of the libraries is mainly to do with buildtype not being set. Use -Dbuildtype=release

all good with the size. It was the soversion that showed up differently.

28 -> libexiv2.so.0.28.5 30 -> libexiv2.so.1.0.0

Lack of CMake files should not be an issue.

Agreed from the testing I did.

heitbaum avatar Apr 29 '25 21:04 heitbaum

Tested with the latest branch - still erroring with the build with the empty exiv2lib_export.h file kodi-build-error-exiv2.txt

$ cat build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/include/exiv2/exiv2lib_export.h
/*
 * Autogenerated by the Meson build system.
 * Do not edit, your changes will be lost.
 */

#pragma once

updated: I applied the following diff to the meson.build (it did warn (./exiv2lib_export.h:8:9: warning: 'EXIV2API' redefined) during the compile of the libexiv2.a, but did result in a workable exiv2lib_export.h that allowed the application to build.

--- a/meson.build       2025-04-30 04:59:36.106230126 +0000
+++ b/meson.build       2025-04-30 05:29:57.446264929 +0000
@@ -6,13 +6,18 @@
   default_options: ['warning_level=0', 'cpp_std=c++20'],
 )

+exiv_api = configuration_data()
+
 cpp = meson.get_compiler('cpp')
 if host_machine.system() == 'windows' and get_option('default_library') != 'static'
   cargs = '-DEXIV2API=__declspec(dllexport)'
+  exiv_api.set('EXIV2API', '__declspec(dllexport)')
 elif cpp.has_function_attribute('visibility:default')
   cargs = '-DEXIV2API=__attribute__((visibility("default")))'
+  exiv_api.set('EXIV2API', '__attribute__((visibility("default")))')
 else
   cargs = '-DEXIV2API='
+  exiv_api.set('EXIV2API', '')
 endif

 if host_machine.system() == 'windows'
@@ -23,8 +28,7 @@
   endif
 endif

-exiv_api = configuration_data()
 exiv_conf = configure_file(output: 'exiv2lib_export.h', configuration: exiv_api)

 cdata = configuration_data()
$ cat build.LibreELEC-Generic.x86_64-13.0-devel/install_pkg/exiv2-0.28.5/usr/include/exiv2/exiv2lib_export.h
/*
 * Autogenerated by the Meson build system.
 * Do not edit, your changes will be lost.
 */

#pragma once

#define EXIV2API __attribute__((visibility("default")))

heitbaum avatar Apr 30 '25 05:04 heitbaum

I think I know what's happening.

You're using cmake to find exiv2 but that's subtly broken. Try finding with pkgconfig instead.

neheb avatar Apr 30 '25 06:04 neheb

I think I know what's happening.

You're using cmake to find exiv2 but that's subtly broken. Try finding with pkgconfig instead.

Correct - kodi uses cmake to do the find. https://github.com/xbmc/xbmc/blob/master/cmake/modules/FindExiv2.cmake

heitbaum avatar Apr 30 '25 06:04 heitbaum

@heitbaum removed cmake config files. Now pkgconfig must be used.

neheb avatar May 01 '25 23:05 neheb

@heitbaum rebased. split off the cmake removal into its own commit.

neheb avatar Jun 27 '25 20:06 neheb

I’d personally like to see:

  • the app commit merged,
  • the pkgconfig fix applied
  • and the cmake removal deferred, as this will break the Kodi build if meson is used to build exiv2. As Kodi does not looks for pkgconfig for exiv2. Then it can at least be revisited?

heitbaum avatar Jun 28 '25 04:06 heitbaum

@neheb Maybe we want this for 0.28.6? (Might depend on some other earlier commits though...?)

kmilos avatar Aug 26 '25 10:08 kmilos

Sure

neheb avatar Aug 26 '25 19:08 neheb