X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=adm_local%2Fcmake_files%2FUsePyQt4.cmake;h=391ce98fece9ac5d9c913046e7fdc2d13d5c601c;hb=11a370454e581b8e532a2a58bff6cd18136ebafd;hp=aa41a6be2e692141518bdfa1534a81eefa104369;hpb=1c34a194edd4d0370f1929a6a87c75c7a961cb36;p=modules%2Fgui.git diff --git a/adm_local/cmake_files/UsePyQt4.cmake b/adm_local/cmake_files/UsePyQt4.cmake index aa41a6be2..391ce98fe 100644 --- a/adm_local/cmake_files/UsePyQt4.cmake +++ b/adm_local/cmake_files/UsePyQt4.cmake @@ -1,9 +1,9 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2012-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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 @@ -63,19 +65,49 @@ ENDFUNCTION() # #################################################################### MACRO(PYQT4_WRAP_UIC outfiles) + + IF(NOT WIN32) + FOREACH(_input ${ARGN}) GET_FILENAME_COMPONENT(_input_name ${_input} NAME) STRING(REPLACE ".ui" "_ui.py" _input_name ${_input_name}) SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name}) ADD_CUSTOM_COMMAND( OUTPUT ${_output} - COMMAND ${PYQT_PYUIC_EXECUTABLE} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} + COMMAND ${PYQT_PYUIC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} MAIN_DEPENDENCY ${_input} ) SET(${outfiles} ${${outfiles}} ${_output}) ENDFOREACH() _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName) 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 +# for the list of the dependencies. It works only for the first dependency in the +# list. So generate separate target for the each input file. This problem will be +#investigated in the future. +#### + + SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) + _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName) + ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL) + FOREACH(_input ${ARGN}) + GET_FILENAME_COMPONENT(_input_name ${_input} NAME) + STRING(REPLACE ".ui" "_ui.py" _input_name ${_input_name}) + SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name}) + _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _TgName) + ADD_CUSTOM_TARGET(${_TgName} ${PYQT_PYUIC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} + DEPENDS ${_input} + ) + SET_TARGET_PROPERTIES(${_TgName} PROPERTIES FOLDER PYQT4_WRAP_UIC_TARGETS) + ADD_DEPENDENCIES(${_uniqueTargetName} DEPEND ${_TgName}) + SET(${outfiles} ${${outfiles}} ${_output}) + ENDFOREACH() + ENDIF(NOT WIN32) ENDMACRO(PYQT4_WRAP_UIC) #################################################################### @@ -84,56 +116,46 @@ 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]) +# +# NOTES: See SIP_WRAP_SIP macro from UseSIP.cmake for the usage description. +# +#################################################################### +MACRO(PYQT4_WRAP_SIP outfiles) + SIP_WRAP_SIP(${outfiles} ${ARGN} OPTIONS ${PYQT_SIPFLAGS}) +ENDMACRO(PYQT4_WRAP_SIP) + +#################################################################### +# +# PYQT4_WRAP_QRC macro +# +# Generate Python wrappings for *.qrc files by processing them with pyrcc4. +# +# USAGE: PYQT4_WRAP_QRC(output_files qrc_files) # # ARGUMENTS: # output_files [out] variable where output file names are listed to -# sip_files [in] list of *.sip files +# qrc_files [in] list of *.qrc 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. -# -# TODO: -# - Check if dependency of static sources on generated headers works properly: -# if header is changed, dependant sources should be recompiled. +# - Macro automatically adds custom build target to generate output files # #################################################################### -MACRO(PYQT4_WRAP_SIP outfiles) + +MACRO(PYQT4_WRAP_QRC outfiles) FOREACH(_input ${ARGN}) - FILE(STRINGS ${_input} _sip_modules REGEX "%Module") - FILE(STRINGS ${_input} _sip_classes REGEX "^class ") - SET(_output) - 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}) - 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() + GET_FILENAME_COMPONENT(_input_name ${_input} NAME) + STRING(REPLACE ".qrc" "_qrc.py" _input_name ${_input_name}) + SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name}) ADD_CUSTOM_COMMAND( OUTPUT ${_output} - COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} + COMMAND ${PYQT_PYRCC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} MAIN_DEPENDENCY ${_input} ) + SET(${outfiles} ${${outfiles}} ${_output}) ENDFOREACH() -ENDMACRO(PYQT4_WRAP_SIP) + _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_QRC_PY_FILES _uniqueTargetName) + ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL DEPENDS ${${outfiles}}) +ENDMACRO(PYQT4_WRAP_QRC)