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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/cmake/modules/FindJPEGTurbo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,22 @@ endif ()
if (JPEG_INCLUDE_DIR AND JPEG_LIBRARY)
set (JPEG_INCLUDE_DIRS ${JPEG_INCLUDE_DIR} CACHE PATH "JPEG include dirs")
set (JPEG_LIBRARIES ${JPEG_LIBRARY} CACHE STRING "JPEG libraries")
file(STRINGS "${JPEG_INCLUDE_DIR}/jconfig.h"

find_path(jconfig_header_file jconfig.h PATHS "${JPEG_INCLUDE_DIR}")

if (NOT jconfig_header_file)
file(GLOB_RECURSE jconfig_header_file_list "${JPEG_INCLUDE_DIR}/*/jconfig.h")

if (jconfig_header_file_list)
list(GET jconfig_header_file_list 0 jconfig_header_file)
endif()

if (NOT jconfig_header_file)
message(WARNING "Cannot find jconfig.h from libturbojpeg")
endif()
endif()

file(STRINGS "${jconfig_header_file}"
jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*")
Comment on lines +47 to 48
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.

if (jpeg_lib_version)
string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*"
Expand Down