mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-19 21:50:39 -06:00
FindJPEG: Add version detection and associated test update and docs
This commit is contained in:
@@ -18,12 +18,16 @@
|
|||||||
# where to find jpeglib.h, etc.
|
# where to find jpeglib.h, etc.
|
||||||
# ``JPEG_LIBRARIES``
|
# ``JPEG_LIBRARIES``
|
||||||
# the libraries needed to use JPEG.
|
# the libraries needed to use JPEG.
|
||||||
|
# ``JPEG_VERSION``
|
||||||
|
# the version of the JPEG library found
|
||||||
#
|
#
|
||||||
# Cache variables
|
# Cache variables
|
||||||
# ^^^^^^^^^^^^^^^
|
# ^^^^^^^^^^^^^^^
|
||||||
#
|
#
|
||||||
# The following cache variables may also be set:
|
# The following cache variables may also be set:
|
||||||
#
|
#
|
||||||
|
# ``JPEG_INCLUDE_DIR``
|
||||||
|
# where to find jpeglib.h, etc.
|
||||||
# ``JPEG_LIBRARY``
|
# ``JPEG_LIBRARY``
|
||||||
# where to find the JPEG library.
|
# where to find the JPEG library.
|
||||||
|
|
||||||
@@ -32,8 +36,29 @@ find_path(JPEG_INCLUDE_DIR jpeglib.h)
|
|||||||
set(JPEG_NAMES ${JPEG_NAMES} jpeg libjpeg)
|
set(JPEG_NAMES ${JPEG_NAMES} jpeg libjpeg)
|
||||||
find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES})
|
find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES})
|
||||||
|
|
||||||
|
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}")
|
||||||
|
unset(jpeg_lib_version)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
find_package_handle_standard_args(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR)
|
find_package_handle_standard_args(JPEG
|
||||||
|
REQUIRED_VARS JPEG_LIBRARY JPEG_INCLUDE_DIR
|
||||||
|
VERSION_VAR JPEG_VERSION)
|
||||||
|
|
||||||
if(JPEG_FOUND)
|
if(JPEG_FOUND)
|
||||||
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2
|
foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2
|
||||||
HDF5 LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf)
|
HDF5 JPEG LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf)
|
||||||
check_version_string(${VTEST} ${VTEST}_VERSION)
|
check_version_string(${VTEST} ${VTEST}_VERSION)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user