[CMake] cmake PyQT/SIP

Michael Wild themiwi at gmail.com
Sun Dec 5 08:51:12 EST 2010


On 12/05/2010 02:04 AM, luxInteg wrote:
> On Thursday 02 December 2010 07:48:55 Michael Wild wrote:
> 
>>>>
>>>> Use ADD_CUSTOM_COMMAND.
>>>
>>> @Michael: that advice is not correct.  add_custom_command sets up a
>>> command to be run at "make" time. Instead, the execute_process command
>>> should be used to run a command at "CMake" time which is what the OP
>>> needs to generate his *.cpp files.
>>>
>>> @LuxInteg:  See the CMakeLists.txt file at
>>> http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/bindings/qt_gui/pyq
>>> t4/
>>>
>>> for an example of generating source code with sip.
>>>
>>> Alan
>>
>> Huh, why can't he run sip at build time? If you do:
>>
>> find_program(SIP_EXECUTABLE sip)
>>
>> add_custom_command(OUTPUT
>>     ${CMAKE_CURRENT_BINARY_DIR}/fileC.cpp
>>     ${CMAKE_CURRENT_BINARY_DIR}/fileD.cpp
>>   COMMAND ${SIP_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR}
>>     ${CMAKE_CURRENT_SOURCE_DIR}/fileA.sip
>>   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fileA.sip
>>   COMMENT "Processing ${CMAKE_CURRENT_SOURCE_DIR}/fileA.sip"
>>   VERBATIM)
>>
>> add_library(myPythonExtension SHARED
>>   ${CMAKE_CURRENT_BINARY_DIR}/fileC.cpp
>>   ${CMAKE_CURRENT_BINARY_DIR}/fileD.cpp)
>>
>> # possibly link with required libraries here...
>>
> Thanks for your hep so far
> 
> I have been experimenting on the  above with the following results:-
> 
> When the  dependency has other dependencies  the  above appears to fail;  i.e 
> when  filA.sip calls some file  say  PyQt4/QTCore/somefile.sip.  (And I do not 
> know of anyway of fitting this inside the add_custom_command() function.)
> 
> I tried  beforehand 
>                     this:-
> set(PYQt4_SIP_FILES   /usr/share/sip/PyQt4)   
>                     then 
> COMMAND ${SIP_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR}
>     ${CMAKE_CURRENT_SOURCE_DIR}/fileA.sip
>   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fileA.sip
>   ${PYQt4_SIP_FILES}/PyQt4/QTCore/somefile.sip
>   MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/fileA.sip
> 
> I even tried (the penultimate line)   with ${PYQt4_SIP_FILES}/PyQt4/  
> 
> but each time it comes  back with 
> 
> "sip: Unable to find file "QtCore/somefile.sip" "
> 
> I am using  a FindSIP.cmake that kde4 uses.
> 
> Advice would be appreciated
> 
> luxInteg

The DEPENDS option tells CMake about the dependency on somefile.sip, but
not sip. You also need to pass "-I ${PYQT4_SIP_FILES}" to the sip processor.

One word of advice: you seem to spurn documentation, but you really
should read it. At some point people get tired answering the most simple
questions, ending up doing your work. Such simple questions are a waste
of time; both for you (you have to wait until someone answers your
question, which might take hours if not days), and for us, answering
them. You could have answered all of your questions by working your way
through a CMake tutorial and then referring to the official CMake
documentation. CMake is well-documented (give "man cmake" or the
web-based documentation
http://www.cmake.org/cmake/help/cmake-2-8-docs.html) a try. Also, I
never used SIP in my life, but finding out about the "-I" flag took me
about 10 seconds (as long as it took me to type "man sip" and then
search for "include")...

Michael


More information about the CMake mailing list