So, a couple things:
string(TOUPPER ${lib} lib_upper)
> set(WITH_LIB_${lib_upper}_EXAMPLES "")
>
> This needs to be outside the foreach loop. It's getting reset to empty on
every iteration rather than accumulating results
list(APPEND ${WITH_LIB_${lib_upper}_EXAMPLES} ${CMAKE_MATCH_1})
>
> Don't de-reference the first argument, just use the variable name itself,
i.e.:
list(APPEND WITH_LIB_${lib_upper}_EXAMPLES ${CMAKE_MATCH_1})
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:
function(bsBuildLibExamples lib)
string(TOUPPER ${lib} lib_upper)
set(all_lib_examples)
get_cmake_property(all_vars VARIABLES)
foreach(var IN LISTS all_vars)
if(var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")
list(APPEND all_lib_examples ${CMAKE_MATCH_1})
endif()
endforeach()
set(WITH_LIB_${lib_upper}_EXAMPLES "${all_lib_examples}" PARENT_SCOPE)
endmacro()
- Chuck
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake