2011-01-20 22:38:58 +01:00
|
|
|
find_path(PYQT_SIP_DIR QtCore/qstring.sip
|
2011-01-18 13:47:26 +01:00
|
|
|
PATHS /System/Library/Frameworks/Python.framework/Versions/2.6
|
2011-02-27 13:14:12 +01:00
|
|
|
PATH_SUFFIXES share/sip/PyQt4 share/sip ../share/sip share/py-sip/
|
2010-12-31 19:13:28 +01:00
|
|
|
)
|
|
|
|
|
2011-01-18 13:47:26 +01:00
|
|
|
find_program(SIP_BINARY "sip"
|
2011-02-01 00:44:44 +01:00
|
|
|
PATHS /System/Library/Frameworks/Python.framework/Versions/2.6/bin
|
|
|
|
CMAKE_FIND_ROOT_PATH_BOTH
|
|
|
|
)
|
2011-01-18 13:47:26 +01:00
|
|
|
|
2011-01-02 16:30:15 +01:00
|
|
|
macro(add_sip_binding outputvar source)
|
2010-12-31 19:13:28 +01:00
|
|
|
# Work out what the SIP flags should be for PyQt4. These would normally be
|
|
|
|
# obtained from PyQt4.pyqtconfig.Configuration().pyqt_sip_flags, but we can't
|
|
|
|
# call that when cross-compiling.
|
2011-01-27 16:40:53 +01:00
|
|
|
set(PYQT_SIP_FLAGS
|
|
|
|
"-x" "VendorID"
|
|
|
|
"-x" "PyQt_NoPrintRangeBug"
|
2011-02-15 22:08:39 +01:00
|
|
|
"-o"
|
2011-01-27 16:40:53 +01:00
|
|
|
)
|
2010-12-31 19:13:28 +01:00
|
|
|
|
|
|
|
if(WIN32)
|
2011-01-27 16:40:53 +01:00
|
|
|
list(APPEND PYQT_SIP_FLAGS "-t" "Qt_4_6_2")
|
2010-12-31 19:13:28 +01:00
|
|
|
list(APPEND PYQT_SIP_FLAGS "-t" "WS_WIN")
|
|
|
|
elseif(APPLE)
|
2011-01-27 16:40:53 +01:00
|
|
|
list(APPEND PYQT_SIP_FLAGS "-t" "Qt_4_7_1")
|
2011-01-18 13:47:26 +01:00
|
|
|
list(APPEND PYQT_SIP_FLAGS "-t" "WS_MACX")
|
2010-12-31 19:13:28 +01:00
|
|
|
else(WIN32)
|
2011-01-27 16:40:53 +01:00
|
|
|
list(APPEND PYQT_SIP_FLAGS "-t" "Qt_4_6_2")
|
2010-12-31 19:13:28 +01:00
|
|
|
list(APPEND PYQT_SIP_FLAGS "-t" "WS_X11")
|
|
|
|
endif(WIN32)
|
|
|
|
|
2011-01-02 16:30:15 +01:00
|
|
|
get_filename_component(source_directory ${source} PATH)
|
|
|
|
get_filename_component(source_basename ${source} NAME)
|
|
|
|
get_filename_component(source_module ${source} NAME_WE)
|
2010-12-31 19:13:28 +01:00
|
|
|
|
2011-01-02 16:30:15 +01:00
|
|
|
set(outputs
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/sip${source_module}cmodule.cpp"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/sipAPI${source_module}.h"
|
|
|
|
${ARGN}
|
|
|
|
)
|
2010-12-31 19:13:28 +01:00
|
|
|
|
2011-01-02 16:30:15 +01:00
|
|
|
# Find any included files
|
|
|
|
execute_process(
|
|
|
|
COMMAND "awk" "/^%Include/ {ORS=\";\"; print \"${source_directory}/\" $2}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${source}"
|
|
|
|
OUTPUT_VARIABLE included_files
|
|
|
|
)
|
|
|
|
foreach(included_file ${included_files} ${source})
|
|
|
|
# Sip creates 1 file per class... so we have to figure out what classes
|
|
|
|
# it will generate
|
2010-12-31 19:13:28 +01:00
|
|
|
execute_process(
|
2011-01-03 16:15:51 +01:00
|
|
|
COMMAND "awk" "/^\\s*(class|namespace|struct) +([A-Za-z0-9]+)/ {ORS=\";\"; print $2}"
|
2011-01-02 16:30:15 +01:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${included_file}"
|
|
|
|
OUTPUT_VARIABLE classes
|
2010-12-31 19:13:28 +01:00
|
|
|
)
|
2011-01-02 16:30:15 +01:00
|
|
|
foreach(class ${classes})
|
|
|
|
list(APPEND outputs "${CMAKE_CURRENT_BINARY_DIR}/sip${source_module}${class}.cpp")
|
|
|
|
endforeach(class)
|
|
|
|
endforeach(included_file)
|
2010-12-31 19:13:28 +01:00
|
|
|
|
2011-01-02 16:30:15 +01:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${outputs}
|
2011-01-18 13:47:26 +01:00
|
|
|
COMMAND ${SIP_BINARY} ${PYQT_SIP_FLAGS}
|
2011-01-02 16:30:15 +01:00
|
|
|
"-I${PYQT_SIP_DIR}"
|
|
|
|
"-c" "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/${source}"
|
|
|
|
DEPENDS ${included_files} "${source}"
|
|
|
|
)
|
2010-12-31 19:13:28 +01:00
|
|
|
|
2011-01-02 16:30:15 +01:00
|
|
|
list(APPEND ${outputvar} ${outputs})
|
|
|
|
endmacro(add_sip_binding)
|