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: also find jconfig.h from libturbojpeg from arch-specific include directory #3640

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

Conversation

illwieckz
Copy link

@illwieckz illwieckz commented Oct 31, 2022

Description

This header file is architecture-dependent and can be stored as:

  • /usr/include/i386-linux-gnu/jconfig.h
  • /usr/include/x86_64-linux-gnu/jconfig.h

Instead of:

  • /usr/include/jconfig.h

That fixes build errors like this:

CMake Error at src/cmake/modules/FindJPEGTurbo.cmake:32 (file):
  file STRINGS file "/usr/include/jconfig.h" cannot be read.
Call Stack (most recent call first):
  src/cmake/checked_find_package.cmake:127 (find_package)
  src/cmake/externalpackages.cmake:139 (checked_find_package)
  CMakeLists.txt:155 (include)

Checklist:

  • I have read the contribution guidelines.
  • If this is more extensive than a small change to existing code, I
    have previously submitted a Contributor License Agreement
    (individual, and if there is any way my
    employers might think my programming belongs to them, then also
    corporate).

    This change is too small and not original enough to be subject to copyright.
  • I have updated the documentation, if applicable.
    Not applicable.
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).

    Not applicable.
  • My code follows the prevailing code style of this project.

…de directory

This header file is architecture-dependent and can be stored as:

- /usr/include/i386-linux-gnu/jconfig.h
- /usr/include/x86_64-linux-gnu/jconfig.h

Instead of:

- /usr/include/jconfig.h

Signed-off-by: Thomas Debesse <[email protected]>
endif()

if (NOT jconfig_header_file)
message(FATAL_ERROR "Cannot find jconfig.h from libturbojpeg")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about the FATAL_ERROR here -- if this header can't be found, I think we want only the find_package(JPEGTurbo) to not succeed, and then to fall back on regular find_package(JPEG). We don't want the entire cmake build to fail.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illwieckz Any comment or further action on this? In general, I think it's fine except for the FATAL_ERROR part.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was busy and totally forgot about it. I'll look at it again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illwieckz Ping -- can you please take a look here at my previous comment and offer an opinion?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to a WARNING.

Comment on lines +47 to 48
file(STRINGS "${jconfig_header_file}"
jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line file(STRINGS ...) needs to be inside an if (jconfig_header_file) conditional. If the header is not found, trying to extract strings from it results in a build-breaking cmake error, as you can see from the windows CI job.

@domin144
Copy link
Contributor

Starting with version 2.1.0 libjpeg-turbo provides it's own cmake config files, but they are named different to what is used in oiio cmake files.
I think the line:

checked_find_package (JPEGTurbo

Should be changed to:

checked_find_package (libjpeg-turbo

so that distro provided library is detected if present.

@lgritz
Copy link
Collaborator

lgritz commented Sep 16, 2023

That's interesting, @domin144. I'm tempted to advise abandoning this PR entirely and instead simply removing FindJPEGTurbo.cmake entirely, relying on jpeg-turbo's exported config, and calling it a day. That will mean that we are raising the floor of JPEG-turbo that we support to 2.1. But since that's still 2.5 years old and this is not a required dependency (we can automatically fall back to libjpeg), I think that would be acceptable.

Opinions?

@lgritz
Copy link
Collaborator

lgritz commented Sep 17, 2023

I tried the other strategy here: #3987

What do people think of that proposal, which would obviate the need for this one here?

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.

3 participants