Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Ensure openjpeg2 is used #1135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kmilos
Copy link
Contributor

@kmilos kmilos commented Feb 28, 2024

Resolves #1134

@bradh
Copy link
Contributor

bradh commented Apr 16, 2024

I merged this locally, and it breaks openjpeg detection on my Ubuntu (mantic) box. I do have:

Package: libopenjp2-7-dev                
Version: 2.5.0-2
State: installed

Detection (and build) works fine without this change, and fails with it. I think the change looks fine, but not sure its completely backwards compatible.

@kmilos
Copy link
Contributor Author

kmilos commented Apr 16, 2024

it breaks openjpeg detection on my Ubuntu

Any hints in the CMake output as to why?

@kmilos
Copy link
Contributor Author

kmilos commented Apr 16, 2024

Here's my output when running cmake --debug-find-pkg=OpenJPEG:

CMake Debug Log at CMakeLists.txt:51 (find_package):
  find_package considered the following paths for FindOpenJPEG.cmake:

    C:/msys64/ucrt64/share/cmake/Modules/FindOpenJPEG.cmake

  The file was not found.

  The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.

    C:/msys64/home/kmilos/test/build/CMakeFiles/pkgRedirects

  <PackageName>_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].

    none

  CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
  [CMAKE_FIND_USE_CMAKE_PATH].

    none

  Env variable OpenJPEG_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
  [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  Paths specified by the find_package HINTS option.

    none

  Standard system environment variables
  [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].

    C:/msys64/ucrt64
    C:/msys64/usr/local
    C:/msys64/usr
    C:/Windows/System32
    C:/Windows
    C:/Windows/System32/wbem
    C:/Windows/System32/WindowsPowerShell/v1.0
    C:/msys64/usr/bin/site_perl
    C:/msys64/usr/bin/vendor_perl
    C:/msys64/usr/bin/core_perl

  CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].

    none

  CMake variables defined in the Platform file
  [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].

    C:/Program Files
    C:/Program Files (x86)
    C:/Program Files (x86)/test

  CMake System Package Registry
  [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].

    none

  Paths specified by the find_package PATHS option.

    none

  find_package considered the following locations for OpenJPEG's Config
  module:

    C:/msys64/home/kmilos/test/build/CMakeFiles/pkgRedirects/OpenJPEGConfig.cmake
    C:/msys64/home/kmilos/test/build/CMakeFiles/pkgRedirects/openjpeg-config.cmake
    C:/msys64/ucrt64/OpenJPEGConfig.cmake
    C:/msys64/ucrt64/openjpeg-config.cmake
    C:/msys64/ucrt64/cmake/OpenJPEGConfig.cmake
    C:/msys64/ucrt64/cmake/openjpeg-config.cmake
    C:/msys64/ucrt64/lib/cmake/openjpeg-2.5/OpenJPEGConfig.cmake

  The file was found at

    C:/msys64/ucrt64/lib/cmake/openjpeg-2.5/OpenJPEGConfig.cmake

@kmilos
Copy link
Contributor Author

kmilos commented Apr 16, 2024

AFAICT, the cmake config files should be present on Debian/Ubuntu as well: https://packages.debian.org/bookworm/amd64/libopenjp2-7-dev/filelist

@bradh
Copy link
Contributor

bradh commented Apr 16, 2024

I get this:

CMake Warning at CMakeLists.txt:178 (find_package):
  Could not find a configuration file for package "OpenJPEG" that is
  compatible with requested version "2".

  The following configuration files were considered but not accepted:

    /usr/lib/x86_64-linux-gnu/openjpeg-2.1/OpenJPEGConfig.cmake, version: unknown
    /usr/lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGConfig.cmake, version: unknown
    /lib/x86_64-linux-gnu/openjpeg-2.1/OpenJPEGConfig.cmake, version: unknown
    /lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGConfig.cmake, version: unknown



CMake Debug Log at CMakeLists.txt:178 (find_package):
  find_package considered the following paths for FindOpenJPEG.cmake:

    /home/bradh/coding/libheif_staging/cmake/modules/FindOpenJPEG.cmake
    /usr/share/cmake-3.27/Modules/FindOpenJPEG.cmake

  The file was not found.

  The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.

    /home/bradh/coding/libheif_staging/build/CMakeFiles/pkgRedirects

  <PackageName>_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].

    none

  CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
  [CMAKE_FIND_USE_CMAKE_PATH].

    none

  Env variable OpenJPEG_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
  [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  Paths specified by the find_package HINTS option.

    none

  Standard system environment variables
  [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].

    /home/bradh/perl5
    /home/bradh/.local
    /usr/local
    /usr
    /
    /usr/games
    /usr/local/games
    /snap
    /home/bradh/Downloads/010editor

  CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].

    none

  CMake variables defined in the Platform file
  [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].

    /usr/X11R6
    /usr/pkg
    /opt

  CMake System Package Registry
  [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].

    none

  Paths specified by the find_package PATHS option.

    none

  find_package considered the following locations for OpenJPEG's Config
  module:

    /home/bradh/coding/libheif_staging/build/CMakeFiles/pkgRedirects/OpenJPEGConfig.cmake
    /home/bradh/coding/libheif_staging/build/CMakeFiles/pkgRedirects/openjpeg-config.cmake
    /home/bradh/perl5/OpenJPEGConfig.cmake
    /home/bradh/perl5/openjpeg-config.cmake
    /home/bradh/.local/OpenJPEGConfig.cmake
    /home/bradh/.local/openjpeg-config.cmake
    /usr/local/OpenJPEGConfig.cmake
    /usr/local/openjpeg-config.cmake
    /usr/OpenJPEGConfig.cmake
    /usr/openjpeg-config.cmake
    /usr/lib/x86_64-linux-gnu/openjpeg-2.1/OpenJPEGConfig.cmake
    /usr/lib/x86_64-linux-gnu/openjpeg-2.1/openjpeg-config.cmake
    /usr/lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGConfig.cmake
    /usr/lib/x86_64-linux-gnu/openjpeg-2.5/openjpeg-config.cmake
    /OpenJPEGConfig.cmake
    /openjpeg-config.cmake
    /lib/x86_64-linux-gnu/openjpeg-2.1/OpenJPEGConfig.cmake
    /lib/x86_64-linux-gnu/openjpeg-2.1/openjpeg-config.cmake
    /lib/x86_64-linux-gnu/openjpeg-2.5/OpenJPEGConfig.cmake
    /lib/x86_64-linux-gnu/openjpeg-2.5/openjpeg-config.cmake
    /usr/games/OpenJPEGConfig.cmake
    /usr/games/openjpeg-config.cmake
    /usr/local/games/OpenJPEGConfig.cmake
    /usr/local/games/openjpeg-config.cmake
    /snap/OpenJPEGConfig.cmake
    /snap/openjpeg-config.cmake
    /opt/OpenJPEGConfig.cmake
    /opt/openjpeg-config.cmake

  The file was not found.

(The openjpeg-2.1 thing is just a symlink to openjpeg-2.5).

The start of the config file has this:

set(OPENJPEG_MAJOR_VERSION "2")
set(OPENJPEG_MINOR_VERSION "5")
set(OPENJPEG_BUILD_VERSION "0")

I don't see anything else about a version though.

@kmilos
Copy link
Contributor Author

kmilos commented Apr 16, 2024

Looks like there is a OpenJPEGConfigVersion.cmake file missing, so this is possibly a Debian/Ubuntu packaging bug that should be reported. @malaterre @hlef

Cf. the file list in Arch, Fedora, and openSUSE

On my MSYS2 UCRT64, this file contains set(PACKAGE_VERSION "2.5.2") followed by the actual version check code.

The patch is fundamentally correct IMHO. However, given that this is going to take a while to fix and propagate in Debian/Ubuntu, an alternative workaround is obviously needed, so other suggestions are welcome.

@kmilos
Copy link
Contributor Author

kmilos commented May 27, 2024

FYI, reported Debian/Ubuntu problem as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot compile OpenJPEG decoder plugin
2 participants