Warning, /frameworks/kdelibs4support/cmake/modules/SIPMacros.cmake is written in an unsupported language. File is not indexed.
0001 # Macros for SIP 0002 # ~~~~~~~~~~~~~~ 0003 # Copyright (c) 2007, Simon Edwards <simon@simonzone.com> 0004 # Redistribution and use is allowed according to the terms of the BSD license. 0005 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0006 # 0007 # SIP website: http://www.riverbankcomputing.co.uk/sip/index.php 0008 # 0009 # This file defines the following macros: 0010 # 0011 # ADD_SIP_PYTHON_MODULE (MODULE_NAME MODULE_SIP [library1, libaray2, ...]) 0012 # Specifies a SIP file to be built into a Python module and installed. 0013 # MODULE_NAME is the name of Python module including any path name. (e.g. 0014 # os.sys, Foo.bar etc). MODULE_SIP the path and filename of the .sip file 0015 # to process and compile. libraryN are libraries that the Python module, 0016 # which is typically a shared library, should be linked to. The built 0017 # module will also be install into Python's site-packages directory. 0018 # 0019 # The behaviour of the ADD_SIP_PYTHON_MODULE macro can be controlled by a 0020 # number of variables: 0021 # 0022 # SIP_INCLUDES - List of directories which SIP will scan through when looking 0023 # for included .sip files. (Corresponds to the -I option for SIP.) 0024 # 0025 # SIP_TAGS - List of tags to define when running SIP. (Corresponds to the -t 0026 # option for SIP.) 0027 # 0028 # SIP_CONCAT_PARTS - An integer which defines the number of parts the C++ code 0029 # of each module should be split into. Defaults to 8. (Corresponds to the 0030 # -j option for SIP.) 0031 # 0032 # SIP_DISABLE_FEATURES - List of feature names which should be disabled 0033 # running SIP. (Corresponds to the -x option for SIP.) 0034 # 0035 # SIP_EXTRA_OPTIONS - Extra command line options which should be passed on to 0036 # SIP. 0037 0038 SET(SIP_INCLUDES) 0039 SET(SIP_TAGS) 0040 SET(SIP_CONCAT_PARTS 8) 0041 SET(SIP_DISABLE_FEATURES) 0042 SET(SIP_EXTRA_OPTIONS) 0043 0044 MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP) 0045 0046 SET(EXTRA_LINK_LIBRARIES ${ARGN}) 0047 0048 STRING(REPLACE "." "/" _x ${MODULE_NAME}) 0049 GET_FILENAME_COMPONENT(_parent_module_path ${_x} PATH) 0050 GET_FILENAME_COMPONENT(_child_module_name ${_x} NAME) 0051 0052 GET_FILENAME_COMPONENT(_module_path ${MODULE_SIP} PATH) 0053 0054 if(_module_path STREQUAL "") 0055 set(CMAKE_CURRENT_SIP_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") 0056 else(_module_path STREQUAL "") 0057 set(CMAKE_CURRENT_SIP_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_module_path}") 0058 endif(_module_path STREQUAL "") 0059 0060 GET_FILENAME_COMPONENT(_abs_module_sip ${MODULE_SIP} ABSOLUTE) 0061 0062 # We give this target a long logical target name. 0063 # (This is to avoid having the library name clash with any already 0064 # install library names. If that happens then cmake dependancy 0065 # tracking get confused.) 0066 STRING(REPLACE "." "_" _logical_name ${MODULE_NAME}) 0067 SET(_logical_name "python_module_${_logical_name}") 0068 0069 FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_SIP_OUTPUT_DIR}) # Output goes in this dir. 0070 0071 SET(_sip_includes) 0072 FOREACH (_inc ${SIP_INCLUDES}) 0073 GET_FILENAME_COMPONENT(_abs_inc ${_inc} ABSOLUTE) 0074 LIST(APPEND _sip_includes -I ${_abs_inc}) 0075 ENDFOREACH (_inc ) 0076 0077 SET(_sip_tags) 0078 FOREACH (_tag ${SIP_TAGS}) 0079 LIST(APPEND _sip_tags -t ${_tag}) 0080 ENDFOREACH (_tag) 0081 0082 SET(_sip_x) 0083 FOREACH (_x ${SIP_DISABLE_FEATURES}) 0084 LIST(APPEND _sip_x -x ${_x}) 0085 ENDFOREACH (_x ${SIP_DISABLE_FEATURES}) 0086 0087 SET(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}") 0088 SET(_sip_output_files) 0089 FOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} ) 0090 IF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} ) 0091 SET(_sip_output_files ${_sip_output_files} ${CMAKE_CURRENT_SIP_OUTPUT_DIR}/sip${_child_module_name}part${CONCAT_NUM}.cpp ) 0092 ENDIF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} ) 0093 ENDFOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} ) 0094 0095 IF(NOT WIN32) 0096 SET(TOUCH_COMMAND touch) 0097 ELSE(NOT WIN32) 0098 SET(TOUCH_COMMAND echo) 0099 # instead of a touch command, give out the name and append to the files 0100 # this is basically what the touch command does. 0101 FOREACH(filename ${_sip_output_files}) 0102 FILE(APPEND filename "") 0103 ENDFOREACH(filename ${_sip_output_files}) 0104 ENDIF(NOT WIN32) 0105 ADD_CUSTOM_COMMAND( 0106 OUTPUT ${_sip_output_files} 0107 COMMAND ${CMAKE_COMMAND} -E echo ${message} 0108 COMMAND ${TOUCH_COMMAND} ${_sip_output_files} 0109 COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_SIP_OUTPUT_DIR} ${_sip_includes} ${_abs_module_sip} 0110 DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND} 0111 ) 0112 # not sure if type MODULE could be uses anywhere, limit to cygwin for now 0113 IF (CYGWIN) 0114 ADD_LIBRARY(${_logical_name} MODULE ${_sip_output_files} ) 0115 ELSE (CYGWIN) 0116 ADD_LIBRARY(${_logical_name} SHARED ${_sip_output_files} ) 0117 ENDIF (CYGWIN) 0118 TARGET_LINK_LIBRARIES(${_logical_name} ${PYTHON_LIBRARY}) 0119 TARGET_LINK_LIBRARIES(${_logical_name} ${EXTRA_LINK_LIBRARIES}) 0120 SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES PREFIX "" OUTPUT_NAME ${_child_module_name}) 0121 0122 INSTALL(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_INSTALL_DIR}/${_parent_module_path}") 0123 0124 ENDMACRO(ADD_SIP_PYTHON_MODULE)