[CMake] cmake PyQT/SIP

luxInteg lux-integ at btconnect.com
Thu Dec 2 08:22:58 EST 2010


On Thursday 02 December 2010 10:10:59 Michael Wild wrote:

> 
> 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...
> 
 thanks for the clarification

Now supposing I want to set a preprosessor -DINT for filC.cpp and FileD.cpp is 
it done  as below (dotted lines) ?


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)

#---------------------------
SET_SOURCE_FILES_PROPERTIES  ${CMAKE_CURRENT_BINARY_DIR}/fileC.cpp PROPERTIES  
COMPILE_DEFINITIONS DINT )
SET_SOURCE_FILES_PROPERTIES  ${CMAKE_CURRENT_BINARY_DIR}/fileD.cpp PROPERTIES  
COMPILE_DEFINITIONS DINT )
#-------------------------
then
add_library(myPythonExtension SHARED
  ${CMAKE_CURRENT_BINARY_DIR}/fileC.cpp
  ${CMAKE_CURRENT_BINARY_DIR}/fileD.cpp)

sincerely
luxInteg


More information about the CMake mailing list