Only try to run the libjpeg-turbo test program if we aren't cross-compiling.  In a cross-compile environment, we'll settle for just making sure it compiles and links.  Even though that can theoretically produce situations in which the wrong libjpeg is linked, such situations would be exceedingly rare in a cross-compile environment, since there is no "system libjpeg" to accidentally link with.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4611 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a3b23a..4a95961 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,7 +220,7 @@
   set(CMAKE_REQUIRED_DEFINITIONS -MT)
 endif()
 
-check_c_source_runs("\n
+set(JPEG_TEST_SOURCE "\n
   #include <stdio.h>\n
   #include <jpeglib.h>\n
   int main(void) {\n
@@ -233,7 +233,13 @@
     cinfo.in_color_space = JCS_EXT_RGB;\n
     jpeg_default_colorspace(&cinfo);\n
     return 0;\n
-  }" FOUND_LIBJPEG_TURBO)
+  }")
+
+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)