I believe it is necessary, yes.  It ensures that you are actually
linking with libjpeg-turbo.

The most common means of linking against libjpeg-turbo requires using
the libjpeg-turbo SDK, which installs in a path that won't be found by
FindJPEG.cmake.  Thus, there is a high potential for user error if we
don't perform this check.  A user could, for instance, specify
JPEG_INCLUDE_DIR and pick up the proper header file in
/opt/libjpeg-turbo/include, but they could forget to specify
JPEG_LIBRARIES.  Without the run-time check, they will get "bogus
colorspace" errors, which are hard to debug.  I wouldn't have added the
code if I hadn't made that mistake myself!

I think the right thing to do would be to move the tests into a separate
CMake file (FindLibjpegTurbo.cmake or whatever) and use the "new" test
if not in a cross-compilation environment, otherwise use the old test.
I'll look into that.


On 8/1/11 3:27 AM, Peter Åstrand wrote:
> 
> Is this really necessary? It makes it more difficult to cross compile.
> Now I get:
> 
> -- Found JPEG: /usr/i686-pc-mingw32/sys-root/mingw/lib/libjpeg.dll.a
> -- Performing Test FOUND_LIBJPEG_TURBO
> CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the
> following cache variables appropriately:
>    FOUND_LIBJPEG_TURBO_EXITCODE (advanced)
> For details see /home/astrand/thin/vnc/tigervnc/trunk/TryRunResults.cmake
> -- Performing Test FOUND_LIBJPEG_TURBO - Failed
> 
> I can work around this by setting -DFOUND_LIBJPEG_TURBO_EXITCODE=0, but
> I don't think it should be this complicated.
> 
> Rgds,
> Peter
> 
> On Thu, 28 Jul 2011, dcomman...@users.sourceforge.net wrote:
> 
>> Revision: 4602
>>          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4602&view=rev
>> Author:   dcommander
>> Date:     2011-07-28 08:06:39 +0000 (Thu, 28 Jul 2011)
>>
>> Log Message:
>> -----------
>> Actually link and run the libjpeg-turbo test program to ensure that
>> JPEG_LIBRARY is set correctly
>>
>> Modified Paths:
>> --------------
>>    trunk/CMakeLists.txt
>>
>> Modified: trunk/CMakeLists.txt
>> ===================================================================
>> --- trunk/CMakeLists.txt    2011-07-28 07:22:39 UTC (rev 4601)
>> +++ trunk/CMakeLists.txt    2011-07-28 08:06:39 UTC (rev 4602)
>> @@ -13,6 +13,7 @@
>> include(CheckTypeSize)
>> include(CheckCSourceCompiles)
>> include(CheckCXXSourceCompiles)
>> +include(CheckCSourceRuns)
>>
>> include(CMakeMacroLibtoolFile)
>>
>> @@ -176,11 +177,28 @@
>> # Warn if it doesn't seem to be the accelerated libjpeg that's found
>> set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
>> set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
>> +if(MSVC)
>> +  set(CMAKE_REQUIRED_DEFINITIONS -MT)
>> +endif()
>>
>> -check_c_source_compiles("#include <stdio.h>\n#include
>> <jpeglib.h>\nint main(int c, char** v) { return JCS_EXT_RGBX; }"
>> FOUND_LIBJPEG_TURBO)
>> +check_c_source_runs("\n
>> +  #include <stdio.h>\n
>> +  #include <jpeglib.h>\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
>> +  }" FOUND_LIBJPEG_TURBO)
>>
>> set(CMAKE_REQUIRED_LIBRARIES)
>> set(CMAKE_REQUIRED_FLAGS)
>> +set(CMAKE_REQUIRED_DEFINITIONS)
>>
>> if(NOT FOUND_LIBJPEG_TURBO)
>>   message(STATUS "WARNING: You are not using libjpeg-turbo.
>> Performance will suffer.")
>>
>>
>> This was sent by the SourceForge.net collaborative development
>> platform, the world's largest Open Source development site.
>>
>> ------------------------------------------------------------------------------
>>
>> Got Input?   Slashdot Needs You.
>> Take our quick survey online.  Come on, we don't ask for help often.
>> Plus, you'll get a chance to win $100 to spend on ThinkGeek.
>> http://p.sf.net/sfu/slashdot-survey
>> _______________________________________________
>> Tigervnc-commits mailing list
>> tigervnc-comm...@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tigervnc-commits
>>
> 
> 
> ---
> Peter Åstrand        ThinLinc Chief Developer
> Cendio AB        http://www.cendio.com
> Wallenbergs gata 4
> 583 30 Linköping    Phone: +46-13-21 46 00
> 
> 
> ------------------------------------------------------------------------------
> Got Input?   Slashdot Needs You.
> Take our quick survey online.  Come on, we don't ask for help often.
> Plus, you'll get a chance to win $100 to spend on ThinkGeek.
> http://p.sf.net/sfu/slashdot-survey
> 
> 
> 
> _______________________________________________
> Tigervnc-devel mailing list
> Tigervnc-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to