<div dir="ltr"><div dir="ltr"><div>So, a couple things:</div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF"><pre> string(TOUPPER ${lib} lib_upper)
set(WITH_LIB_${lib_upper}_EXAMPLES "")</pre></div></blockquote><div>This needs to be outside the foreach loop. It's getting reset to empty on every iteration rather than accumulating results</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF"><pre> list(APPEND ${WITH_LIB_${lib_upper}_EXAMPLES} ${CMAKE_MATCH_1})</pre></div></blockquote><div>Don't de-reference the first argument, just use the variable name itself, i.e.:</div><div>list(APPEND WITH_LIB_${lib_upper}_EXAMPLES ${CMAKE_MATCH_1})</div><div><br></div><div>This is also well suited to a function, which are generally preferred over macros as it will avoid polluting the current variable scope with temporary variables:</div><div><br></div><div style="margin-left:40px"><span style="font-family:courier new,monospace">function(bsBuildLibExamples lib)<br> string(TOUPPER ${lib} lib_upper)<br> set(all_lib_examples)<br> get_cmake_property(all_vars VARIABLES)<br> foreach(var IN LISTS all_vars)<br> if(var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")<br> list(APPEND all_lib_examples ${CMAKE_MATCH_1})<br> endif()<br> endforeach()<br> set(WITH_LIB_${lib_upper}_EXAMPLES "${all_lib_examples}" PARENT_SCOPE)<br>endmacro()</span></div><div><br></div><div>- Chuck<br></div></div></div>