LibRaw-cmake icon indicating copy to clipboard operation
LibRaw-cmake copied to clipboard

JPEG_VERSION not defined for the library installed with OpenCV

Open vintage-camera-pictures opened this issue 2 years ago • 0 comments

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?

vintage-camera-pictures avatar Dec 03 '23 10:12 vintage-camera-pictures