From 77dce5b6af7d95afc486b7353217743f4371bb04 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Wed, 26 Sep 2018 20:48:25 +0200 Subject: [PATCH] CMake: only do jpeg-turbo tests if a libjpeg was found --- CMakeLists.txt | 68 ++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0f1537..70907b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,39 +58,41 @@ endif(WITH_ZLIB) if(WITH_JPEG) find_package(JPEG) - # Check whether the version of libjpeg we found was libjpeg-turbo and print a - # warning if not. - set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) - set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) - - set(JPEG_TEST_SOURCE "\n - #include \n - #include \n - int main(void) {\n - struct jpeg_compress_struct cinfo;\n - struct jpeg_error_mgr jerr;\n - cinfo.err=jpeg_std_error(&jerr);\n - jpeg_create_compress(&cinfo);\n - cinfo.input_components = 3;\n - jpeg_set_defaults(&cinfo);\n - cinfo.in_color_space = JCS_EXT_RGB;\n - jpeg_default_colorspace(&cinfo);\n - return 0;\n - }") - - if(CMAKE_CROSSCOMPILING) - check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) - else() - check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) - endif() - - set(CMAKE_REQUIRED_LIBRARIES) - 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/ ***") - endif() + if(JPEG_FOUND) + # Check whether the version of libjpeg we found was libjpeg-turbo and print a + # warning if not. + set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) + set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) + + set(JPEG_TEST_SOURCE "\n + #include \n + #include \n + int main(void) {\n + struct jpeg_compress_struct cinfo;\n + struct jpeg_error_mgr jerr;\n + cinfo.err=jpeg_std_error(&jerr);\n + jpeg_create_compress(&cinfo);\n + cinfo.input_components = 3;\n + jpeg_set_defaults(&cinfo);\n + cinfo.in_color_space = JCS_EXT_RGB;\n + jpeg_default_colorspace(&cinfo);\n + return 0;\n + }") + + if(CMAKE_CROSSCOMPILING) + check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) + else() + check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) + endif() + + set(CMAKE_REQUIRED_LIBRARIES) + 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/ ***") + endif() + endif(JPEG_FOUND) endif(WITH_JPEG)