diff options
author | Alex Neundorf <neundorf@kde.org> | 2012-02-12 17:57:28 (GMT) |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2012-02-12 17:57:28 (GMT) |
commit | 3b488228032e32f03a639af3a084a4e5ad3201bd (patch) | |
tree | 242169aefb019129f261bac8787c1326347ee516 /Modules/FindGettext.cmake | |
parent | 677047dda0620fa675bcc1a8bacde5388ad954c3 (diff) | |
download | CMake-3b488228032e32f03a639af3a084a4e5ad3201bd.zip CMake-3b488228032e32f03a639af3a084a4e5ad3201bd.tar.gz CMake-3b488228032e32f03a639af3a084a4e5ad3201bd.tar.bz2 |
FindGetText: fix multiple targets with the same name problem (CMP0002)
The functions in FindGettext create a custom target. If the functions
are called multiple times, multiple times the same target is created.
This works only if CMP0002 is set to OLD.
With this patch there is only one central target created, and each
invocation of the function creates a target with a unique name and
make the central target depend on this one.
Alex
Diffstat (limited to 'Modules/FindGettext.cmake')
-rw-r--r-- | Modules/FindGettext.cmake | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 635090b..6dbc026 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -61,6 +61,17 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext INCLUDE(CMakeParseArguments) +FUNCTION(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name) + SET(propertyName "_GETTEXT_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() + MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) # make it a real variable, so we can modify it here SET(_firstPoFile "${_firstPoFileArg}") @@ -94,7 +105,15 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) ENDFOREACH (_currentPoFile ) - ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles}) + IF(NOT TARGET translations) + ADD_CUSTOM_TARGET(translations) + ENDIF() + + _GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName) + + ADD_CUSTOM_TARGET(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles}) + + ADD_DEPENDENCIES(translations ${uniqueTargetName}) ENDMACRO(GETTEXT_CREATE_TRANSLATIONS ) @@ -133,11 +152,20 @@ FUNCTION(GETTEXT_PROCESS_POT_FILE _potFile) LIST(APPEND _gmoFiles ${_gmoFile}) ENDFOREACH (_lang ) + IF(NOT TARGET potfiles) + ADD_CUSTOM_TARGET(potfiles) + ENDIF() + + _GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName) + IF(_parsedArguments_ALL) - ADD_CUSTOM_TARGET(potfiles ALL DEPENDS ${_gmoFiles}) + ADD_CUSTOM_TARGET(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) ELSE(_parsedArguments_ALL) - ADD_CUSTOM_TARGET(potfiles DEPENDS ${_gmoFiles}) + ADD_CUSTOM_TARGET(${uniqueTargetName} DEPENDS ${_gmoFiles}) ENDIF(_parsedArguments_ALL) + + ADD_DEPENDENCIES(potfiles ${uniqueTargetName}) + ENDFUNCTION(GETTEXT_PROCESS_POT_FILE) @@ -165,11 +193,21 @@ FUNCTION(GETTEXT_PROCESS_PO_FILES _lang) LIST(APPEND _gmoFiles ${_gmoFile}) ENDFOREACH(_current_PO_FILE) + + IF(NOT TARGET pofiles) + ADD_CUSTOM_TARGET(pofiles) + ENDIF() + + _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName) + IF(_parsedArguments_ALL) - ADD_CUSTOM_TARGET(pofiles ALL DEPENDS ${_gmoFiles}) + ADD_CUSTOM_TARGET(${uniqueTargetName} ALL DEPENDS ${_gmoFiles}) ELSE(_parsedArguments_ALL) - ADD_CUSTOM_TARGET(pofiles DEPENDS ${_gmoFiles}) + ADD_CUSTOM_TARGET(${uniqueTargetName} DEPENDS ${_gmoFiles}) ENDIF(_parsedArguments_ALL) + + ADD_DEPENDENCIES(pofiles ${uniqueTargetName}) + ENDFUNCTION(GETTEXT_PROCESS_PO_FILES) IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) |