2fbc3d9
diff -up digikam-1.8.0/CMakeLists.txt.libjpeg_version digikam-1.8.0/CMakeLists.txt
2fbc3d9
--- digikam-1.8.0/CMakeLists.txt.libjpeg_version	2011-01-23 13:33:57.000000000 -0600
2fbc3d9
+++ digikam-1.8.0/CMakeLists.txt	2011-02-04 11:34:22.712549338 -0600
2fbc3d9
@@ -151,17 +151,23 @@ ELSE(NOT APPLE)
2fbc3d9
     SET(CLAPACK_FOUND FALSE)
2fbc3d9
 ENDIF(NOT APPLE)
2fbc3d9
 
2fbc3d9
-# Extract version of libjpeg so that we can use the appropriate dir
2fbc3d9
-# See bug #227313, #228483
2fbc3d9
-FILE(READ "${JPEG_INCLUDE_DIR}/jpeglib.h" jpeglib_h_content)
2fbc3d9
-STRING(REGEX REPLACE ".*#define +JPEG_LIB_VERSION +([0-9]+).*" "\\1" jpeglib_version "${jpeglib_h_content}")
2fbc3d9
-MESSAGE(STATUS "Identified libjpeg version: ${jpeglib_version}")
2fbc3d9
-
2fbc3d9
-IF ("${jpeglib_version}" LESS 80)
2fbc3d9
-    SET(DIGIKAM_LIBJPEG_DIR libjpeg-62)
2fbc3d9
-ELSE ("${jpeglib_version}" LESS 80)
2fbc3d9
-    SET(DIGIKAM_LIBJPEG_DIR libjpeg-80)
2fbc3d9
-ENDIF ("${jpeglib_version}" LESS 80)
2fbc3d9
+# check version of libjpeg so that we can use the appropriate dir
2fbc3d9
+# See bug #227313
2fbc3d9
+set(_jpeglib_version_source "#include <stddef.h>\n#include<stdio.h>\n#include <jpeglib.h>\n int main()\n {\n #if (JPEG_LIB_VERSION >= 80) \n #error JPEG_LIB_VERSION >= 80 found \n #endif \n }\n")
2fbc3d9
+set(_jpeglib_version_source_file ${CMAKE_BINARY_DIR}/CMakeTmp/cmake_jpeglib_version_check.cpp)
2fbc3d9
+file(WRITE "${_jpeglib_version_source_file}" "${_jpeglib_version_source}")
2fbc3d9
+set(_jpeglib_version_include_dirs "-DINCLUDE_DIRECTORIES:STRING=${JPEG_INCLUDE_DIR}")
2fbc3d9
+
2fbc3d9
+try_compile(_jpeglib_version_compile_result ${CMAKE_BINARY_DIR} ${_jpeglib_version_source_file} CMAKE_FLAGS "${_jpeglib_version_include_dirs}" COMPILE_OUTPUT_VARIABLE _jpeglib_version_compile_output_var)
2fbc3d9
+
2fbc3d9
+if(_jpeglib_version_compile_result)
2fbc3d9
+MESSAGE(STATUS "Identified libjpeg version: 62")
2fbc3d9
+set(DIGIKAM_LIBJPEG_DIR libjpeg-62)
2fbc3d9
+else(_jpeglib_version_compile_result)
2fbc3d9
+MESSAGE(STATUS "Identified libjpeg version: 80+")
2fbc3d9
+set(DIGIKAM_LIBJPEG_DIR libjpeg-80)
2fbc3d9
+endif(_jpeglib_version_compile_result)
2fbc3d9
+
2fbc3d9
 
2fbc3d9
 # Check KDcraw version installed to compile fine.
2fbc3d9
 IF(NOT WIN32)