[CMake] cmake PyQT/SIP
Michael Wild
themiwi at gmail.com
Thu Dec 2 07:27:27 EST 2010
On 12/02/2010 02:22 PM, luxInteg wrote:
> 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
If you only want it to be set for these two files, do
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/fileC.cpp
${CMAKE_CURRENT_BINARY_DIR}/fileD.cpp
PROPERTIES COMPILE_FLAGS INT)
i.e. you can set it for both files in the same call, and you leave away
the D. The D is only a compiler flag when using -DINT, the actual symbol
is INT.
If it is OK to set INT for all source files in this and its child
directories, it's simpler to do
add_definitions(-DINT)
Michael
More information about the CMake
mailing list