1 # Copyright (C) 2012-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
23 ####################################################################
25 # _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME: internal function
27 # Used to generate unique custom target name for usage in
28 # PYQT4_WRAP_UIC macro.
30 # USAGE: _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(prefix unique_name)
33 # prefix [in] prefix for the name
34 # unique_name [out] unique name generated by function
36 ####################################################################
37 FUNCTION(_PYQT4_WRAP_GET_UNIQUE_TARGET_NAME name unique_name)
38 SET(_propertyName "_PYQT4_WRAP_UNIQUE_COUNTER_${name}")
39 GET_PROPERTY(_currentCounter GLOBAL PROPERTY "${_propertyName}")
40 IF(NOT _currentCounter)
41 SET(_currentCounter 1)
43 SET(${unique_name} "${name}_${_currentCounter}" PARENT_SCOPE)
44 MATH(EXPR _currentCounter "${_currentCounter} + 1")
45 SET_PROPERTY(GLOBAL PROPERTY ${_propertyName} ${_currentCounter} )
48 ####################################################################
50 # PYQT4_WRAP_UIC macro
52 # Create Python modules by processing input *.ui (Qt designer) files with
55 # USAGE: PYQT4_WRAP_UIC(output_files pyuic_files)
58 # output_files [out] variable where output file names are listed to
59 # pyuic_files [in] list of *.ui files
62 # - Input files are considered relative to the current source directory.
63 # - Output files are generated in the current build directory.
64 # - Macro automatically adds custom build target to generate output files
66 ####################################################################
67 MACRO(PYQT4_WRAP_UIC outfiles)
71 FOREACH(_input ${ARGN})
72 GET_FILENAME_COMPONENT(_input_name ${_input} NAME)
73 STRING(REPLACE ".ui" "_ui.py" _input_name ${_input_name})
74 SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name})
77 COMMAND ${PYQT_PYUIC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
78 MAIN_DEPENDENCY ${_input}
80 SET(${outfiles} ${${outfiles}} ${_output})
82 _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName)
83 ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL DEPENDS ${${outfiles}})
88 # ANA: Workaround for the Microsoft Visual Studio 2010. Seems there is a bug in
89 # the Microsoft Visual Studio 2010 or CMake 2.8.10.2: custom target doesn't work
90 # for the list of the dependencies. It works only for the first dependency in the
91 # list. So generate separate target for the each input file. This problem will be
92 #investigated in the future.
95 SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
96 _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName)
97 ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL)
98 FOREACH(_input ${ARGN})
99 GET_FILENAME_COMPONENT(_input_name ${_input} NAME)
100 STRING(REPLACE ".ui" "_ui.py" _input_name ${_input_name})
101 SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name})
102 _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _TgName)
103 ADD_CUSTOM_TARGET(${_TgName} ${PYQT_PYUIC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
106 SET_TARGET_PROPERTIES(${_TgName} PROPERTIES FOLDER PYQT4_WRAP_UIC_TARGETS)
107 ADD_DEPENDENCIES(${_uniqueTargetName} DEPEND ${_TgName})
108 SET(${outfiles} ${${outfiles}} ${_output})
111 ENDMACRO(PYQT4_WRAP_UIC)
113 ####################################################################
115 # PYQT4_WRAP_SIP macro
117 # Generate C++ wrappings for *.sip files by processing them with sip.
119 # USAGE: PYQT4_WRAP_SIP(output_files sip_file [sip_file...] [OPTIONS options] [SOURCES sources])
121 # NOTES: See SIP_WRAP_SIP macro from UseSIP.cmake for the usage description.
123 ####################################################################
124 MACRO(PYQT4_WRAP_SIP outfiles)
125 SIP_WRAP_SIP(${outfiles} ${ARGN} OPTIONS ${PYQT_SIPFLAGS})
126 ENDMACRO(PYQT4_WRAP_SIP)
128 ####################################################################
130 # PYQT4_WRAP_QRC macro
132 # Generate Python wrappings for *.qrc files by processing them with pyrcc4.
134 # USAGE: PYQT4_WRAP_QRC(output_files qrc_files)
137 # output_files [out] variable where output file names are listed to
138 # qrc_files [in] list of *.qrc files
141 # - Input files are considered relative to the current source directory.
142 # - Output files are generated in the current build directory.
143 # - Macro automatically adds custom build target to generate output files
145 ####################################################################
147 MACRO(PYQT4_WRAP_QRC outfiles)
148 FOREACH(_input ${ARGN})
149 GET_FILENAME_COMPONENT(_input_name ${_input} NAME)
150 STRING(REPLACE ".qrc" "_qrc.py" _input_name ${_input_name})
151 SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_input_name})
154 COMMAND ${PYQT_PYRCC_PATH} -o ${_output} ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
155 MAIN_DEPENDENCY ${_input}
157 SET(${outfiles} ${${outfiles}} ${_output})
159 _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_QRC_PY_FILES _uniqueTargetName)
160 ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL DEPENDS ${${outfiles}})
161 ENDMACRO(PYQT4_WRAP_QRC)