diff options
author | Brad King <brad.king@kitware.com> | 2018-11-08 12:30:41 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-11-08 12:30:51 (GMT) |
commit | a848abe24cd9cf05b9ffc9141d3f4a3ea633c056 (patch) | |
tree | 876410a767ce064e46c095efc3e7976936a495df | |
parent | 4193430628757eb664f65bb1810ce5077f68e2b3 (diff) | |
parent | 1c4c4be509ab548d9e848a8850c30e3dbbb7f8bc (diff) | |
download | CMake-a848abe24cd9cf05b9ffc9141d3f4a3ea633c056.zip CMake-a848abe24cd9cf05b9ffc9141d3f4a3ea633c056.tar.gz CMake-a848abe24cd9cf05b9ffc9141d3f4a3ea633c056.tar.bz2 |
Merge topic 'find-jpeg-turbo-multiarch-version'
1c4c4be509 FindJPEG: handle multiarch installs of libjpeg-turbo
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2572
-rw-r--r-- | Modules/FindJPEG.cmake | 42 | ||||
-rw-r--r-- | Tests/FindJPEG/Test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/FindJPEG/Test/main.c | 2 |
3 files changed, 29 insertions, 17 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) diff --git a/Tests/FindJPEG/Test/CMakeLists.txt b/Tests/FindJPEG/Test/CMakeLists.txt index a744f85..912c7a1 100644 --- a/Tests/FindJPEG/Test/CMakeLists.txt +++ b/Tests/FindJPEG/Test/CMakeLists.txt @@ -4,6 +4,8 @@ include(CTest) find_package(JPEG) +add_definitions(-DCMAKE_EXPECTED_JPEG_VERSION=${JPEG_VERSION}) + add_executable(test_jpeg_tgt main.c) target_link_libraries(test_jpeg_tgt JPEG::JPEG) add_test(NAME test_jpeg_tgt COMMAND test_jpeg_tgt) diff --git a/Tests/FindJPEG/Test/main.c b/Tests/FindJPEG/Test/main.c index c6e48f0..0e23eff 100644 --- a/Tests/FindJPEG/Test/main.c +++ b/Tests/FindJPEG/Test/main.c @@ -12,5 +12,5 @@ int main() cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); - return 0; + return (JPEG_LIB_VERSION != CMAKE_EXPECTED_JPEG_VERSION); } |