On 12/02/2010 11:54 AM, luxInteg wrote: > 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
No, you can't. CMake simply concatenates the strings when you do ${CMAKE_SOURCE_DIR}/${sipED-SRS}. You'll have to put CMAKE_BINARY_DIR (or equivalent, like CMAKE_CURRENT_BINARY_DIR) in front of every element in sipED-SRCS. A few additional issues: - never EVER create output in the source tree, only in the build tree. This is an absolute taboo and is verboten. - it is a bad idea to use the hyphen (-) in a variable name. Replace it by an underscore (_). - don't use "sip" directly in your COMMAND, use FIND_EXECUTABLE first like I showed in my example. This way the user of your project can override the sip executable that is being used by specifying SIP_EXECUTABLE. - use better variable names. "sip_generator" sounds like it refers to a program. Better use "SIP_SOURCES" or similar. Also, sipED-SRS is pretty bad, make it SIP_OUTPUT. People reading the code (even yourself in a half-years time) will be very thankful to you... Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake