multiple pathes in cmake variables

Ralf Habacker ralf.habacker at freenet.de
Sat Feb 11 18:46:04 CET 2006


Alexander Neundorf schrieb:
> Hi,
>
> On Saturday 11 February 2006 11:14, Ralf Habacker wrote:
> ...
>   
>> There seems a bug in cmake.  In cmake/modules/FindlibXML2 the following
>> config is required to detect libxml2
>>
>> FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h
>>   ${CMAKE_INCLUDE_PATH}/libxml2
>>   ${_LibXml2IncDir}/libxml2
>>   /usr/include/libxml2
>>   /usr/local/include/libxml2
>> )
>>
>> using
>>
>> cmake -DCMAKE_INCLUDE_PATH:PATH=c:\gnuwin32\include
>>
>> If more than one path is used in CMAKE_INCLUDE_PATH this detection will
>> fail.
>>
>> cmake -DCMAKE_INCLUDE_PATH:PATH=c:\gnuwin32\include;c:\xyz\include
>>
>> the FIND_PATH function tried to find the include file libxml/xpath.h in
>> "c:\gnuwin32\include;c:\xyz\include/libxml2" which fails as one path and
>> not as  in c:\gnuwin32\include/libxml2 and c:\xyz\include/libxml2 expected.
>>
>> That means that multiple pathes in a variable and concatenation of
>> additional subdirs dot not work in the FIND_PATH function or is there an
>> alternative syntax to fix this problem ?
>>     
>
> So the problem is that CMAKE_INCLUDE_PATH is a list and in the case above a 
> subdir is appended to it.
> This has to be fixed in FindFoo.cmake script, something like this (not tested, 
> syntax may be incorrect):
>
> set(allIncDirs)
> foreach(incDir ${CMAKE_INCLUDE_PATH})
>    set(allIncDirs ${allIncDirs} ${incDir}/libxml2)
> endforeach(incDir ${CMAKE_INCLUDE_PATH})
>
> find_path(... ${allIncDirs} ...)
>
>   
Thanks for this hint, but it does not work because

when using

F:\daten\kdelibs>cmake -G "MinGW Makefiles" 
-DCMAKE_INCLUDE_PATH:STRING=f:\daten\gnuwin32\include;c:\Programme\kdewin32\include
CMAKE_LIBRARY_PATH:STRING=f:\daten\gnuwin32\lib;c:\Programme\kdewin32\lib

allIncDir is set to 
f:\daten\gnuwin32\include/libxml2;c:\Programme\kdewin32\include/libxml2, 
which was given as one path to FIND_PATH


<snip>

CMake Error: Could not find LibXml2
<snip>

instead the following code work although several directory will be 
searched multiple times.

foreach(incDir ${CMAKE_INCLUDE_PATH})
    FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h
        ${incDir}/libxml2
      ${_LibXml2IncDir}/libxml2
      /usr/include/libxml2
      /usr/local/include/libxml2
    )
endforeach(incDir ${CMAKE_INCLUDE_PATH})

Any better way to deal with  like extending FIND_PATH to be able to 
handle path lists ?

Ralf




More information about the Kde-buildsystem mailing list