diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2018-11-06 18:20:36 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2018-11-06 21:45:52 (GMT) |
commit | 1c4c4be509ab548d9e848a8850c30e3dbbb7f8bc (patch) | |
tree | 11b337d3933fccf5dc0ae47a0829244f427cdda4 /Modules/FindJPEG.cmake | |
parent | bfdd1ba604a31b3bb9f0baa29ce6fce467ee2e47 (diff) | |
download | CMake-1c4c4be509ab548d9e848a8850c30e3dbbb7f8bc.zip CMake-1c4c4be509ab548d9e848a8850c30e3dbbb7f8bc.tar.gz CMake-1c4c4be509ab548d9e848a8850c30e3dbbb7f8bc.tar.bz2 |
FindJPEG: handle multiarch installs of libjpeg-turbo
Fedora installs a `jconfig-32.h` and `jconfig-64.h` which were not
searched. Instead, glob up all `jconfig` headers and bail once we've
found a version number.
Diffstat (limited to 'Modules/FindJPEG.cmake')
-rw-r--r-- | Modules/FindJPEG.cmake | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 0aa387a..f50f79e 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -67,23 +67,33 @@ endif() unset(jpeg_names) unset(jpeg_names_debug) -if(JPEG_INCLUDE_DIR AND EXISTS "${JPEG_INCLUDE_DIR}/jpeglib.h") - file(STRINGS "${JPEG_INCLUDE_DIR}/jpeglib.h" - jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*") - - if (NOT jpeg_lib_version) - # libjpeg-turbo sticks JPEG_LIB_VERSION in jconfig.h - find_path(jconfig_dir jconfig.h) - if (jconfig_dir) - file(STRINGS "${jconfig_dir}/jconfig.h" - jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*") - endif() - unset(jconfig_dir) - endif() - - string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*" - "\\1" JPEG_VERSION "${jpeg_lib_version}") +if(JPEG_INCLUDE_DIR) + file(GLOB _JPEG_CONFIG_HEADERS_FEDORA "${JPEG_INCLUDE_DIR}/jconfig*.h") + file(GLOB _JPEG_CONFIG_HEADERS_DEBIAN "${JPEG_INCLUDE_DIR}/*/jconfig.h") + set(_JPEG_CONFIG_HEADERS + "${JPEG_INCLUDE_DIR}/jpeglib.h" + ${_JPEG_CONFIG_HEADERS_FEDORA} + ${_JPEG_CONFIG_HEADERS_DEBIAN}) + foreach (_JPEG_CONFIG_HEADER IN LISTS _JPEG_CONFIG_HEADERS) + if (NOT EXISTS "${_JPEG_CONFIG_HEADER}") + continue () + endif () + file(STRINGS "${_JPEG_CONFIG_HEADER}" + jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*") + + if (NOT jpeg_lib_version) + continue () + endif () + + string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*" + "\\1" JPEG_VERSION "${jpeg_lib_version}") + break () + endforeach () unset(jpeg_lib_version) + unset(_JPEG_CONFIG_HEADER) + unset(_JPEG_CONFIG_HEADERS) + unset(_JPEG_CONFIG_HEADERS_FEDORA) + unset(_JPEG_CONFIG_HEADERS_DEBIAN) endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) |