[CMake] include_directories and qt4_wrap_cpp

Clinton Stimpson clinton at elemtech.com
Mon Aug 2 11:09:09 EDT 2010


On 08/02/2010 09:02 AM, Michael Wild wrote:
> On 2. Aug, 2010, at 16:44 , Dennis Schridde wrote:
>
>    
>> Hello!
>>
>> I setup include_directories and then call qt4_wrap_cpp for a set of
>> files. What I am seeing now is that the set of -I flags for moc are
>> different from those for the
>> compiler:
>>
>> include_directories(/a/b/c/lib/mylib/framework)
>> qt4_wrap_cpp(MOC
>> testfile.hpp)
>>
>> [<<  Commandlines shortened for readability>>]
>> /usr/bin/moc
>> [...] -F/a/b/c/lib [...] -o moc_testfile.cxx testfile.hpp
>> [...]
>> /usr/bin/c++
>> [...] -I/a/b/c/lib/mylib/framework -o testfile.cpp.o -c testfile.cpp
>>
>> My
>> first guess is that CMake detects the pattern lib/mylib/framework as
>> something special, strips the mylib/framework part, and thus screws up.
>>
>> Can
>> someone elaborate on this behaviour?
>>
>> Kind regards,
>> Dennis
>>      
> I didn't look into the source code, but looks like there is some REGEX REPLACE which is too simplistic. Probably there is a missing escape for the . character, thus making it also match /framework, instead of just .framework.
>
>    

Yeah, that seems to be the problem.
Dennis, can you edit your Qt4Macros.cmake in the cmake installation and 
fix the following section to

   FOREACH(_current ${_inc_DIRS})
     IF("${_current}" MATCHES "\.framework/?$")
       STRING(REGEX REPLACE "/[^/]+\.framework" "" framework_path 
"${_current}")
       SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
     ELSE("${_current}" MATCHES "\.framework/?$")
       SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
     ENDIF("${_current}" MATCHES "\.framework/?$")
   ENDFOREACH(_current ${_inc_DIRS})

Let me know if that works for you.

Clint


More information about the CMake mailing list