Salome HOME
Split PyConsole in order to be used easily outside GUI of SALOME.
[modules/gui.git] / adm_local / cmake_files / UsePyQt4.cmake
index ee3ec4558d2553677cd16475f6fa36073fc563d3..391ce98fece9ac5d9c913046e7fdc2d13d5c601c 100644 (file)
@@ -18,6 +18,8 @@
 #
 # Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 
+INCLUDE(UseSIP)
+
 ####################################################################
 #
 # _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME: internal function
@@ -81,6 +83,7 @@ MACRO(PYQT4_WRAP_UIC outfiles)
   ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL DEPENDS ${${outfiles}})
 
  ELSE(NOT WIN32)
+
 ####
 # ANA: Workaround for the Microsoft Visual Studio 2010. Seems there is a bug in 
 # the Microsoft Visual Studio 2010 or CMake 2.8.10.2: custom target doesn't work 
@@ -113,71 +116,15 @@ ENDMACRO(PYQT4_WRAP_UIC)
 #
 # Generate C++ wrappings for *.sip files by processing them with sip.
 #
-# USAGE: PYQT4_WRAP_SIP(output_files sip_files)
+# USAGE: PYQT4_WRAP_SIP(output_files sip_file [sip_file...] [OPTIONS options] [SOURCES sources])
 #
-# ARGUMENTS:
-#   output_files [out] variable where output file names are listed to
-#   sip_files    [in]  list of *.sip files
-# 
-# NOTES:
-#   - Input files are considered relative to the current source directory.
-#   - Output files are generated in the current build directory.
-#   - This version of macro requires class(es) definition in the 
-#     *.sip file to be started on a new line without any preceeding characters.
-# 
-# WARNING:
-#   - The macro does not properly processes sip features which are wrapped
-#     with sip conditionals.
-#   - The macro works only if one single sip module is processed
-#     (there's only one %Module directive within all input sip files).
-#
-# TODO:
-#   - Check if dependency of static sources on generated headers works properly:
-#     if header is changed, dependant sources should be recompiled.
-#   - Think how to properly process sip conditionals.
-#   - Process several sip modules.
+# NOTES: See SIP_WRAP_SIP macro from UseSIP.cmake for the usage description.
 # 
 ####################################################################
 MACRO(PYQT4_WRAP_SIP outfiles)
-  SET(_output)
-  SET(_module_input)
-  FOREACH(_input ${ARGN})
-    FILE(STRINGS ${_input} _sip_modules REGEX "%Module")
-    FILE(STRINGS ${_input} _sip_classes REGEX "^class ")
-    FOREACH(_sip_module ${_sip_modules})
-      STRING(REGEX MATCH ".*%Module *\\( *name=.*\\).*" _mod_name "${_sip_module}")
-      IF (_mod_name)
-       STRING(REGEX REPLACE ".*%Module *\\( *name=(.*).*\\).*" "\\1" _mod_name ${_sip_module})
-      ELSE()
-       STRING(REGEX REPLACE ".*%Module *(.*)" "\\1" _mod_name ${_sip_module})
-      ENDIF()
-      SET(_mod_header "sipAPI${_mod_name}.h")
-      SET(_mod_source "sip${_mod_name}cmodule${PYQT_CXX_EXT}")
-      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source})
-      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source})
-      SET(_module_input ${_input})
-    ENDFOREACH()
-    FOREACH(_sip_class ${_sip_classes})
-      STRING(REGEX MATCH ".*class +.* *:" _class_name "${_sip_class}")
-      IF (_class_name)
-       STRING(REGEX REPLACE ".*class +(.*) *:.*" "\\1" _class_name ${_sip_class})
-      ELSE()
-       STRING(REGEX REPLACE ".*class *(.*)" "\\1" _class_name ${_sip_class})
-      ENDIF()
-      STRING(STRIP ${_class_name} _class_name)
-      SET(_class_source "sip${_mod_name}${_class_name}${PYQT_CXX_EXT}")
-      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_class_source})
-      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_class_source})
-    ENDFOREACH()
-  ENDFOREACH()
-  ADD_CUSTOM_COMMAND(
-    OUTPUT ${_output}
-    COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${_module_input}
-    MAIN_DEPENDENCY ${_module_input}
-    )
+  SIP_WRAP_SIP(${outfiles} ${ARGN} OPTIONS ${PYQT_SIPFLAGS})
 ENDMACRO(PYQT4_WRAP_SIP)
 
-
 ####################################################################
 #
 # PYQT4_WRAP_QRC macro