[CMake] General question about variable scope.
Steven Truppe
workbench at gmx.at
Tue Jun 4 16:04:24 EDT 2019
Hi everyone,
i've the following code:
macro(bsBuildLibExamples lib)
# get all examples
get_cmake_property(_vars VARIABLES)
foreach(_var ${_vars})
string(TOUPPER ${lib} lib_upper)
set(WITH_LIB_${lib_upper}_EXAMPLES "")
if(_var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")
message(STATUS "Example found: ${CMAKE_MATCH_1}")
list(APPEND ${WITH_LIB_${lib_upper}_EXAMPLES} ${CMAKE_MATCH_1})
endif()
endforeach()
message(STATUS "Glad examples: ${WITH_LIB_GLAD_EXAMPLES}")
message(STATUS "GLFW examples: ${WITH_LIB_GLFW_EXAMPLES}")
endmacro()
The problem is that ${WITH_LIB_${lib_upper}_EXAMPLES} is not available
anymore after the foreach, i was not able to find something in the docs
about this, i hope someone here can help me out.
best regrads!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190604/6d8a6190/attachment.html>
More information about the CMake
mailing list