Handling Missing X Libs Better

Bill Hoffman bill.hoffman at kitware.com
Tue Feb 27 23:39:09 CET 2007


Alexander Neundorf wrote:
> On Tuesday 27 February 2007 21:56, Allen Winter wrote:
>   
>> On Tuesday 27 February 2007 3:42:22 pm Alexander Neundorf wrote:
>>     
>>> On Tuesday 27 February 2007 19:20, Allen Winter wrote:
>>>       
>>>> Howdy,
>>>>
>>>> Here's a problem with the buildsystem that I hope a cmake guru can fix.
>>>> A least twice I've had to help people on $kde4-devel with the following
>>>> scenario:
>>>>
>>>> - user runs cmake && make
>>>> - compile fails due to missing ICE include files
>>>> - user installs their distros libICE-devel packages
>>>> - user runs cmake && make
>>>> - linking fails (can't find libICE)
>>>>
>>>> apparently the fact that libICE can't be found is cached.
>>>> so the user needs to remove their cmake cache so the
>>>> search for libICE is re-run and then added to the linker libs list.
>>>>
>>>> Should there be an error exit from cmake if libICE can't be found
>>>> in the first place?
>>>>         
>>> Where does this happen ?
>>>       
>> Alex,
>>
>> You're forcing me to not be lazy :)
>>
>> OK, in FindX11.cmake we see
>>     CHECK_LIBRARY_EXISTS("ICE" "IceConnectionNumber" "${X11_LIBRARY_DIR}"
>>                          CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
>>     if (CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
>>       set(X11_X_PRE_LIBS -lSM -lICE)
>>     endif (CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
>>
>> If not found, then you'll have in CMakeCache.txt:
>> MAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER:INTERNAL=0
>> and cmake continues normally.
>>
>> then the compile starts and errors when you encounter a file that
>> looks for an ICE include file.
>>
>> then you realize you need the libICE devel package, so you install it.
>>
>> then you run cmake again, but CHECK_LIBRARY_EXISTS("ICE".... ) apparently
>> looks at the cache value of CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER
>> so you'll never have "-lSM -lICE" added to your X11_LIBS
>>     
>
> That feels more like a bug in the cmake module. If the test wasn't successfull 
> it should try again the next time. Apparently it doesn't.
> I'll have a look.
>
> Bye
> Alex
>   

The problem seems to be that a TRY_COMPILE is being used to find a 
library.  Once a try-compile has been done, it never gets re-done.  If 
FIND_LIBRARY were used instead, it would not have that problem.

-Bill




More information about the Kde-buildsystem mailing list