Update TDEL10n module - add excludes #4
Fusionado
SlavekB
fusionados 1 commits de feat/CMakeL10n-excludes
en master
hace 5 años
Cargando…
Referencia en una nueva incidencia
Aún no existe contenido.
Eliminar la rama con el nombre 'feat/CMakeL10n-excludes'
Eliminar una rama es permanente. NO PUEDE deshacerse. ¿Continuar?
As mentioned in TDE/tdelibs#8, it would be useful to have a way to determine EXCLUDES. The patch contained here adds this option.
need to review exclude modification loop
foreach( _src ${_files} )
foreach( _exclude ${_excludes} )
if( ${_src} MATCHES ${_exclude} )
list( REMOVE_ITEM _files ${_src} )
I am not sure how cmake handles that, but usually modifying a list that is also being iterated with a foreach at the same time, is a mistake. See line 283 and 285.
You should either
I have already tested this procedure several times and it works successfully. I think CMake will evaluate items for the foreach at the beginning of the cycle and then the changes in the list will have no undue impact on the cycle.
By the way, the same procedure is used also in loops for pick resource files (line 305) and desktop files (line 353).
cmake documentation does not add anything that helps. it may work fine, but still it is not best practice because we are relying on cmake to save/copy the list initially and then iterate over all items. Should this behavior change in future versions of cmake, we would have new bugs to fix.
If you believe it is safe enough due to previous testing, then ok.
you could do something like this (not sure about the exact cmake syntax):
I researched it again. Passing
${_files}
toforeach(…)
means, that the value of_files
list is expanded to its current content and passed as unquoted argument – see Unquoted Argument and Variable References in CMake documentation.Because the value of list is expanded into arguments before the
foreach(…)
starts then such use is and will be safe.In any case, I have now found the solution that will be the best:
list(FILTER …)
This could serve for all the cases we have now used. Because this is a change that applies not only to this PR but also to the existing code, I will probably prepare a separate patch => another commit and PR in this series.
Great, list (FILTER... ) looks good and it is even simpler to code 😄
Bad news: The
list( FILTER … )
is new in CMake 3.6, while we hold CMake 2.8 support. So I leave the existing code withforeach( … )
as it is now.ok. suggest we add a comment to make clear the modifying foreach look is safe 😄
empty lines could be better places to separate different foreach sections in files. I sae the problem in a few points.
13a14899d5
.