Files
OpenVulkano/cmake/functions/VarsFromFile.cmake
2024-08-04 14:43:31 +02:00

15 lines
593 B
CMake

function(VarsFromFile filename)
if (EXISTS ${filename})
file(STRINGS ${filename} ConfigContents)
foreach(NameAndValue ${ConfigContents})
# Strip leading spaces
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
# Find variable name
string(REGEX MATCH "^[^=]+" Name ${NameAndValue})
# Find the value
string(REPLACE "${Name}=" "" Value ${NameAndValue})
# Set the variable
set(${Name} "${Value}" PARENT_SCOPE)
endforeach()
endif ()
endfunction(VarsFromFile)