From 1c34a194edd4d0370f1929a6a87c75c7a961cb36 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 3 Oct 2013 06:51:31 +0000 Subject: [PATCH] Porting to CMake: improve PYQT4_WRAP_UIC macro for multiple usage in the same project: name of the custom target should be globally unique within the project. --- adm_local/cmake_files/UsePyQt4.cmake | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/adm_local/cmake_files/UsePyQt4.cmake b/adm_local/cmake_files/UsePyQt4.cmake index a5c33abfc..aa41a6be2 100644 --- a/adm_local/cmake_files/UsePyQt4.cmake +++ b/adm_local/cmake_files/UsePyQt4.cmake @@ -18,6 +18,31 @@ # # Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +#################################################################### +# +# _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME: internal function +# +# Used to generate unique custom target name for usage in +# PYQT4_WRAP_UIC macro. +# +# USAGE: _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(prefix unique_name) +# +# ARGUMENTS: +# prefix [in] prefix for the name +# unique_name [out] unique name generated by function +# +#################################################################### +FUNCTION(_PYQT4_WRAP_GET_UNIQUE_TARGET_NAME name unique_name) + SET(_propertyName "_PYQT4_WRAP_UNIQUE_COUNTER_${name}") + GET_PROPERTY(_currentCounter GLOBAL PROPERTY "${_propertyName}") + IF(NOT _currentCounter) + SET(_currentCounter 1) + ENDIF() + SET(${unique_name} "${name}_${_currentCounter}" PARENT_SCOPE) + MATH(EXPR _currentCounter "${_currentCounter} + 1") + SET_PROPERTY(GLOBAL PROPERTY ${_propertyName} ${_currentCounter} ) +ENDFUNCTION() + #################################################################### # # PYQT4_WRAP_UIC macro @@ -49,7 +74,8 @@ MACRO(PYQT4_WRAP_UIC outfiles) ) SET(${outfiles} ${${outfiles}} ${_output}) ENDFOREACH() - ADD_CUSTOM_TARGET(BUILD_UI_PY_FILES ALL DEPENDS ${${outfiles}}) + _PYQT4_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _uniqueTargetName) + ADD_CUSTOM_TARGET(${_uniqueTargetName} ALL DEPENDS ${${outfiles}}) ENDMACRO(PYQT4_WRAP_UIC) #################################################################### -- 2.39.2