[CMake] cmake PyQT/SIP

luxInteg lux-integ at btconnect.com
Thu Dec 2 05:54:54 EST 2010


On Thursday 02 December 2010 07:48:55 Michael Wild wrote:
> On 12/02/2010 08:25 AM, Alan W. Irwin wrote:
> > On 2010-12-02 06:32+0100 Michael Wild wrote:
> >> On 12/02/2010 12:37 AM, luxInteg wrote:
> >>> On Tuesday 30 November 2010 22:43:34 luxInteg wrote:
> >>>> Greetings
> >>>> 
> >>>> I an learnig cmake.
> >>> 
> >>> My test project is as follows:-
> >>> linux machine with pyQt4, sip-4.10.2,qt-4.6.2 and cmake-2.8.2
> >>> 
> >>> ---stepA: I have a file -fileA.sip.
> >>> ---stepB: Upon execution of fileA.sip  two files  files -fileC.cpp and
> >>> fileD.cpp    result,
> >>> ---stepC: fileC.cpp and fileD,cpp are compiled into  a shared library.
> >>> 
> >>> I am ok with stepC.  I do not know how to carry out step B
> >>> execution  within
> >>> cmake.
> >>> 
> >>> advice would be appreciated.
> >>> 
> >>> sincerely
> >>> luxInteg
> >> 
> >> 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)
> 
thaks to you all for suggestions.

Before I saw the posts,  I had actually  'blind-man-fumbled' into something   
that looks like this:-
---------------------
set(sip_generator ../wherever/FileA.sip )
set(generatorCMD "sip -C . ../wherever/FileA.sip" )

set(sipED-SRS
../path/to/fileC.cpp
../path/to/FileD.cpp
)


ADD_CUSTOM_COMMAND(
   OUTPUT ${CMAKE_SOURCE_DIR}/${sipED-SRS}
   COMMAND ${generatorCMD}
   DEPENDS ${sip_generator} )
----------------------

(beforehand I would have to  actually designate some directory  in the  
source-tree equivalent to '/path/to/'.  (And this I am unsure of.)

I have posted it   only because I want to know if I can group the generated 
source files as  ${sipED_SRS} AND if so  how   the line  with  OUTPUT is set 
to find them.

thanks again


More information about the CMake mailing list