View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012603CMakeCMakepublic2011-11-30 22:362011-11-30 23:09
ReporterAndreas Schuh 
Assigned ToClinton Stimpson 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformApple MacOSOS XOS Version10.4.10
Product VersionCMake 2.8.5 
Target VersionFixed in Version 
Summary0012603: When passing ARGV or ARGN on to subfunction, empty elements are stripped off
DescriptionWhen attempting to pass on the optional or all arguments given to one function on to another function using ARGN or ARGV, the empty elements in those lists are stripped off.

Saving the attached example code in a file and executing it with "cmake -P <script>" outputs

foo(s;h;t)
bar(s;h;t)

though the expected output would have been

foo(s;h;;;t)
bar(s;h;;;t)

This bug is related to bug 0012303, but yet seems to differ.
Steps To Reproducecmake_minimum_required (VERSION 2.6)

function (foo)
  message ("foo(${ARGV})")
endfunction ()

function (bar)
  message ("bar(${ARGV})")
endfunction ()

function (foobar)
  foo (${ARGV})
  bar (${ARGN})
endfunction ()

foobar (s h "" "" "t")
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0027876)
Andreas Schuh (reporter)
2011-11-30 22:50

A workaround for this problem in my case was to use a macro instead of a function and in order to still take advantage of the function scopes call this macro inside a function.

Example:

function (set_target_properties)
  my_set_target_properties_impl(${ARGV}) # the macro still sees the empty elements
endfunction ()

function (my_set_target_properties)
  my_set_target_properties_impl(${ARGV}) # the macro still sees the empty elements
endfunction ()

macro (my_set_target_properties_impl)
  # do the actual work here
endmacro ()

Instead of

function (set_target_properties)
  my_set_target_properties(${ARGV}) # the function will not get the empty elements
endfunction ()



Or, the previously example modified:

cmake_minimum_required (VERSION 2.6)

function (foo)
  message ("foo(${ARGV})")
  foreach (ARG IN LISTS ARGV)
    if (ARG MATCHES "^$")
      message ("EMPTY ELEMENT IN LIST")
    endif ()
  endforeach ()
endfunction ()

macro (bar)
  message ("bar(${ARGV})")
  foreach (ARG IN LISTS ARGV)
    if (ARG MATCHES "^$")
      message ("EMPTY ELEMENT IN LIST")
    endif ()
  endforeach ()
endmacro ()

function (foobar)
  foo (${ARGV})
  bar (${ARGV})
endfunction ()


foobar (s h "" "" "t")
(0027877)
Clinton Stimpson (developer)
2011-11-30 23:09

Duplicate of 12303

 Issue History
Date Modified Username Field Change
2011-11-30 22:36 Andreas Schuh New Issue
2011-11-30 22:50 Andreas Schuh Note Added: 0027876
2011-11-30 23:09 Clinton Stimpson Note Added: 0027877
2011-11-30 23:09 Clinton Stimpson Status new => closed
2011-11-30 23:09 Clinton Stimpson Assigned To => Clinton Stimpson
2011-11-30 23:09 Clinton Stimpson Resolution open => duplicate


Copyright © 2000 - 2018 MantisBT Team