Skip to content

JPEG_VERSION not defined for the library installed with OpenCV #41

@vintage-camera-pictures

Description

@vintage-camera-pictures

I have a problem using LibRaw-cmake in a project that depends on OpenCV. It appears that OpenCV builds libJPEG library and find_package(JPEG) in LibRaw-cmake CMakeLists.txt returns True. At the same time JPEG_VERSION is not defined for some reason and the if-statement

if(JPEG_FOUND)
    if (${JPEG_VERSION} LESS 80)
        set(JPEG8_FOUND FALSE)
    else()
        set(JPEG8_FOUND TRUE)
    endif()
endif()

produces the following error:

[cmake] CMake Error at external/libraw-cmake/CMakeLists.txt:179 (if):
[cmake]   if given arguments:
[cmake] 
[cmake]     "LESS" "80"
[cmake] 
[cmake]   Unknown arguments specified

due to JPEG_VERSION not defined.

As a work-around I replaced JPEG_FOUND with ${JPEG_VERSION}:

if(${JPEG_VERSION})
    if (${JPEG_VERSION} LESS 80)
        set(JPEG8_FOUND FALSE)
    else()
        set(JPEG8_FOUND TRUE)
    endif()
endif()

and it seems to resolve the issue.

The problem is likely in OpenCV. They do not support integration with FetchContent and have no plans to implement it. There is an open issue that remains unsolved for several years now.

Also, I noticed that find_package(JPEG) statement appears twice:

# zlib library check

find_package(ZLIB)
find_package(JPEG)

and a few lines below

# JPEG library check
find_package(JPEG)

Is that intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions