CMake: only do jpeg-turbo tests if a libjpeg was found

pull/3/head
Christian Beier 6 years ago
parent d6c907ffbc
commit 77dce5b6af
No known key found for this signature in database
GPG Key ID: 421BB3B45C6067F8

@ -58,39 +58,41 @@ endif(WITH_ZLIB)
if(WITH_JPEG) if(WITH_JPEG)
find_package(JPEG) find_package(JPEG)
# Check whether the version of libjpeg we found was libjpeg-turbo and print a if(JPEG_FOUND)
# warning if not. # Check whether the version of libjpeg we found was libjpeg-turbo and print a
set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) # warning if not.
set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
set(JPEG_TEST_SOURCE "\n
#include <stdio.h>\n set(JPEG_TEST_SOURCE "\n
#include <jpeglib.h>\n #include <stdio.h>\n
int main(void) {\n #include <jpeglib.h>\n
struct jpeg_compress_struct cinfo;\n int main(void) {\n
struct jpeg_error_mgr jerr;\n struct jpeg_compress_struct cinfo;\n
cinfo.err=jpeg_std_error(&jerr);\n struct jpeg_error_mgr jerr;\n
jpeg_create_compress(&cinfo);\n cinfo.err=jpeg_std_error(&jerr);\n
cinfo.input_components = 3;\n jpeg_create_compress(&cinfo);\n
jpeg_set_defaults(&cinfo);\n cinfo.input_components = 3;\n
cinfo.in_color_space = JCS_EXT_RGB;\n jpeg_set_defaults(&cinfo);\n
jpeg_default_colorspace(&cinfo);\n cinfo.in_color_space = JCS_EXT_RGB;\n
return 0;\n jpeg_default_colorspace(&cinfo);\n
}") return 0;\n
}")
if(CMAKE_CROSSCOMPILING)
check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) if(CMAKE_CROSSCOMPILING)
else() check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) else()
endif() check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
endif()
set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_FLAGS) set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_DEFINITIONS) set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_DEFINITIONS)
if(NOT FOUND_LIBJPEG_TURBO)
message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***") if(NOT FOUND_LIBJPEG_TURBO)
endif() message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
endif()
endif(JPEG_FOUND)
endif(WITH_JPEG) endif(WITH_JPEG)

Loading…
Cancel
Save